Commit 045a2b88 authored by Clemens Backes's avatar Clemens Backes Committed by V8 LUCI CQ

[tools] Flush stdout before reading input

The last line of output (which is not terminated by a newline) was not
showing for me when running the merge script. We can either fix it by
specifying `flush=True` at the `print` statement, or flushing before
reading user input. The latter seems more future-proof.

R=machenbach@chromium.org

Change-Id: I61cb929d2f7cdd20b3e32b9beb1653fe2d5c5791
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3676857Reviewed-by: 's avatarMichael Achenbach <machenbach@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80890}
parent a9ca9f7d
......@@ -114,15 +114,15 @@ def Command(cmd, args="", prefix="", pipe=True, cwd=None):
def SanitizeVersionTag(tag):
version_without_prefix = re.compile(r"^\d+\.\d+\.\d+(?:\.\d+)?$")
version_with_prefix = re.compile(r"^tags\/\d+\.\d+\.\d+(?:\.\d+)?$")
if version_without_prefix.match(tag):
return tag
elif version_with_prefix.match(tag):
return tag[len("tags/"):]
else:
return None
version_without_prefix = re.compile(r"^\d+\.\d+\.\d+(?:\.\d+)?$")
version_with_prefix = re.compile(r"^tags\/\d+\.\d+\.\d+(?:\.\d+)?$")
if version_without_prefix.match(tag):
return tag
elif version_with_prefix.match(tag):
return tag[len("tags/"):]
else:
return None
def NormalizeVersionTags(version_tags):
......@@ -146,6 +146,7 @@ class SideEffectHandler(object): # pragma: no cover
return Command(cmd, args, prefix, pipe, cwd=cwd)
def ReadLine(self):
sys.stdout.flush()
return sys.stdin.readline().strip()
def ReadURL(self, url, params=None):
......@@ -238,7 +239,7 @@ class GitInterface(VCInterface):
self.step.Git("fetch")
def GetTags(self):
return self.step.Git("tag").strip().splitlines()
return self.step.Git("tag").strip().splitlines()
def GetBranches(self):
# Get relevant remote branches, e.g. "branch-heads/3.25".
......@@ -684,18 +685,22 @@ class UploadStep(Step):
def MakeStep(step_class=Step, number=0, state=None, config=None,
options=None, side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER):
# Allow to pass in empty dictionaries.
state = state if state is not None else {}
config = config if config is not None else {}
try:
message = step_class.MESSAGE
except AttributeError:
message = step_class.__name__
# Allow to pass in empty dictionaries.
state = state if state is not None else {}
config = config if config is not None else {}
return step_class(message, number=number, config=config,
state=state, options=options,
handler=side_effect_handler)
try:
message = step_class.MESSAGE
except AttributeError:
message = step_class.__name__
return step_class(
message,
number=number,
config=config,
state=state,
options=options,
handler=side_effect_handler)
class ScriptsBase(object):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment