Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
emulab
emulab-devel
Commits
9ab4f937
Commit
9ab4f937
authored
Oct 26, 2014
by
Robert Ricci
Browse files
Clean up and actually call sendmail
parent
c999a2ad
Changes
1
Hide whitespace changes
Inline
Side-by-side
tools/git/gitissued
View file @
9ab4f937
...
...
@@ -197,24 +197,24 @@ sub send_message($$) {
#
# Get information about the project, so that we know where the repo lives,
# etc.
# NB: This depends on the Utah patch to gitlab that adds the project ID
# to the data in the hook
#
my
$repoinfo
=
call_gitlab_api
("
/projects/
"
.
$attr
->
{"
project_id
"});
#
# Build up options that we'll pass to gitmail
#
my
%options
;
#
# Who the mail comes from
$options
{'
mailfrom
'}
=
$authorinfo
->
{
name
}
.
"
<
"
.
$authorinfo
->
{
email
}
.
"
>
";
#
my
$mailfrom
=
$authorinfo
->
{
name
}
.
"
<
"
.
$authorinfo
->
{
email
}
.
"
>
";
#
# Name of the repo
#
my
$reponame
=
$repoinfo
->
{
path_with_namespace
};
$options
{'
alwaysmail
'}
=
get_member_addresses
(
$attr
->
{"
project_id
"});
#
# Mail to all project members
#
my
$mailto
=
get_member_addresses
(
$attr
->
{"
project_id
"});
#
# Actually send the mail
...
...
@@ -222,10 +222,21 @@ sub send_message($$) {
if
(
$debug
)
{
open
(
MAIL
,"
>&STDERR
");
print
MAIL
"
\n\n
";
}
else
{
# sendmail args:
# -oem causes errors in mail to be "mailed back"
# -odb deliver mail in background
# -t causes sendmail to look in the message for 'To:' 'Cc:' and
# 'Bcc:' lines
open
(
MAIL
,
"
| /usr/sbin/sendmail -odb -oem -f'
$mailfrom
' -t
");
}
print
MAIL
"
From:
"
.
$options
{"
mailfrom
"}
.
"
\n
";
print
MAIL
"
To:
"
.
join
("
,
",
@
{
$options
{'
alwaysmail
'}})
.
"
\n
";
#
# Basic headers
#
print
MAIL
"
From:
"
.
$mailfrom
.
"
\n
";
print
MAIL
"
To:
"
.
join
("
,
",
$mailto
)
.
"
\n
";
print
MAIL
"
Subject: gitlab issue: [
$reponame
] issue #
"
.
$attr
->
{"
iid
"}
.
"
"
.
$attr
->
{"
action
"}
.
"
(
"
.
$attr
->
{"
state
"}
.
"
)
"
.
"
\n
";
print
MAIL
"
Message-Id:
$messageid
\n
";
...
...
@@ -242,6 +253,9 @@ sub send_message($$) {
#
print
MAIL
"
\n
";
#
# Put the basics in the mail
#
print
MAIL
"
Issue #
"
.
$attr
->
{"
iid
"}
.
"
-
"
.
$attr
->
{"
title
"}
.
"
\n
";
print
MAIL
"
Action:
"
.
$attr
->
{"
action
"}
.
"
\n
";
print
MAIL
"
State:
"
.
$attr
->
{"
state
"}
.
"
\n
";
...
...
@@ -254,6 +268,10 @@ sub send_message($$) {
print
MAIL
$attr
->
{"
description
"};
print
"
\n
";
if
(
!
$debug
)
{
close
MAIL
;
}
#
# Done!
#
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment