Commit 1ec3af6c authored by Robert Ricci's avatar Robert Ricci
Browse files

First working version!

parent 5a4ed942
...@@ -29,6 +29,7 @@ print "GITMAIL is $GITMAIL\n"; ...@@ -29,6 +29,7 @@ print "GITMAIL is $GITMAIL\n";
my $TOKEN = ""; my $TOKEN = "";
my $BASEURL = "http://git.flux.utah.edu/"; my $BASEURL = "http://git.flux.utah.edu/";
my $BASEPATH = "/home/git/repositories"; my $BASEPATH = "/home/git/repositories";
my $DEFAULT_ARCHIVEMAIL = 'ricci@cs.utah.edu';
sub run_gitmail($); sub run_gitmail($);
...@@ -74,11 +75,28 @@ sub run_gitmail($) { ...@@ -74,11 +75,28 @@ sub run_gitmail($) {
my $repodir = $BASEPATH . "/" . $repoinfo->{"path_with_namespace"} . ".git"; my $repodir = $BASEPATH . "/" . $repoinfo->{"path_with_namespace"} . ".git";
chdir $repodir; chdir $repodir;
my %options;
$options{'archivemail'} = $DEFAULT_ARCHIVEMAIL;
$options{'mailfrom'} = $userinfo->{name} . " <" . $userinfo->{email} . ">";
my $optionstr = format_options(%options);
print "optionstr is '$optionstr'\n";
# #
# Run gitmail in test mode for now # Run gitmail in test mode for now
# #
my $pid = open3(\*CHLD_IN, \*CHLD_OUT, \*CHLD_ERR, my $pid = open3(\*CHILD_IN, \*CHILD_OUT, \*CHILD_ERR,
"$GITMAIL -d -t"); "$GITMAIL $optionstr");
#
# Pass along the commit information we were given, in the form expected
# by a git commit hook
#
print CHILD_IN $refline . "\n";
close CHILD_IN;
waitpid $pid,0; waitpid $pid,0;
print STDOUT <CHILD_OUT>; print STDOUT <CHILD_OUT>;
print STDOUT <CHILD_ERR>; print STDOUT <CHILD_ERR>;
...@@ -101,3 +119,13 @@ sub call_gitlab_api($) { ...@@ -101,3 +119,13 @@ sub call_gitlab_api($) {
# Error checking # Error checking
return decode_json($response->content); return decode_json($response->content);
} }
#
# Re-format a hash as a string sutable for passing to gitmail
# TODO: support mutiple options
# TODO: proper command line escaping
#
sub format_options(@) {
my %opt = @_;
return join(" ",map { "-o " . $_ . "='$opt{$_}'"} keys %opt);
}
Supports Markdown
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