summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Brown <ben.brown@codethink.co.uk>2017-10-16 11:21:24 +0100
committerBen Brown <ben.brown@codethink.co.uk>2017-10-16 11:21:24 +0100
commit1b1e373e020d586a0f5157be4032f74cbb1d5c9b (patch)
treece5febc9c3265648f3a73af2ef539ab92dcc4681
parentdaeb29e2f43e76b2215de23398ae783553311745 (diff)
downloadybd-benbrown/old-git-sha-contains.tar.gz
Add tag check to for-each-ref replacementbenbrown/old-git-sha-contains
-rw-r--r--ybd/repos.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/ybd/repos.py b/ybd/repos.py
index 1b4da71..0deb9b8 100644
--- a/ybd/repos.py
+++ b/ybd/repos.py
@@ -113,15 +113,16 @@ def ensure_ref_contains_sha(dn, gitdir, ref, sha):
if ref == sha:
return
- def sha_in_ref():
+ def sha_in_ref(tag=False):
+ arg = "tag" if tag else "branch"
try:
- return bool(check_output(['git', 'branch', '--contains',
+ return bool(check_output(['git', arg, '--contains',
sha, ref], 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 +130,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)