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__))
|
||||
env[GIT_DIR] = os.path.join(proj, '.git')
|
||||
|
||||
p = subprocess.Popen([GIT, 'describe', HEAD], stdout=subprocess.PIPE,
|
||||
env=env)
|
||||
if p.wait() == 0:
|
||||
ver = p.stdout.read().strip().decode('utf-8')
|
||||
result = subprocess.run([GIT, 'describe', HEAD], stdout=subprocess.PIPE,
|
||||
encoding='utf-8', env=env, check=False)
|
||||
if result.returncode == 0:
|
||||
ver = result.stdout.strip()
|
||||
if ver.startswith('v'):
|
||||
ver = ver[1:]
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user