diff options
author | Guido Guenther <agx@sigxcpu.org> | 2006-12-10 16:07:37 +0100 |
---|---|---|
committer | Guido Guenther <agx@bogon.sigxcpu.org> | 2006-12-10 16:07:37 +0100 |
commit | ff7797932f04a625d92d7e63e9af5bfbe1076a9d (patch) | |
tree | a17fcd130ef15482f6a4823b95b50ac2043b7a46 /git_buildpackage | |
parent | 093704c9c7e16d71659c49661ce91c605bfabd45 (diff) |
git-buildpackage: detect the branch we're on and bail out if it's not the debian branchdebian/0.2.18
Diffstat (limited to 'git_buildpackage')
-rw-r--r-- | git_buildpackage/config.py | 1 | ||||
-rw-r--r-- | git_buildpackage/git_utils.py | 28 |
2 files changed, 26 insertions, 3 deletions
diff --git a/git_buildpackage/config.py b/git_buildpackage/config.py index a6f3ff7d..e1fde158 100644 --- a/git_buildpackage/config.py +++ b/git_buildpackage/config.py @@ -25,6 +25,7 @@ class GBPOptionParser(OptionParser): defaults={ 'builder' : 'debuild', 'debian-branch' : 'master', 'upstream-branch' : 'upstream', + 'upstream-branch' : 'upstream', 'sign-tags' : '', # empty means False 'keyid' : '', } diff --git a/git_buildpackage/git_utils.py b/git_buildpackage/git_utils.py index 59f80f25..1cd5e6d5 100644 --- a/git_buildpackage/git_utils.py +++ b/git_buildpackage/git_utils.py @@ -1,12 +1,16 @@ # -*- coding: utf-8 -*- +# # (C) 2006 Guido Guenther <agx@sigxcpu.org> """provides some git repository related helpers""" import subprocess import os.path +import re + def is_repository_clean(path): """Does the repository at path contain any uncommitted modifications""" + clean_msg='nothing to commit' try: curdir=os.path.abspath(os.path.curdir) os.chdir(path) @@ -15,13 +19,30 @@ def is_repository_clean(path): popen = subprocess.Popen(['git','status'], stdout=subprocess.PIPE) popen.wait() out=popen.stdout.readlines() - if out[0].strip() != 'nothing to commit': - ret=False - else: + if out[0].strip() == clean_msg: + ret=True + elif out[0].startswith('#') and out[1].strip() == clean_msg: 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 + popen = subprocess.Popen(['git','branch'], stdout=subprocess.PIPE) + popen.wait() + for line in popen.stdout: + if line.startswith('*'): + return line.split(' ',1)[1].strip() + + def is_repository(path): """Is there a git repository at path""" if not path: @@ -32,6 +53,7 @@ def is_repository(path): return False return True + def sanitize_version(version): """sanitize a version so git accepts it as a tag""" if ':' in version: # strip of any epochs |