diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2012-09-06 18:17:02 +0100 |
---|---|---|
committer | Jannis Pohlmann <jannis.pohlmann@codethink.co.uk> | 2012-09-10 11:38:23 +0000 |
commit | 9b2df7beae03860c0b3fae3f84e44cc265e25b20 (patch) | |
tree | ab64ef123470389ff768d2a1d43326156443b439 /morphlib/git.py | |
parent | 6075afa879da2eba9468b913332b41ff23a4e269 (diff) | |
download | morph-9b2df7beae03860c0b3fae3f84e44cc265e25b20.tar.gz |
morph branch: Fail if branch already exists in the system repo
Diffstat (limited to 'morphlib/git.py')
-rw-r--r-- | morphlib/git.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/morphlib/git.py b/morphlib/git.py index 0a4b01f4..f5722ebe 100644 --- a/morphlib/git.py +++ b/morphlib/git.py @@ -150,6 +150,14 @@ def checkout_ref(runcmd, gitdir, ref): '''Checks out a specific ref/SHA1 in a git working tree.''' runcmd(['git', 'checkout', ref], cwd=gitdir) +def ref_exists(runcmd, gitdir, ref): + '''Check if specific ref exists locally or in a remote.''' + try: + runcmd(['git', 'show-ref', '--quiet', ref], cwd=gitdir) + except cliapp.AppException: + return False + return True + def reset_workdir(runcmd, gitdir): '''Removes any differences between the current commit ''' '''and the status of the working directory''' |