All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

Commit 05a4a77b authored by Robert Ricci's avatar Robert Ricci

Add host and path headers to gitmail

For now, these go into headers (X-Git-Repo-Host and X-Git-Repo-Path)
Might consider moving them to the body of the mail at some point.

Note that I *don't* attempt to figure out the actual 'URL' for the
repo, since that is *not* necessarily automatically derivable: eg.
it might be any of ssh,git, or http protocols, and the path (esp.
for git: and http:) might not match the path in the filesystem. So
this suggests that wat goes into the body of the mail ought to be
set with a config variable.
parent b6dc5a0e
......@@ -268,6 +268,8 @@ sub debug(@);
sub object_exists($$);
sub filter_out_objects_in_repo($@);
sub generate_messageid();
sub get_hostname();
sub get_pathname();
######################################################################
# Main Body
......@@ -1004,6 +1006,12 @@ sub send_mail($$$@) {
}
print MAIL "X-Git-Ref: $refname\n";
#
# Add headers to help people figure out where this repo lives
#
print MAIL "X-Git-Repo-Host: " . get_hostname() . "\n";
print MAIL "X-Git-Repo-Path: " . get_pathname() . "\n";
#
# Marks end of headers
#
......@@ -1207,3 +1215,22 @@ sub generate_messageid() {
return $msgid;
}
#
# Get the hostame - right now, only supports using the 'hostname' command, by
# might be configurable at some point in the future
#
sub get_hostname() {
my $hostname = `$HOSTNAME -f $STDERRNULL`;
chomp $hostname;
return $hostname;
}
#
# Gets the path for the repo
#
sub get_pathname() {
my $pwd = `$GIT rev-parse --show-toplevel $STDERRNULL`;
chomp $pwd;
return $pwd;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment