mirror of
https://gerrit.googlesource.com/git-repo
synced 2025-01-02 16:14:25 +00:00
git_command: use subprocess.run for version info
The code is a bit simpler & easier to reason about. Change-Id: If125ea7d776cdfa38a0440a2b03583de079c4839 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/297023 Reviewed-by: Michael Mortensen <mmortensen@google.com> Tested-by: Mike Frysinger <vapier@google.com>
This commit is contained in:
parent
fb21d6ab64
commit
f307916f22
@ -162,11 +162,10 @@ def RepoSourceVersion():
|
|||||||
|
|
||||||
proj = os.path.dirname(os.path.abspath(__file__))
|
proj = os.path.dirname(os.path.abspath(__file__))
|
||||||
env[GIT_DIR] = os.path.join(proj, '.git')
|
env[GIT_DIR] = os.path.join(proj, '.git')
|
||||||
|
result = subprocess.run([GIT, 'describe', HEAD], stdout=subprocess.PIPE,
|
||||||
p = subprocess.Popen([GIT, 'describe', HEAD], stdout=subprocess.PIPE,
|
encoding='utf-8', env=env, check=False)
|
||||||
env=env)
|
if result.returncode == 0:
|
||||||
if p.wait() == 0:
|
ver = result.stdout.strip()
|
||||||
ver = p.stdout.read().strip().decode('utf-8')
|
|
||||||
if ver.startswith('v'):
|
if ver.startswith('v'):
|
||||||
ver = ver[1:]
|
ver = ver[1:]
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user