From f1bb9d61af5adbd32985cd1e09a17b46816dc810 Mon Sep 17 00:00:00 2001 From: Frederic Massart Date: Wed, 8 Aug 2012 15:27:05 +0800 Subject: [PATCH] Branch names use mapping keys --- config-dist.json | 2 +- lib/moodle.py | 6 +++++- moodle-fix.py | 11 ++++------- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/config-dist.json b/config-dist.json index 598ca9d..6ff9270 100644 --- a/config-dist.json +++ b/config-dist.json @@ -38,7 +38,7 @@ "prefixMaster": "m", "suffixSeparator": "", - "branchFormat": "MDL-%s-%s", + "branchFormat": "MDL-%(issue)s-%(version)s", "branchSuffixSeparator": "-", "integration": "Integration", diff --git a/lib/moodle.py b/lib/moodle.py index 4063ed6..48217e8 100644 --- a/lib/moodle.py +++ b/lib/moodle.py @@ -78,7 +78,11 @@ class Moodle(object): mdl = re.sub(r'MDL(-|_)?', '', issue, flags=re.I) if version == '': version = self.get('branch') - branch = C('wording.branchFormat') % (mdl, version) + args = { + 'issue': mdl, + 'version': version + } + branch = C('wording.branchFormat') % args if suffix != None and suffix != '': branch += C('wording.branchSuffixSeparator') + suffix return branch diff --git a/moodle-fix.py b/moodle-fix.py index c53f143..531da11 100755 --- a/moodle-fix.py +++ b/moodle-fix.py @@ -26,24 +26,21 @@ if not M: sys.exit(1) # Branch name -mdl = re.sub(r'MDL(-|_)?', '', args.issue, flags=re.I) -branch = C('wording.branchFormat') % (mdl, M.get('branch')) -if len(args.suffix) > 0: - branch += C('wording.branchSuffixSeparator') + args.suffix +branch = M.generateBranchName(args.issue, suffix=args.suffix) # Track track = 'origin/%s' % M.get('stablebranch') # Git repo -repo = git.Git(M.get('path')) +repo = M.git() # Creating and checking out the new branch if not repo.hasBranch(branch): if not repo.createBranch(branch, track): debug('Could not create branch %s' % branch) - exit() + sys.exit(1) if not repo.checkout(branch): debug('Error while checkout out branch %s' % branch) - exit() + sys.exit(1) debug('Branch %s checked out' % branch) -- 2.11.0