mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 12:30:03 +00:00
Reland "[build] Don't combine stdout and stderr when consuming git output."
Ignore non-zero exit code during GetGitRevision. Bug: https://github.com/flutter/flutter/issues/123416 Bug: https://github.com/dart-lang/sdk/issues/51865 Change-Id: Ifff7251d478cfd742a60ba6dcdeb60e581279b75 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291300 Reviewed-by: Alexander Aprelev <aam@google.com> Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
parent
98f18ec45a
commit
ec8688d97a
|
@ -500,11 +500,14 @@ def GetGitRevision(git_revision_file=None, repo_path=DART_DIR):
|
||||||
pass
|
pass
|
||||||
p = subprocess.Popen(['git', 'rev-parse', 'HEAD'],
|
p = subprocess.Popen(['git', 'rev-parse', 'HEAD'],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.STDOUT,
|
stderr=subprocess.PIPE,
|
||||||
shell=IsWindows(),
|
shell=IsWindows(),
|
||||||
cwd=repo_path)
|
cwd=repo_path)
|
||||||
output, _ = p.communicate()
|
out, err = p.communicate()
|
||||||
revision = output.decode('utf-8').strip()
|
# TODO(https://github.com/dart-lang/sdk/issues/51865): Don't ignore errors.
|
||||||
|
# if p.wait() != 0:
|
||||||
|
# raise Exception('git rev-parse failed: ' + str(err))
|
||||||
|
revision = out.decode('utf-8').strip()
|
||||||
# We expect a full git hash
|
# We expect a full git hash
|
||||||
if len(revision) != 40:
|
if len(revision) != 40:
|
||||||
print('Warning: Could not parse git commit, output was {}'.format(
|
print('Warning: Could not parse git commit, output was {}'.format(
|
||||||
|
@ -517,13 +520,15 @@ def GetGitRevision(git_revision_file=None, repo_path=DART_DIR):
|
||||||
def GetShortGitHash(repo_path=DART_DIR):
|
def GetShortGitHash(repo_path=DART_DIR):
|
||||||
p = subprocess.Popen(['git', 'rev-parse', '--short=10', 'HEAD'],
|
p = subprocess.Popen(['git', 'rev-parse', '--short=10', 'HEAD'],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.STDOUT,
|
stderr=subprocess.PIPE,
|
||||||
shell=IsWindows(),
|
shell=IsWindows(),
|
||||||
cwd=repo_path)
|
cwd=repo_path)
|
||||||
output, _ = p.communicate()
|
out, err = p.communicate()
|
||||||
revision = output.decode('utf-8').strip()
|
|
||||||
if p.wait() != 0:
|
if p.wait() != 0:
|
||||||
|
# TODO(https://github.com/dart-lang/sdk/issues/51865): Don't ignore errors.
|
||||||
|
# raise Exception('git rev-parse failed: ' + str(err))
|
||||||
return None
|
return None
|
||||||
|
revision = out.decode('utf-8').strip()
|
||||||
return revision
|
return revision
|
||||||
|
|
||||||
|
|
||||||
|
@ -540,16 +545,16 @@ def GetLatestDevTag(repo_path=DART_DIR):
|
||||||
]
|
]
|
||||||
p = subprocess.Popen(cmd,
|
p = subprocess.Popen(cmd,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.STDOUT,
|
stderr=subprocess.PIPE,
|
||||||
shell=IsWindows(),
|
shell=IsWindows(),
|
||||||
cwd=repo_path)
|
cwd=repo_path)
|
||||||
output, _ = p.communicate()
|
out, err = p.communicate()
|
||||||
tag = output.decode('utf-8').strip()
|
|
||||||
if p.wait() != 0:
|
if p.wait() != 0:
|
||||||
print('Warning: Could not get the most recent dev branch tag {}'.format(
|
print('Warning: Could not get the most recent dev branch tag {}'.format(
|
||||||
tag),
|
tag),
|
||||||
file=sys.stderr)
|
file=sys.stderr)
|
||||||
return None
|
return None
|
||||||
|
tag = out.decode('utf-8').strip()
|
||||||
return tag
|
return tag
|
||||||
|
|
||||||
|
|
||||||
|
@ -564,24 +569,29 @@ def GetGitTimestamp(git_timestamp_file=None, repo_path=DART_DIR):
|
||||||
pass
|
pass
|
||||||
p = subprocess.Popen(['git', 'log', '-n', '1', '--pretty=format:%cd'],
|
p = subprocess.Popen(['git', 'log', '-n', '1', '--pretty=format:%cd'],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.STDOUT,
|
stderr=subprocess.PIPE,
|
||||||
shell=IsWindows(),
|
shell=IsWindows(),
|
||||||
cwd=repo_path)
|
cwd=repo_path)
|
||||||
output, _ = p.communicate()
|
out, err = p.communicate()
|
||||||
timestamp = output.decode('utf-8').strip()
|
|
||||||
if p.wait() != 0:
|
if p.wait() != 0:
|
||||||
|
# TODO(https://github.com/dart-lang/sdk/issues/51865): Don't ignore errors.
|
||||||
|
# raise Exception('git log failed: ' + str(err))
|
||||||
return None
|
return None
|
||||||
|
timestamp = out.decode('utf-8').strip()
|
||||||
return timestamp
|
return timestamp
|
||||||
|
|
||||||
|
|
||||||
def GetGitNumber(repo_path=DART_DIR):
|
def GetGitNumber(repo_path=DART_DIR):
|
||||||
p = subprocess.Popen(['git', 'rev-list', 'HEAD', '--count'],
|
p = subprocess.Popen(['git', 'rev-list', 'HEAD', '--count'],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.STDOUT,
|
stderr=subprocess.PIPE,
|
||||||
shell=IsWindows(),
|
shell=IsWindows(),
|
||||||
cwd=repo_path)
|
cwd=repo_path)
|
||||||
output, _ = p.communicate()
|
out, err = p.communicate()
|
||||||
number = output.decode('utf-8').strip()
|
# TODO(https://github.com/dart-lang/sdk/issues/51865): Don't ignore errors.
|
||||||
|
# if p.wait() != 0:
|
||||||
|
# raise Exception('git rev-list failed: ' + str(err))
|
||||||
|
number = out.decode('utf-8').strip()
|
||||||
try:
|
try:
|
||||||
number = int(number)
|
number = int(number)
|
||||||
return number + GIT_NUMBER_BASE
|
return number + GIT_NUMBER_BASE
|
||||||
|
|
Loading…
Reference in a new issue