Created
March 9, 2012 00:24
-
-
Save patthoyts/2004319 to your computer and use it in GitHub Desktop.
Quick and dirty patch for gitk to make clickable bug/issue links when displaying commits
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From b35942dc61aaa07961662aaaea49eb89ae913670 Mon Sep 17 00:00:00 2001 | |
From: Pat Thoyts <[email protected]> | |
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 <[email protected]> | |
--- | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment