Skip to content

Commit

Permalink
px_mkfw: add git commit hash to .px4 file
Browse files Browse the repository at this point in the history
  • Loading branch information
bkueng authored and dagar committed Aug 14, 2019
1 parent 9e055e9 commit 5cadb0a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Tools/px_mkfw.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def mkdesc():
proto['version'] = ""
proto['summary'] = ""
proto['description'] = ""
proto['git_identity'] = ""
proto['git_identity'] = "" # git tag
proto['git_hash'] = "" # git commit hash
proto['build_time'] = 0
proto['image'] = bytes()
proto['image_size'] = 0
Expand Down Expand Up @@ -98,10 +99,14 @@ def mkdesc():
if args.description != None:
desc['description'] = str(args.description)
if args.git_identity != None:
cmd = " ".join(["git", "--git-dir", args.git_identity + "/.git", "describe", "--always", "--tags"])
cmd = "git --git-dir '{:}/.git' describe --always --tags".format(args.git_identity)
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).stdout
desc['git_identity'] = str(p.read().strip())
p.close()
cmd = "git --git-dir '{:}/.git' rev-parse --verify HEAD".format(args.git_identity)
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).stdout
desc['git_hash'] = str(p.read().strip())
p.close()
if args.parameter_xml != None:
f = open(args.parameter_xml, "rb")
bytes = f.read()
Expand Down

0 comments on commit 5cadb0a

Please sign in to comment.