[kteam-tools] Fix inconvenient usage of strip
Brad Figg
brad.figg at canonical.com
Fri Jun 21 14:41:52 UTC 2013
On 06/21/2013 04:54 AM, Stefan Bader wrote:
> 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
> #
>
Or how about a "replace('refs/heads/', '')" ?
--
Brad Figg brad.figg at canonical.com http://www.canonical.com
More information about the kernel-team
mailing list