Skip to content

Instantly share code, notes, and snippets.

@jimtreadway
Created October 21, 2010 01:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimtreadway/637716 to your computer and use it in GitHub Desktop.
Save jimtreadway/637716 to your computer and use it in GitHub Desktop.
A very simple but ugly hack to link to Git comment ids from a Bugzilla comment.
--- Template.pm.orig 2010-10-20 17:16:02.000000000 -0700
+++ Template.pm 2010-10-20 17:59:23.000000000 -0700
@@ -234,6 +234,25 @@
("\0\0" . ($count-1) . "\0\0")
~egmxi;
+ # Link to Git repository
+ if ($text =~ /\bcommit\s*[a-zA-Z0-9]+/) {
+ my $gitweb = "http://example.com/git";
+ my %repos = (
+ "2" => "product2.git",
+ "3" => "product3.git",
+ "5" => "product5.git",
+ "6" => "product6.git"
+ );
+ my $dbh = Bugzilla->dbh;
+ my ($product_id) =
+ $dbh->selectrow_array('SELECT product_id FROM bugs WHERE bug_id = ?',
+ undef, $curr_bugid);
+ my $repo = $repos{$product_id};
+ if ($repo) {
+ $text =~ s#\b(commit\s*)([a-zA-Z0-9]+)#$1<a href="$gitweb/?p=$repo;a=commit;h=$2">$2</a>#ig;
+ }
+ }
+
# Current bug ID this comment belongs to
my $current_bugurl = $curr_bugid ? "show_bug.cgi?id=$curr_bugid" : "";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment