From: Frederic Massart Date: Mon, 10 Mar 2014 12:38:08 +0000 (+0800) Subject: Backport command can upload patches to tracker X-Git-Tag: v1.0~17 X-Git-Url: https://git.cameron1729.xyz/?a=commitdiff_plain;h=841adc8a6896aeccfd8b82b74cca29f42dd8af94;p=mdk.git Backport command can upload patches to tracker --- diff --git a/lib/commands/backport.py b/lib/commands/backport.py index 648a0c7..136ee95 100644 --- a/lib/commands/backport.py +++ b/lib/commands/backport.py @@ -23,7 +23,7 @@ http://github.com/FMCorz/mdk """ import logging -from lib import tools, css +from lib import tools, css, jira from lib.command import Command from lib.tools import yesOrNo @@ -73,6 +73,14 @@ class BackportCommand(Command): } ), ( + ['--patch'], + { + 'action': 'store_true', + 'dest': 'patch', + 'help': 'instead of pushing to a remote, this will upload a patch file to the tracker. Security issues use this by default if --push is set. This option discards most other flags.', + } + ), + ( ['-t', '--update-tracker'], { 'const': True, @@ -126,6 +134,14 @@ class BackportCommand(Command): suffix = parsedbranch['suffix'] version = parsedbranch['version'] + if args.push and not args.patch: + mdlIssue = 'MDL-%s' % (issue) + J = jira.Jira() + args.patch = J.isSecurityIssue(mdlIssue) + args.push = False + if args.patch: + logging.info('%s appears to be a security issue, switching to patch mode...' % (mdlIssue)) + # Original track originaltrack = tools.stableBranch(version) @@ -244,6 +260,10 @@ class BackportCommand(Command): ref = None if args.updatetracker == True else args.updatetracker M2.updateTrackerGitInfo(branch=newbranch, ref=ref) + elif args.patch: + if not M2.pushPatch(newbranch): + continue + stashPop(stash) logging.info('Instance %s successfully patched!' % name) diff --git a/lib/commands/push.py b/lib/commands/push.py index d114456..6728ab7 100644 --- a/lib/commands/push.py +++ b/lib/commands/push.py @@ -152,7 +152,7 @@ class PushCommand(Command): mdlIssue = 'MDL-%s' % (parsedbranch['issue']) args.patch = J.isSecurityIssue(mdlIssue) if args.patch: - logging.info('%s appears to be a security issue, attempting to upload a patch...' % (mdlIssue)) + logging.info('%s appears to be a security issue, switching to patch mode...' % (mdlIssue)) if args.patch: if not M.pushPatch(branch): diff --git a/lib/moodle.py b/lib/moodle.py index 6cf7fe3..4ba9948 100644 --- a/lib/moodle.py +++ b/lib/moodle.py @@ -596,7 +596,7 @@ class Moodle(object): headcommit = self.headcommit(branch) # Creating a patch file. - fileName = branch + '-mdk' + '.patch' + fileName = branch + '.mdk.patch' tmpPatchFile = os.path.join(gettempdir(), fileName) if self.git().createPatch('%s...%s' % (headcommit, branch), saveTo=tmpPatchFile):