Skip to content

Commit

Permalink
pio: check returncode of the git process
Browse files Browse the repository at this point in the history
Since the Popen instance won't do that by itself. Handles the case
where there is `git` command present, but it's not a git repo underneath.
  • Loading branch information
mcspr committed Aug 17, 2021
1 parent 459591b commit bdd821d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions code/scripts/espurna_utils/version.py
Expand Up @@ -16,10 +16,11 @@ def app_revision():
def git(*args):
cmd = ["git"]
cmd.extend(args)
proc = subprocess.Popen(
cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE, universal_newlines=True
)
return proc.stdout.readlines()[0].strip()

result = subprocess.run(cmd, capture_output=True, universal_newlines=True)
result.check_returncode()

return result.stdout.strip()

revision = None
try:
Expand Down

0 comments on commit bdd821d

Please sign in to comment.