public
Created

Quick and dirty patch for gitk to make clickable bug/issue links when displaying commits

  • Download Gist
gistfile1.diff
Diff
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
From b35942dc61aaa07961662aaaea49eb89ae913670 Mon Sep 17 00:00:00 2001
From: Pat Thoyts <patthoyts@users.sourceforge.net>
Date: Fri, 9 Mar 2012 00:20:51 +0000
Subject: [PATCH] gitk: quick hack to make clickable bug links in commit
message
 
Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
---
gitk | 24 ++++++++++++++++++++++++
1 files changed, 24 insertions(+), 0 deletions(-)
 
diff --git a/gitk b/gitk
index 4719fd0..8be6044 100755
--- a/gitk
+++ b/gitk
@@ -6716,6 +6716,30 @@ proc appendwithlinks {text tags} {
setlink $linkid link$linknum
incr linknum
}
+ set bugs [regexp -indices -all -inline \
+ {(?:(?:jira)|(?:issue))\s+[0-9]+} $text]
+ foreach bug $bugs {
+ foreach {s e} $bug break
+ regexp {(?:(?:jira)|(?:issue))\s+([0-9]+)}\
+ [string range $text $s $e] -> bugid
+ incr e
+ $ctext tag add bug$bugid "$start + $s c" "$start + $e c"
+ setbuglink $bugid bug$bugid
+ }
+}
+
+proc setbuglink {bugid tag} {
+ global ctext
+ $ctext tag configure $tag -underline 1
+ $ctext tag bind $tag <Enter> [list linkcursor %W 1]
+ $ctext tag bin $tag <Leave> [list linkcursor %W -1]
+ $ctext tag bind $tag <1> \
+ [list browseto "http://bugzilla.example.com/show_bug.cgi?id=$bugid"]
+}
+
+proc browseto {url} {
+ puts stderr "Launching browser for $url"
+ exec git web--browse $url &
}
proc setlink {id lk} {
--
1.7.9.msysgit.0

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.