From c8fe0990f82154b8601442f5bbf18343178f338a Mon Sep 17 00:00:00 2001 From: "Dustin J. Mitchell" Date: Fri, 1 Feb 2019 23:27:48 +0000 Subject: [PATCH] Bug 1524358 - get commit message locally, rather than from task parameters r=tomprince Differential Revision: https://phabricator.services.mozilla.com/D18288 --HG-- extra : moz-landing-system : lando --- .taskcluster.yml | 4 +--- taskcluster/mach_commands.py | 3 --- taskcluster/taskgraph/cron/decision.py | 1 - taskcluster/taskgraph/decision.py | 4 ++-- taskcluster/taskgraph/test/test_decision.py | 5 +++-- taskcluster/taskgraph/util/hg.py | 10 +++++++--- 6 files changed, 13 insertions(+), 14 deletions(-) diff --git a/.taskcluster.yml b/.taskcluster.yml index f7144f4c38db..8a8ec0dfc50a 100644 --- a/.taskcluster.yml +++ b/.taskcluster.yml @@ -13,7 +13,7 @@ # - cron tasks - See taskcluster/taskgraph/cron/decision.py # { # tasks_for: 'cron', -# push: {revision, pushlog_id, pushdate, owner, comment} +# push: {revision, pushlog_id, pushdate, owner} # repository: {url, project, level}, # cron: {task_id, job_name, job_symbol, quoted_args}, # now, @@ -191,7 +191,6 @@ tasks: GECKO_HEAD_REPOSITORY: '${repoUrl}' GECKO_HEAD_REF: '${push.revision}' GECKO_HEAD_REV: '${push.revision}' - GECKO_COMMIT_MSG: {$if: 'tasks_for != "action"', then: '${push.comment}'} HG_STORE_PATH: /builds/worker/checkouts/hg-store TASKCLUSTER_CACHES: /builds/worker/checkouts # someday, these will be provided by the worker - Bug 1492664 @@ -240,7 +239,6 @@ tasks: --pushlog-id='${push.pushlog_id}' --pushdate='${push.pushdate}' --project='${repository.project}' - --message="$GECKO_COMMIT_MSG" --owner='${ownerEmail}' --level='${repository.level}' --base-repository="$GECKO_BASE_REPOSITORY" diff --git a/taskcluster/mach_commands.py b/taskcluster/mach_commands.py index ffac5c14e0b1..b6612b1c9ba7 100644 --- a/taskcluster/mach_commands.py +++ b/taskcluster/mach_commands.py @@ -149,9 +149,6 @@ class MachCommands(MachCommandBase): @CommandArgument('--comm-head-rev', required=False, help='Commit revision to use from head comm-* repository') - @CommandArgument('--message', - required=True, - help='Commit message to be parsed. Example: "try: -b do -p all -u all"') @CommandArgument('--project', required=True, help='Project to use for creating task graph. Example: --project=try') diff --git a/taskcluster/taskgraph/cron/decision.py b/taskcluster/taskgraph/cron/decision.py index b57e17e31bd1..e0a0304c8eb3 100644 --- a/taskcluster/taskgraph/cron/decision.py +++ b/taskcluster/taskgraph/cron/decision.py @@ -59,7 +59,6 @@ def make_decision_task(params, root, symbol, arguments=[]): 'pushlog_id': push_info['pushid'], 'pushdate': push_info['pushdate'], 'owner': 'cron', - 'comment': '', }, 'cron': { 'task_id': os.environ.get('TASK_ID', ''), diff --git a/taskcluster/taskgraph/decision.py b/taskcluster/taskgraph/decision.py index 579f4b2366e7..a5e83480ad96 100644 --- a/taskcluster/taskgraph/decision.py +++ b/taskcluster/taskgraph/decision.py @@ -20,7 +20,7 @@ from .parameters import Parameters, get_version, get_app_version from .taskgraph import TaskGraph from .try_option_syntax import parse_message from .util.schema import validate_schema, Schema -from taskgraph.util.hg import get_hg_revision_branch +from taskgraph.util.hg import get_hg_revision_branch, get_hg_commit_message from taskgraph.util.partials import populate_release_history from taskgraph.util.yaml import load_yaml from voluptuous import Required, Optional @@ -193,7 +193,6 @@ def get_decision_parameters(config, options): 'head_repository', 'head_rev', 'head_ref', - 'message', 'project', 'pushlog_id', 'pushdate', @@ -222,6 +221,7 @@ def get_decision_parameters(config, options): parameters['build_number'] = 1 parameters['version'] = get_version(product_dir) parameters['app_version'] = get_app_version(product_dir) + parameters['message'] = get_hg_commit_message(GECKO) parameters['hg_branch'] = get_hg_revision_branch(GECKO, revision=parameters['head_rev']) parameters['next_version'] = None parameters['release_type'] = '' diff --git a/taskcluster/taskgraph/test/test_decision.py b/taskcluster/taskgraph/test/test_decision.py index ca6a6c40272b..85168e75152f 100644 --- a/taskcluster/taskgraph/test/test_decision.py +++ b/taskcluster/taskgraph/test/test_decision.py @@ -87,8 +87,9 @@ class TestGetDecisionParameters(unittest.TestCase): self.assertEqual(params['owner'], 'ffxbld@noreply.mozilla.org') @patch('taskgraph.decision.get_hg_revision_branch') - def test_try_options(self, _): - self.options['message'] = 'try: -b do -t all' + @patch('taskgraph.decision.get_hg_commit_message') + def test_try_options(self, mock_get_hg_commit_message, _): + mock_get_hg_commit_message.return_value = 'try: -b do -t all' self.options['project'] = 'try' with MockedOpen({self.ttc_file: None}): params = decision.get_decision_parameters(FAKE_GRAPH_CONFIG, self.options) diff --git a/taskcluster/taskgraph/util/hg.py b/taskcluster/taskgraph/util/hg.py index 6100a8e6cd8a..737eeec77ee4 100644 --- a/taskcluster/taskgraph/util/hg.py +++ b/taskcluster/taskgraph/util/hg.py @@ -47,8 +47,12 @@ def get_hg_revision_branch(root, revision): ], cwd=root) +# For these functions, we assume that run-task has correctly checked out the +# revision indicated by GECKO_HEAD_REF, so all that remains is to see what the +# current revision is. Mercurial refers to that as `.`. +def get_hg_commit_message(root): + return subprocess.check_output(['hg', 'log', '-r', '.', '-T', '{desc}'], cwd=root) + + def calculate_head_rev(root): - # we assume that run-task has correctly checked out the revision indicated by - # GECKO_HEAD_REF, so all that remains is to see what the current revision is. - # Mercurial refers to that as `.`. return subprocess.check_output(['hg', 'log', '-r', '.', '-T', '{node}'], cwd=root)