зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1400469 - Add ability to specify commit message to |mach try|, r=armenzg
MozReview-Commit-ID: LWkAEDWn8NC --HG-- extra : rebase_source : 24fd977d23f9f09859aa9f9a44c53ffd6c1f4673
This commit is contained in:
Родитель
597114a565
Коммит
5e9a048a4b
|
@ -4,6 +4,9 @@
|
|||
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import tempfile
|
||||
from argparse import ArgumentParser
|
||||
|
||||
from .templates import all_templates
|
||||
|
@ -12,6 +15,13 @@ from .templates import all_templates
|
|||
class BaseTryParser(ArgumentParser):
|
||||
name = 'try'
|
||||
common_arguments = [
|
||||
[['-m', '--message'],
|
||||
{'const': 'editor',
|
||||
'default': '{msg}',
|
||||
'nargs': '?',
|
||||
'help': 'Use the specified commit message, or create it in your '
|
||||
'$EDITOR if blank. Defaults to computed message.',
|
||||
}],
|
||||
[['--no-push'],
|
||||
{'dest': 'push',
|
||||
'action': 'store_false',
|
||||
|
@ -52,8 +62,21 @@ class BaseTryParser(ArgumentParser):
|
|||
for template in self.templates.values():
|
||||
template.add_arguments(group)
|
||||
|
||||
def validate(self, args):
|
||||
if args.message == 'editor':
|
||||
if 'EDITOR' not in os.environ:
|
||||
self.error("must set the $EDITOR environment variable to use blank --message")
|
||||
|
||||
with tempfile.NamedTemporaryFile(mode='r') as fh:
|
||||
subprocess.call([os.environ['EDITOR'], fh.name])
|
||||
args.message = fh.read().strip()
|
||||
|
||||
if '{msg}' not in args.message:
|
||||
args.message = '{}\n\n{}'.format(args.message, '{msg}')
|
||||
|
||||
def parse_known_args(self, *args, **kwargs):
|
||||
args, remainder = ArgumentParser.parse_known_args(self, *args, **kwargs)
|
||||
self.validate(args)
|
||||
|
||||
if self.templates:
|
||||
args.templates = {}
|
||||
|
|
|
@ -198,7 +198,8 @@ def format_header():
|
|||
|
||||
|
||||
def run_fuzzy_try(update=False, query=None, templates=None, full=False, parameters=None,
|
||||
save=False, preset=None, list_presets=False, push=True, **kwargs):
|
||||
save=False, preset=None, list_presets=False, push=True, message='{msg}',
|
||||
**kwargs):
|
||||
if list_presets:
|
||||
return pset.list_presets(section='fuzzy')
|
||||
|
||||
|
@ -248,4 +249,4 @@ def run_fuzzy_try(update=False, query=None, templates=None, full=False, paramete
|
|||
|
||||
query = " with query: {}".format(query) if query else ""
|
||||
msg = "Fuzzy{}".format(query)
|
||||
return vcs.push_to_try('fuzzy', msg, selected, templates, push=push)
|
||||
return vcs.push_to_try('fuzzy', message.format(msg=msg), selected, templates, push=push)
|
||||
|
|
|
@ -638,7 +638,7 @@ class AutoTry(object):
|
|||
if kwargs["verbose"]:
|
||||
print('The following try syntax was calculated:\n%s' % msg)
|
||||
|
||||
self.vcs.push_to_try('syntax', msg, push=kwargs['push'])
|
||||
self.vcs.push_to_try('syntax', kwargs["message"].format(msg=msg), push=kwargs['push'])
|
||||
|
||||
if kwargs["save"]:
|
||||
assert msg.startswith("try: ")
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
[test_fuzzy.t]
|
||||
[test_message.t]
|
||||
[test_preset.t]
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
export topsrcdir=$TESTDIR/../../../
|
||||
export MOZBUILD_STATE_PATH=$TMP/mozbuild
|
||||
|
||||
export MACHRC=$TMP/machrc
|
||||
cat > $MACHRC << EOF
|
||||
[try]
|
||||
default=syntax
|
||||
EOF
|
||||
|
||||
cachedir=$MOZBUILD_STATE_PATH/cache/taskgraph
|
||||
mkdir -p $cachedir
|
||||
|
||||
|
|
|
@ -4,7 +4,11 @@
|
|||
Test fuzzy selector
|
||||
|
||||
$ ./mach try fuzzy $testargs -q "'foo"
|
||||
Calculated try selector:
|
||||
Commit message:
|
||||
Fuzzy with query: 'foo
|
||||
|
||||
Pushed via `mach try fuzzy`
|
||||
Calculated try_task_config.json:
|
||||
{
|
||||
"tasks":[
|
||||
"test/foo-debug",
|
||||
|
@ -12,14 +16,14 @@ Test fuzzy selector
|
|||
]
|
||||
}
|
||||
|
||||
Commit message:
|
||||
Fuzzy with query: 'foo
|
||||
|
||||
Pushed via `mach try fuzzy`
|
||||
$ ./mach try fuzzy $testargs -q "'bar"
|
||||
no tasks selected
|
||||
$ ./mach try fuzzy $testargs --full -q "'bar"
|
||||
Calculated try selector:
|
||||
Commit message:
|
||||
Fuzzy with query: 'bar
|
||||
|
||||
Pushed via `mach try fuzzy`
|
||||
Calculated try_task_config.json:
|
||||
{
|
||||
"tasks":[
|
||||
"test/bar-debug",
|
||||
|
@ -27,15 +31,15 @@ Test fuzzy selector
|
|||
]
|
||||
}
|
||||
|
||||
Commit message:
|
||||
Fuzzy with query: 'bar
|
||||
|
||||
Pushed via `mach try fuzzy`
|
||||
|
||||
Test templates
|
||||
|
||||
$ ./mach try fuzzy --no-push --artifact -q "'foo"
|
||||
Calculated try selector:
|
||||
Commit message:
|
||||
Fuzzy with query: 'foo
|
||||
|
||||
Pushed via `mach try fuzzy`
|
||||
Calculated try_task_config.json:
|
||||
{
|
||||
"templates":{
|
||||
"artifact":{
|
||||
|
@ -48,12 +52,12 @@ Test templates
|
|||
]
|
||||
}
|
||||
|
||||
$ ./mach try fuzzy $testargs --env FOO=1 --env BAR=baz -q "'foo"
|
||||
Commit message:
|
||||
Fuzzy with query: 'foo
|
||||
|
||||
Pushed via `mach try fuzzy`
|
||||
$ ./mach try fuzzy $testargs --env FOO=1 --env BAR=baz -q "'foo"
|
||||
Calculated try selector:
|
||||
Calculated try_task_config.json:
|
||||
{
|
||||
"templates":{
|
||||
"env":{
|
||||
|
@ -67,7 +71,3 @@ Test templates
|
|||
]
|
||||
}
|
||||
|
||||
Commit message:
|
||||
Fuzzy with query: 'foo
|
||||
|
||||
Pushed via `mach try fuzzy`
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
$ . $TESTDIR/setup.sh
|
||||
$ cd $topsrcdir
|
||||
|
||||
Test custom commit messages with fuzzy selector
|
||||
|
||||
$ ./mach try fuzzy $testargs -q foo --message "Foobar"
|
||||
Commit message:
|
||||
Foobar
|
||||
|
||||
Fuzzy with query: foo
|
||||
|
||||
Pushed via `mach try fuzzy`
|
||||
Calculated try_task_config.json:
|
||||
{
|
||||
"tasks":[
|
||||
"test/foo-debug",
|
||||
"test/foo-opt"
|
||||
]
|
||||
}
|
||||
|
||||
$ ./mach try fuzzy $testargs -q foo -m "Foobar: {msg}"
|
||||
Commit message:
|
||||
Foobar: Fuzzy with query: foo
|
||||
|
||||
Pushed via `mach try fuzzy`
|
||||
Calculated try_task_config.json:
|
||||
{
|
||||
"tasks":[
|
||||
"test/foo-debug",
|
||||
"test/foo-opt"
|
||||
]
|
||||
}
|
||||
|
||||
$ unset EDITOR
|
||||
$ ./mach try fuzzy $testargs -q foo -m > /dev/null 2>&1
|
||||
[2]
|
||||
|
||||
|
||||
Test custom commit messages with syntax selector
|
||||
|
||||
$ ./mach try syntax $testargs -p linux -u mochitests --message "Foobar"
|
||||
Commit message:
|
||||
Foobar
|
||||
|
||||
try: -b do -p linux -u mochitests
|
||||
|
||||
Pushed via `mach try syntax`
|
||||
$ ./mach try syntax $testargs -p linux -u mochitests -m "Foobar: {msg}"
|
||||
Commit message:
|
||||
Foobar: try: -b do -p linux -u mochitests
|
||||
|
||||
Pushed via `mach try syntax`
|
||||
$ unset EDITOR
|
||||
$ ./mach try syntax $testargs -p linux -u mochitests -m > /dev/null 2>&1
|
||||
[2]
|
|
@ -4,23 +4,17 @@
|
|||
Test preset with no subcommand
|
||||
|
||||
$ ./mach try $testargs --save foo -b do -p linux -u mochitests -t none --tag foo
|
||||
Calculated try selector:
|
||||
try: -b do -p linux -u mochitests -t none --tag foo
|
||||
Commit message:
|
||||
try: -b do -p linux -u mochitests -t none --tag foo
|
||||
|
||||
Pushed via `mach try syntax`
|
||||
preset saved, run with: --preset=foo
|
||||
$ ./mach try $testargs --preset foo
|
||||
Calculated try selector:
|
||||
try: -b do -p linux -u mochitests -t none --tag foo
|
||||
Commit message:
|
||||
try: -b do -p linux -u mochitests -t none --tag foo
|
||||
|
||||
Pushed via `mach try syntax`
|
||||
$ ./mach try syntax $testargs --preset foo
|
||||
Calculated try selector:
|
||||
try: -b do -p linux -u mochitests -t none --tag foo
|
||||
Commit message:
|
||||
try: -b do -p linux -u mochitests -t none --tag foo
|
||||
|
||||
|
@ -31,23 +25,17 @@ Test preset with no subcommand
|
|||
Test preset with syntax subcommand
|
||||
|
||||
$ ./mach try syntax $testargs --save bar -b do -p win32 -u none -t all --tag bar
|
||||
Calculated try selector:
|
||||
try: -b do -p win32 -u none -t all --tag bar
|
||||
Commit message:
|
||||
try: -b do -p win32 -u none -t all --tag bar
|
||||
|
||||
Pushed via `mach try syntax`
|
||||
preset saved, run with: --preset=bar
|
||||
$ ./mach try syntax $testargs --preset bar
|
||||
Calculated try selector:
|
||||
try: -b do -p win32 -u none -t all --tag bar
|
||||
Commit message:
|
||||
try: -b do -p win32 -u none -t all --tag bar
|
||||
|
||||
Pushed via `mach try syntax`
|
||||
$ ./mach try $testargs --preset bar
|
||||
Calculated try selector:
|
||||
try: -b do -p win32 -u none -t all --tag bar
|
||||
Commit message:
|
||||
try: -b do -p win32 -u none -t all --tag bar
|
||||
|
||||
|
@ -60,40 +48,40 @@ Test preset with fuzzy subcommand
|
|||
|
||||
$ ./mach try fuzzy $testargs --save baz -q "'baz"
|
||||
preset saved, run with: --preset=baz
|
||||
Calculated try selector:
|
||||
Commit message:
|
||||
Fuzzy with query: 'baz
|
||||
|
||||
Pushed via `mach try fuzzy`
|
||||
Calculated try_task_config.json:
|
||||
{
|
||||
"tasks":[
|
||||
"build-baz"
|
||||
]
|
||||
}
|
||||
|
||||
Commit message:
|
||||
Fuzzy with query: 'baz
|
||||
|
||||
Pushed via `mach try fuzzy`
|
||||
$ ./mach try fuzzy $testargs --preset baz
|
||||
Calculated try selector:
|
||||
Commit message:
|
||||
Fuzzy with query: 'baz
|
||||
|
||||
Pushed via `mach try fuzzy`
|
||||
Calculated try_task_config.json:
|
||||
{
|
||||
"tasks":[
|
||||
"build-baz"
|
||||
]
|
||||
}
|
||||
|
||||
Commit message:
|
||||
Fuzzy with query: 'baz
|
||||
|
||||
Pushed via `mach try fuzzy`
|
||||
$ ./mach try $testargs --preset baz
|
||||
Calculated try selector:
|
||||
Commit message:
|
||||
Fuzzy with query: 'baz
|
||||
|
||||
Pushed via `mach try fuzzy`
|
||||
Calculated try_task_config.json:
|
||||
{
|
||||
"tasks":[
|
||||
"build-baz"
|
||||
]
|
||||
}
|
||||
|
||||
Commit message:
|
||||
Fuzzy with query: 'baz
|
||||
|
||||
Pushed via `mach try fuzzy`
|
||||
$ ./mach try fuzzy $testargs --list-presets
|
||||
baz: 'baz
|
||||
|
|
|
@ -108,15 +108,12 @@ class VCSHelper(object):
|
|||
|
||||
try:
|
||||
if not push:
|
||||
print("Calculated try selector:")
|
||||
print("Commit message:")
|
||||
print(commit_message)
|
||||
if config:
|
||||
print("Calculated try_task_config.json:")
|
||||
with open(config) as fh:
|
||||
print(fh.read())
|
||||
else:
|
||||
print(msg)
|
||||
|
||||
print('Commit message:')
|
||||
print(commit_message)
|
||||
return
|
||||
|
||||
self._push_to_try(commit_message, config)
|
||||
|
|
Загрузка…
Ссылка в новой задаче