From 7f83ca76e428f2aa018084bd2f0800e58dcb0c91 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Tue, 24 Sep 2013 16:45:42 +0100 Subject: [PATCH 2/2] Git: Fixed presentation of branches containing front-slashes. Many projects use hierarchical branch names, for example: "devs/tasn/feature-branch" Before this commit, the branch above would be printed as "feature-branch" instead of "devs/tasn/feature-branch". --- irkerhook.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/irkerhook.py b/irkerhook.py index b4a4164..d89cc3b 100755 --- a/irkerhook.py +++ b/irkerhook.py @@ -39,7 +39,7 @@ default_channels = "irc://chat.freenode.net/#commits" version = "1.20" -import os, sys, commands, socket, urllib, subprocess, locale, datetime +import os, sys, commands, socket, urllib, subprocess, locale, datetime, re from pipes import quote as shellquote try: import simplejson as json # Faster, also makes us Python-2.5-compatible @@ -258,7 +258,8 @@ class GitExtractor(GenericExtractor): def commit_factory(self, commit_id): "Make a Commit object holding data for a specified commit ID." commit = Commit(self, commit_id) - commit.branch = os.path.basename(self.refname) + # Get rid of refs/*/ for cleaner output. + commit.branch = re.sub(r"^refs/[^/]*/", "", self.refname) # Compute a description for the revision if self.revformat == 'raw': commit.rev = commit.commit -- 1.8.1.5