Browse Source

Bug 1024443 - Add support for github log+blame and enable for Gaia/Rust/Servo; r=fubar

Ed Morley 10 years ago
parent
commit
27f2f297fa
3 changed files with 43 additions and 0 deletions
  1. 22 0
      Local.pm
  2. 4 0
      template-ident-fileref
  3. 17 0
      template-source-head

+ 22 - 0
Local.pm

@@ -932,6 +932,9 @@ sub localexpandtemplate
                           ('gitpath',           \&gitpath),
                           ('begingitorious',    \&begingitorious),
                           ('endgitorious',      \&endgitorious),
+                          ('githubhost',        \&githubhost),
+                          ('begingithub',       \&begingithub),
+                          ('endgithub',         \&endgithub),
                           ('oghghost',          \&oghghost),
                           ('beginoghg',         \&beginoghg),
                           ('endoghg',           \&endoghg),
@@ -1204,6 +1207,25 @@ sub endgitorious
     return &endskip;
 }
 
+sub githubrepo
+{
+    return 'https://github.com/mozilla-b2g/gaia' if $Path->{'real'} =~ /gaia/;
+    return 'https://github.com/mozilla/rust' if $Path->{'real'} =~ /rust/;
+    return 'https://github.com/mozilla/servo' if $Path->{'real'} =~ /servo/;
+    return '';
+}
+
+sub begingithub
+{
+    return &beginskip unless githubrepo();
+    return '';
+}
+
+sub endgithub
+{
+    return &endskip;
+}
+
 sub ogroot
 {
     my ($virt, $real) = ($Path->{'virt'}, $Path->{'real'});

+ 4 - 0
template-ident-fileref

@@ -9,3 +9,7 @@ $beginwebhg
 <span class=bonsailinks>(View <a href="$webhghost/log/$hgbranch/$hgpath/$filename">Hg log</a> or
 <a href="$webhghost/annotate/$hgversion/$hgpath/$filename">Hg annotations</a>)</span>
 $endwebhg
+$begingithub
+<span class=bonsailinks>(View <a href="$githubrepo/commits/$gitrev$gitpath/$filename">Git log</a> or
+<a href="$githubrepo/blame/$gitrev$gitpath/$filename">Git blame</a>)</span>
+$endgithub

+ 17 - 0
template-source-head

@@ -36,6 +36,23 @@ $begingitorious
       <a href="$gitorioushost/blobs/history/$gitrev$gitpath/$filename"
 >History</a><br>
 $endgitorious
+$begingithub
+<script>
+function updateGithubBlameHash(node, event) {
+  if (!document.location.hash)
+    return;
+  var anchor = document.location.hash;
+  anchor = anchor.replace("#", "#L");
+  node.href =
+    node.href.replace(/#.*|$/, anchor);
+}
+</script>
+<a href="$githubrepo/commits/$gitrev$gitpath/$filename">Git Log</a><br>
+<a href="$githubrepo/blame/$gitrev$gitpath/$filename"
+onfocus='updateGithubBlameHash(this, event)'
+onmouseover='updateGithubBlameHash(this, event)'
+>Git Blame</a><br>
+$endgithub
 $beginbonsai
       <a href="$bonsaihost/cvslog.cgi?file=$cvspath/$filename&amp;rev=$cvsbranch&amp;mark=$cvsversion"
 >CVS Log</a><br>