From 1ece185bcbb2e09894430dc08d4e4136dc5fbf17 Mon Sep 17 00:00:00 2001 From: Ben Brown Date: Mon, 16 Oct 2017 11:21:24 +0100 Subject: Add tag check to for-each-ref replacement --- ybd/repos.py | 14 ++++++++------ 1 file 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) -- cgit v1.2.1