diff options
Diffstat (limited to 'git_buildpackage/git_utils.py')
-rw-r--r-- | git_buildpackage/git_utils.py | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/git_buildpackage/git_utils.py b/git_buildpackage/git_utils.py index 1cd5e6d5..3e68b2d8 100644 --- a/git_buildpackage/git_utils.py +++ b/git_buildpackage/git_utils.py @@ -8,14 +8,9 @@ import os.path import re -def is_repository_clean(path): - """Does the repository at path contain any uncommitted modifications""" +def is_repository_clean(): + """Does the repository contain any uncommitted modifications""" clean_msg='nothing to commit' - try: - curdir=os.path.abspath(os.path.curdir) - os.chdir(path) - except OSError: - return False popen = subprocess.Popen(['git','status'], stdout=subprocess.PIPE) popen.wait() out=popen.stdout.readlines() @@ -25,17 +20,11 @@ def is_repository_clean(path): ret=True else: ret=False - os.chdir(curdir) return (ret, "".join(out)) -def get_repository_branch(path): - """on what branch is the repository at path?""" - try: - curdir=os.path.abspath(os.path.curdir) - os.chdir(path) - except OSError: - return None +def get_repository_branch(): + """on what branch is the repository""" popen = subprocess.Popen(['git','branch'], stdout=subprocess.PIPE) popen.wait() for line in popen.stdout: @@ -43,6 +32,16 @@ def get_repository_branch(path): return line.split(' ',1)[1].strip() +def has_branch(branch): + """check if the repository has branch branch""" + popen = subprocess.Popen(['git','branch'], stdout=subprocess.PIPE) + popen.wait() + for line in popen.stdout: + if line.split(' ',1)[1].strip() == branch: + return True + return False + + def is_repository(path): """Is there a git repository at path""" if not path: |