Skip to content

Commit

Permalink
Fix generating dlt version tag
Browse files Browse the repository at this point in the history
Update git describe to always produce some output. This allows to
ignore git warnings and errors.

Fix problem when git warning about tag get placed in C++ header and
a syntax error breaks build.

Example git output that prodcues compilation errors:
> git describe --tags
warning: tag 'haleytek/v2.18.5' is externally known as 'v2.18.5'
v2.18.5-19-g344c37b
  • Loading branch information
KrzysztofNarlochHaleytek authored and slawomiradamczyk committed Nov 17, 2023
1 parent a4105dd commit 35e9944
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions util/create_dlt_version_h.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,13 @@

def get_cmd(cmd, cwd):
return subprocess.check_output(cmd, cwd=cwd, shell=True,
stderr=subprocess.STDOUT
stderr=subprocess.DEVNULL,
).decode().strip()


def get_revision(git_dir):
try:
rev = get_cmd('git describe --tags', git_dir)
if not rev.startswith("fatal:"):
return rev

rev = get_cmd('git rev-parse HEAD', git_dir)
if not rev.startswith("fatal:"):
return rev
return get_cmd('git describe --tags --always --dirty', git_dir)
except subprocess.CalledProcessError:
pass

Expand Down

0 comments on commit 35e9944

Please sign in to comment.