From f337b8a649b003c9fcc9d8aa3677c290fa0d8859 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Tue, 25 Oct 2011 13:01:49 +0200 Subject: GitRepository: Allow to list local branches --- gbp/git.py | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/gbp/git.py b/gbp/git.py index 8c0debf..98f23f1 100644 --- a/gbp/git.py +++ b/gbp/git.py @@ -711,12 +711,38 @@ class GitRepository(object): name = os.getenv("GIT_AUTHOR_NAME", name) return (name, email) - def get_remote_branches(self): - """Get all remote branches""" - args = [ '--format=%(refname:short)', 'refs/remotes/' ] + def get_branches(self, remote=False): + """ + Get list of branches + + @param remote: whether to list local or remote branches + @type remote: bool + @return: local or remote branches + @rtype: list + """ + args = [ '--format=%(refname:short)' ] + args += [ 'refs/remotes/' ] if remote else [ 'refs/heads/' ] out = self.__git_getoutput('for-each-ref', args)[0] return [ ref.strip() for ref in out ] + def get_remote_branches(self): + """ + Get list of remote branches + + @return: remote branches + @rtype: list + """ + return self.get_branches(remote=True) + + def get_local_branches(self): + """ + Get list of local branches + + @return: local branches + @rtype: list + """ + return self.get_branches(remote=False) + def get_remote_repos(self): """Get all remote repositories""" out = self.__git_getoutput('remote')[0] -- cgit v1.2.3