Fix version.py in case of no branch

pull/1020/head
Willem Melching 5 years ago
parent b552a627e1
commit 1de0b9c233
  1. 16
      selfdrive/version.py

@ -50,16 +50,16 @@ origin = get_git_remote()
branch = get_git_full_branchname() branch = get_git_full_branchname()
try: try:
is_comma_remote = origin.startswith('git@github.com:commaai') or origin.startswith('https://github.com/commaai') # This is needed otherwise touched files might show up as modified
if is_comma_remote and branch is not None: subprocess.check_call(["git", "update-index", "--refresh"])
# This is needed otherwise touched files might show up as modified
try:
subprocess.check_call(["git", "update-index", "--refresh"])
except subprocess.CalledProcessError:
pass
dirty = 'master' in branch if (origin is not None) and (branch is not None):
comma_remote = origin.startswith('git@github.com:commaai') or origin.startswith('https://github.com/commaai')
dirty = not comma_remote
dirty = dirty or ('master' in branch)
dirty = dirty or (subprocess.call(["git", "diff-index", "--quiet", branch, "--"]) != 0) dirty = dirty or (subprocess.call(["git", "diff-index", "--quiet", branch, "--"]) != 0)
if dirty: if dirty:
dirty_files = subprocess.check_output(["git", "diff-index", branch, "--"], encoding='utf8') dirty_files = subprocess.check_output(["git", "diff-index", branch, "--"], encoding='utf8')
commit = subprocess.check_output(["git", "rev-parse", "--verify", "HEAD"], encoding='utf8').rstrip() commit = subprocess.check_output(["git", "rev-parse", "--verify", "HEAD"], encoding='utf8').rstrip()

Loading…
Cancel
Save