[kteam-tools] Fix inconvenient usage of strip

Stefan Bader stefan.bader at canonical.com
Fri Jun 21 11:54:06 UTC 2013


>From e5ea00c057f0541a1a9e319d3ed43700c44a0ba0 Mon Sep 17 00:00:00 2001
From: Stefan Bader <stefan.bader at canonical.com>
Date: Fri, 21 Jun 2013 13:47:49 +0200
Subject: [PATCH] ktl: Git.current_branch: Fix inconvenient usage of strip

The argument to strip is a list of letters to remove from one side,
not a prefix. This is inconvenient if the text after the prefix
happens to start with one or more of those letters.

Signed-off-by: Stefan Bader <stefan.bader at canonical.com>
---
 ktl/git.py |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ktl/git.py b/ktl/git.py
index 28412af..3d6b3d3 100644
--- a/ktl/git.py
+++ b/ktl/git.py
@@ -98,7 +98,7 @@ class Git:
         status, result = run_command("git symbolic-ref HEAD", cls.debug)
         if status != 0:
             raise GitError("no current branch")
-        return result[0].lstrip("refs/heads/")
+        return result[0].split("/")[-1]
 
     # show
     #
-- 
1.7.9.5





More information about the kernel-team mailing list