Bug 1524358 - Get commit message locally, rather than from task parameters. r=tomprince, a=RyanVM
authorDustin J. Mitchell <dustin@mozilla.com>
Fri, 01 Feb 2019 23:27:48 +0000
changeset 509608 b04e2261e4c9f3616e18184e4fa7e25997f5b56e
parent 509607 ad0d9539cc64f1feddf6f9651017b21b78b422fb
child 509609 b3320a1afdc4d7439c8196dff558daa571979aa0
push id1927
push userryanvm@gmail.com
push dateTue, 05 Feb 2019 18:23:21 +0000
treeherdermozilla-release@b04e2261e4c9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstomprince, RyanVM
bugs1524358
milestone65.0.1
Bug 1524358 - Get commit message locally, rather than from task parameters. r=tomprince, a=RyanVM Differential Revision: https://phabricator.services.mozilla.com/D18288
.taskcluster.yml
taskcluster/mach_commands.py
taskcluster/taskgraph/cron/decision.py
taskcluster/taskgraph/decision.py
taskcluster/taskgraph/test/test_decision.py
taskcluster/taskgraph/util/hg.py
--- a/.taskcluster.yml
+++ b/.taskcluster.yml
@@ -8,17 +8,17 @@
 #     now,
 #     as_slugid: // function
 #     ownTaskId: // taskId of the task that will be created
 #   }
 #
 # - 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,
 #     ownTaskId: // taskId of the task that will be created
 #   }
 #
 # - action tasks - See:
 #   * taskcluster/taskgraph/actions/registry.py,
@@ -183,17 +183,16 @@ tasks:
           env:
             # checkout-gecko uses these to check out the source; the inputs
             # to `mach taskgraph decision` are all on the command line.
             $merge:
               - GECKO_BASE_REPOSITORY: 'https://hg.mozilla.org/mozilla-unified'
                 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
               - $if: 'tasks_for == "action"'
                 then:
                   ACTION_TASK_GROUP_ID: '${action.taskGroupId}'     # taskGroupId of the target task
                   ACTION_TASK_ID: {$json: {$eval: 'taskId'}} # taskId of the target task (JSON-encoded)
                   ACTION_INPUT: {$json: {$eval: 'input'}}
                   ACTION_CALLBACK: '${action.cb_name}'
@@ -229,17 +228,16 @@ tasks:
                   ./mach --log-no-times taskgraph action-callback
                 else: >
                   cd /builds/worker/checkouts/gecko &&
                   ln -s /builds/worker/artifacts artifacts &&
                   ./mach --log-no-times taskgraph decision
                   --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"
                   --head-repository="$GECKO_HEAD_REPOSITORY"
                   --head-ref="$GECKO_HEAD_REF"
                   --head-rev="$GECKO_HEAD_REV"
                   ${extraArgs}
 
--- a/taskcluster/mach_commands.py
+++ b/taskcluster/mach_commands.py
@@ -143,19 +143,16 @@ class MachCommands(MachCommandBase):
                      required=False,
                      help='URL for "head" comm-* repository to fetch revision from')
     @CommandArgument('--comm-head-ref',
                      required=False,
                      help='comm-* Reference (this is same as rev usually for hg)')
     @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')
     @CommandArgument('--pushlog-id',
                      dest='pushlog_id',
                      required=True,
                      default=0)
     @CommandArgument('--pushdate',
--- a/taskcluster/taskgraph/cron/decision.py
+++ b/taskcluster/taskgraph/cron/decision.py
@@ -50,17 +50,16 @@ def make_decision_task(params, root, sym
             'level': params['level'],
         },
         'push': {
             'revision': params['head_rev'],
             # remainder are fake values, but the decision task expects them anyway
             'pushlog_id': push_info['pushid'],
             'pushdate': push_info['pushdate'],
             'owner': 'cron',
-            'comment': '',
         },
         'cron': {
             'task_id': os.environ.get('TASK_ID', '<cron task id>'),
             'job_name': params['job_name'],
             'job_symbol': symbol,
             # args are shell-quoted since they are given to `bash -c`
             'quoted_args': ' '.join(pipes.quote(a) for a in arguments),
         },
--- a/taskcluster/taskgraph/decision.py
+++ b/taskcluster/taskgraph/decision.py
@@ -15,17 +15,17 @@ import yaml
 from . import GECKO
 from .actions import render_actions_json
 from .create import create_tasks
 from .generator import TaskGraphGenerator
 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
 
 
 logger = logging.getLogger(__name__)
 
 ARTIFACTS_DIR = 'artifacts'
@@ -196,17 +196,16 @@ def get_decision_parameters(config, opti
     """
     product_dir = config['product-dir']
 
     parameters = {n: options[n] for n in [
         'base_repository',
         'head_repository',
         'head_rev',
         'head_ref',
-        'message',
         'project',
         'pushlog_id',
         'pushdate',
         'owner',
         'level',
         'target_tasks_method',
     ] if n in options}
 
@@ -224,16 +223,17 @@ def get_decision_parameters(config, opti
     parameters['filters'] = [
         'target_tasks_method',
     ]
     parameters['existing_tasks'] = {}
     parameters['do_not_optimize'] = []
     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'] = ''
     parameters['release_eta'] = ''
     parameters['release_enable_partners'] = False
     parameters['release_partners'] = []
     parameters['release_partner_config'] = {}
     parameters['release_partner_build_number'] = 1
--- a/taskcluster/taskgraph/test/test_decision.py
+++ b/taskcluster/taskgraph/test/test_decision.py
@@ -82,18 +82,19 @@ class TestGetDecisionParameters(unittest
     @patch('taskgraph.decision.get_hg_revision_branch')
     def test_no_email_owner(self, _):
         self.options['owner'] = 'ffxbld'
         with MockedOpen({self.ttc_file: None}):
             params = decision.get_decision_parameters(FAKE_GRAPH_CONFIG, self.options)
         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)
         self.assertEqual(params['try_mode'], 'try_option_syntax')
         self.assertEqual(params['try_options']['build_types'], 'do')
         self.assertEqual(params['try_options']['unittests'], 'all')
         self.assertEqual(params['try_task_config'], None)
 
--- a/taskcluster/taskgraph/util/hg.py
+++ b/taskcluster/taskgraph/util/hg.py
@@ -38,13 +38,17 @@ def find_hg_revision_push_info(repositor
 
 
 def get_hg_revision_branch(root, revision):
     """Given the parameters for a revision, find the hg_branch (aka
     relbranch) of the revision."""
     return subprocess.check_output(['hg', 'identify', '--branch', '--rev', 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)