Always resolve branches to a SHA if a tag isn't available

The list changes output of I5485b7ea35be76d7c980e7b222b0c3320770493c
looks 'messy' as some branches do not resolve to a tag.  A shell based
example of what the current code does:

[tony@thor networking-bgpvpn]$ for branch in $(git branch -a | grep -v -- -\> | tr  '[*]' '[ ]') ; do printf "%-30s %s\n" $branch $(git describe --abbrev=0 $branch); done
master                         7.0.0.0rc1
fatal: No tags can describe '8ff78c308a004cdc948c804190d1178d7263781f'.
Try --always, or create some tags.
remotes/gerrit/backport/juno
fatal: No tags can describe '06aa314936eb9a43d358ed75b2e8fef2dadb59d6'.
Try --always, or create some tags.
remotes/gerrit/backport/kilo
remotes/gerrit/master          7.0.0.0rc1
remotes/gerrit/stable/newton   5.0.0
remotes/gerrit/stable/ocata    6.0.0
remotes/gerrit/stable/pike     7.0.0
fatal: No tags can describe '8ff78c308a004cdc948c804190d1178d7263781f'.
Try --always, or create some tags.
remotes/origin/backport/juno
fatal: No tags can describe '06aa314936eb9a43d358ed75b2e8fef2dadb59d6'.
Try --always, or create some tags.
remotes/origin/backport/kilo
remotes/origin/master          7.0.0.0rc1
remotes/origin/stable/newton   5.0.0
remotes/origin/stable/ocata    6.0.0
remotes/origin/stable/pike     7.0.0

Adding --always:
[tony@thor networking-bgpvpn]$ for branch in $(git branch -a | grep -v -- -\> | tr  '[*]' '[ ]') ; do printf "%-30s %s\n" $branch $(git describe --always --abbrev=0 $branch); done
master                         7.0.0.0rc1
remotes/gerrit/backport/juno   8ff78c308a004cdc948c804190d1178d7263781f
remotes/gerrit/backport/kilo   06aa314936eb9a43d358ed75b2e8fef2dadb59d6
remotes/gerrit/master          7.0.0.0rc1
remotes/gerrit/stable/newton   5.0.0
remotes/gerrit/stable/ocata    6.0.0
remotes/gerrit/stable/pike     7.0.0
remotes/origin/backport/juno   8ff78c308a004cdc948c804190d1178d7263781f
remotes/origin/backport/kilo   06aa314936eb9a43d358ed75b2e8fef2dadb59d6
remotes/origin/master          7.0.0.0rc1
remotes/origin/stable/newton   5.0.0
remotes/origin/stable/ocata    6.0.0
remotes/origin/stable/pike     7.0.0

Change-Id: Ic59797ea2c7e2278e8b25f45511009620e6f103a
This commit is contained in:
Tony Breeds 2017-09-22 08:42:51 -04:00
parent 8de8bed659
commit 6434830358

View File

@ -207,7 +207,7 @@ def check_ancestry(workdir, repo, old_version, sha):
def get_latest_tag(workdir, repo, sha=None):
cmd = ['git', 'describe', '--abbrev=0']
cmd = ['git', 'describe', '--abbrev=0', '--always']
if sha is not None:
cmd.append(sha)
try: