summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Brown <ben.brown@codethink.co.uk>2017-10-16 12:23:07 +0000
committerBen Brown <ben.brown@codethink.co.uk>2017-10-16 12:23:07 +0000
commit97ac065bd946fb611407dbabe4bf642e2813568b (patch)
tree53a67db393a967e5fe50aeed4cd96ae0f4838ae0
parentdaeb29e2f43e76b2215de23398ae783553311745 (diff)
parent1ece185bcbb2e09894430dc08d4e4136dc5fbf17 (diff)
downloadybd-97ac065bd946fb611407dbabe4bf642e2813568b.tar.gz
Merge branch 'benbrown/old-git-sha-contains' into 'master'
Add tag check to for-each-ref replacement See merge request baserock/ybd!394
-rw-r--r--ybd/repos.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/ybd/repos.py b/ybd/repos.py
index 1b4da71..df5d99a 100644
--- a/ybd/repos.py
+++ b/ybd/repos.py
@@ -113,15 +113,17 @@ def ensure_ref_contains_sha(dn, gitdir, ref, sha):
if ref == sha:
return
- def sha_in_ref():
+ def sha_in_ref(tag=False):
+ args = ['git', "tag" if tag else "branch", '--contains', sha, ref]
+ if tag:
+ args.insert(2, '-l')
try:
- return bool(check_output(['git', 'branch', '--contains',
- sha, ref], stderr=fnull,
- universal_newlines=True).strip())
+ return bool(check_output(
+ args, stderr=fnull, universal_newlines=True).strip())
except:
return False
- if not sha_in_ref():
+ if not sha_in_ref() and not sha_in_ref(tag=True):
# The sha may currently exist in another branch,
# force an update of the provided ref.
repo_url = get_repo_url(dn['repo'])
@@ -129,7 +131,7 @@ def ensure_ref_contains_sha(dn, gitdir, ref, sha):
'+refs/*/{0}:refs/*/{0}'.format(ref)],
stdout=fnull, stderr=fnull)
- if not sha_in_ref():
+ if not sha_in_ref() and not sha_in_ref(tag=True):
exit = check == 'exit'
app.log(dn, 'WARNING: unable to find %s within' %
sha, ref, exit=exit)