build: Use git describe --always

Add --always flag to "git describe" command to get a build identifier
even if one checks out the repo with a depth parameter that prunes out
the last tagged version.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2018-02-26 21:50:05 -05:00
parent 239c1ad5c9
commit 656cb2c417
2 changed files with 2 additions and 2 deletions

View File

@ -57,7 +57,7 @@ def get_git_version():
if not os.path.exists(gitdir): if not os.path.exists(gitdir):
logging.debug("No '.git' file/directory found") logging.debug("No '.git' file/directory found")
return "?" return "?"
prog = "git -C %s describe --tags --long --dirty" % (gitdir,) prog = "git -C %s describe --always --tags --long --dirty" % (gitdir,)
try: try:
process = subprocess.Popen(shlex.split(prog), stdout=subprocess.PIPE) process = subprocess.Popen(shlex.split(prog), stdout=subprocess.PIPE)
output = process.communicate()[0] output = process.communicate()[0]

View File

@ -244,7 +244,7 @@ def git_version():
if not os.path.exists('.git'): if not os.path.exists('.git'):
logging.debug("No '.git' file/directory found") logging.debug("No '.git' file/directory found")
return "" return ""
ver = check_output("git describe --tags --long --dirty").strip() ver = check_output("git describe --always --tags --long --dirty").strip()
logging.debug("Got git version: %s" % (repr(ver),)) logging.debug("Got git version: %s" % (repr(ver),))
return ver return ver