From 351565faaf660a51331eae3540dbd3620415d97b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Elliott=20B=C3=A9cue?= Date: Mon, 22 Jun 2015 03:43:01 +0200 Subject: [PATCH] On compatibilise git-notify avec les urls gitlab. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Il faut penser à changer l'attribut baseurl * Il faut ajouter isgitlab = 1 * Il faut préciser gitlabowner = membres-actifs ou gitlabowner = nounous Etc etc. --- utils/git-notify | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/utils/git-notify b/utils/git-notify index 87de54b2..48555e7c 100755 --- a/utils/git-notify +++ b/utils/git-notify @@ -52,6 +52,10 @@ my $debug = 0; # base URL of the gitweb repository browser (can be set with the -u option) my $gitweb_url = git_config( "notify.baseurl" ); +# The git server is behind gitlab +my $is_gitlab = git_config( "notify.isgitlab" ) || ""; +my $gitlab_owner = git_config( "notify.gitlabowner" ) || ""; + # default repository name (can be changed with the -r option) my $repos_name = git_config( "notify.repository" ) || get_repos_name(); @@ -147,6 +151,7 @@ sub parse_options() elsif ($arg eq '-r') { $repos_name = shift @ARGV; } elsif ($arg eq '-s') { $max_diff_size = shift @ARGV; } elsif ($arg eq '-u') { $gitweb_url = shift @ARGV; } + elsif ($arg eq '-g') { $is_gitlab = shift @ARGV; } elsif ($arg eq '-i') { push @include_list, shift @ARGV; } elsif ($arg eq '-x') { push @exclude_list, shift @ARGV; } elsif ($arg eq '-X') { push @revlist_options, "--no-merges"; } @@ -260,7 +265,7 @@ sub send_commit_notice($$) "Module: $repos_name", "Branch: $ref", "Tag: $obj", - $gitweb_url ? "URL: $gitweb_url;a=tag;h=$obj\n" : "", + $gitweb_url ? "URL: $gitweb_url". ($is_gitlab ? "/tag/$obj\n" : ";a=tag;h=$obj\n") : "", "Tagger: " . $info{"tagger"}, "Date: " . format_date($info{"tagger_date"},$info{"tagger_tz"}), "", @@ -273,7 +278,7 @@ sub send_commit_notice($$) "Module: $repos_name", "Branch: $ref", "Commit: $obj", - $gitweb_url ? "URL: $gitweb_url;a=commit;h=$obj\n" : "", + $gitweb_url ? "URL: $gitweb_url". ($is_gitlab ? "/commit/$obj\n" : ";a=commit;h=$obj\n") : "", "Author: " . $info{"author"}, "Date: " . format_date($info{"author_date"},$info{"author_tz"}), "", @@ -296,7 +301,7 @@ sub send_commit_notice($$) } else { - push @notice, "Diff: $gitweb_url;a=commitdiff;h=$obj" if $gitweb_url; + push @notice, "Diff: $gitweb_url". ($is_gitlab ? "/commit/$obj" : ";a=commit;h=$obj") if $gitweb_url; } $subject = "Git commit ($repos_name/$ref): " . ${$info{"log"}}[0]; @@ -352,7 +357,7 @@ sub send_cia_notice($$) push @cia_text, " ", - $gitweb_url ? " " . xml_escape("$gitweb_url;a=commit;h=$commit") . "" : "", + $gitweb_url ? " " . xml_escape("$gitweb_url". ($is_gitlab ? "/commit/$commit" : ";a=commit;h=$commit")) . "" : "", " ", " ", " " . $info{"author_date"} . "", @@ -422,7 +427,7 @@ sub send_all_notices($$$) parse_options(); # append repository path to URL -$gitweb_url .= "?p=$repos_name.git" if $gitweb_url; +$gitweb_url .= $gitweb_url ? $is_gitlab ? "/$gitlab_owner/$repos_name" : "?p=$repos_name.git" : ""; if (@ARGV) {