Bug 1702766 - Add settings to mach try again --list-tasks output r=ahal

Differential Revision: https://phabricator.services.mozilla.com/D110678
This commit is contained in:
Steve Fink 2021-04-06 14:44:35 +00:00
parent ba77e5e136
commit ffb8698cf3

View File

@ -74,8 +74,10 @@ def run(
for i, data in enumerate(history):
msg, config = json.loads(data)
version = config.get("version", "1")
settings = {}
if version == 1:
tasks = config["tasks"]
settings = config
elif version == 2:
try_config = config.get("parameters", {}).get("try_task_config", {})
tasks = try_config.get("tasks")
@ -83,13 +85,25 @@ def run(
tasks = None
if tasks is not None:
n = len(tasks)
# Select only the things that are of interest to display.
settings = settings.copy()
env = settings.pop("env", {}).copy()
env.pop("TRY_SELECTOR", None)
for name in ("tasks", "version"):
settings.pop(name, None)
print(
"{index}. ({n} task{s}) {msg}".format(
index=i, msg=msg, n=n, s="" if n == 1 else "s"
def pluralize(n, noun):
return "{n} {noun}{s}".format(
n=n, noun=noun, s="" if n == 1 else "s"
)
)
out = str(i) + ". (" + pluralize(len(tasks), "task")
if env:
out += ", " + pluralize(len(env), "env var")
if settings:
out += ", " + pluralize(len(settings), "setting")
out += ") " + msg
print(out)
if list_tasks > 0:
indent = " " * 4
@ -102,6 +116,16 @@ def run(
num_hidden_tasks = len(tasks) - len(shown_tasks)
if num_hidden_tasks > 0:
print("{}... and {} more".format(indent, num_hidden_tasks))
if list_tasks and env:
for line in ("env: " + json.dumps(env, indent=2)).splitlines():
print(" " + line)
if list_tasks and settings:
for line in (
"settings: " + json.dumps(settings, indent=2)
).splitlines():
print(" " + line)
else:
print(
"{index}. {msg}".format(