Branch names use mapping keys
authorFrederic Massart <fred@moodle.com>
Wed, 8 Aug 2012 07:27:05 +0000 (15:27 +0800)
committerFrederic Massart <fred@moodle.com>
Wed, 8 Aug 2012 07:27:05 +0000 (15:27 +0800)
config-dist.json
lib/moodle.py
moodle-fix.py

index 598ca9d..6ff9270 100644 (file)
@@ -38,7 +38,7 @@
         "prefixMaster": "m",
         "suffixSeparator": "",
 
-        "branchFormat": "MDL-%s-%s",
+        "branchFormat": "MDL-%(issue)s-%(version)s",
         "branchSuffixSeparator": "-",
 
         "integration": "Integration",
index 4063ed6..48217e8 100644 (file)
@@ -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
index c53f143..531da11 100755 (executable)
@@ -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)