Skip to content

Instantly share code, notes, and snippets.

@patthoyts
Created March 9, 2012 00:24
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save patthoyts/2004319 to your computer and use it in GitHub Desktop.
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
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment