From 8c5f40229cddb8e79fbcef7ea4bed2e4100be079 Mon Sep 17 00:00:00 2001 From: Tom Prince Date: Wed, 15 May 2019 18:04:47 +0000 Subject: [PATCH] Bug 1551738: Add a helper to extract the task name from the final task; r=Callek Differential Revision: https://phabricator.services.mozilla.com/D31160 --HG-- extra : moz-landing-system : lando --- taskcluster/taskgraph/task.py | 9 +++++++++ taskcluster/taskgraph/transforms/l10n.py | 3 +-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/taskcluster/taskgraph/task.py b/taskcluster/taskgraph/task.py index 74c12c16dc0e..3bdd81667d5f 100644 --- a/taskcluster/taskgraph/task.py +++ b/taskcluster/taskgraph/task.py @@ -46,6 +46,15 @@ class Task(object): def __attrs_post_init__(self): self.attributes['kind'] = self.kind + @property + def name(self): + if self.label.startswith(self.kind + "-"): + return self.label[len(self.kind)+1:] + elif self.label.startswith("build-docker-image-"): + return self.label[len("build-docker-image-"):] + else: + raise AttributeError("Task {} does not have a name.".format(self.label)) + def to_json(self): rv = { 'kind': self.kind, diff --git a/taskcluster/taskgraph/transforms/l10n.py b/taskcluster/taskgraph/transforms/l10n.py index 8c1391c846a2..a7d0bbda5bf9 100644 --- a/taskcluster/taskgraph/transforms/l10n.py +++ b/taskcluster/taskgraph/transforms/l10n.py @@ -187,8 +187,7 @@ def setup_name(config, jobs): dep = job['primary-dependency'] # Set the name to the same as the dep task, without kind name. # Label will get set automatically with this kinds name. - job['name'] = job.get('name', - dep.task['metadata']['name'][len(dep.kind) + 1:]) + job['name'] = job.get('name', dep.name) yield job