[bugzilla-gnome-org-customizations/wip/xclaesse/branch: 31/31] Automatically link Git wip/ branches to the corresponding URL



commit 6b3772e24173eb1ce29616788789d823f7d8570e
Author: Xavier Claessens <xavier claessens collabora com>
Date:   Thu Feb 5 15:16:48 2015 -0500

    Automatically link Git wip/ branches to the corresponding URL
    
    Automatically link "branch wip/$branch" to the corresponding URL for that branch
    on https://git.gnome.org. The URL construction relies on the product name of the
    Bugzilla report so if the name in Bugzilla does not match the repository name in
    Git the URL will be a 404. So you might want to make sure that names are the
    same in Bugzilla

 extensions/GNOME/Extension.pm |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
---
diff --git a/extensions/GNOME/Extension.pm b/extensions/GNOME/Extension.pm
index e5bd37f..2c6b702 100644
--- a/extensions/GNOME/Extension.pm
+++ b/extensions/GNOME/Extension.pm
@@ -301,15 +301,27 @@ sub bug_format_comment {
          replace => sub { _createGitCommitLink($self, $args); }
      };
      push( @$regexes, $replacerGitCommit );
+
+     my $replacerGitBranch = {
+         match => qr{\b(branch\s)(wip/[\w\-\/]+)}i,
+         replace => sub { _createGitBranchLink($self, $args); }
+     };
+     push( @$regexes, $replacerGitBranch );
    }
 }
 
 sub _createGitCommitLink {
-
    my ($self, $args) = @_;
    my $productname = $args->{'bug'}->product;
    my $commit_link = join("", $1, '<a href="https://git.gnome.org/browse/', url_quote($productname), 
'/commit/?id=', $2, '">', $2, '</a>');
    return $commit_link;
 };
 
+sub _createGitBranchLink {
+   my ($self, $args) = @_;
+   my $productname = $args->{'bug'}->product;
+   my $branch_link = join("", $1, '<a href="https://git.gnome.org/browse/', url_quote($productname), 
'/log/?h=', $2, '">', $2, '</a>');
+   return $branch_link;
+};
+
 __PACKAGE__->NAME;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]