Simplify calls to tools.parseBranch
authorFrederic Massart <fred@moodle.com>
Wed, 9 Apr 2014 12:29:49 +0000 (20:29 +0800)
committerFrederic Massart <fred@moodle.com>
Wed, 9 Apr 2014 12:29:49 +0000 (20:29 +0800)
lib/commands/backport.py
lib/commands/pull.py
lib/commands/push.py
lib/commands/tracker.py
lib/moodle.py
lib/tools.py

index f408c5f..dac4cd4 100644 (file)
@@ -127,7 +127,7 @@ class BackportCommand(Command):
             branch = M.currentBranch()
 
         # Parsing the branch
-        parsedbranch = tools.parseBranch(branch, self.C.get('wording.branchRegex'))
+        parsedbranch = tools.parseBranch(branch)
         if not parsedbranch:
             raise Exception('Could not extract issue number from %s' % branch)
         issue = parsedbranch['issue']
index 2432b80..11dd02f 100644 (file)
@@ -114,7 +114,7 @@ class PullCommand(Command):
         # Tracker issue number.
         issuenb = args.issue
         if not issuenb:
-            parsedbranch = tools.parseBranch(M.currentBranch(), self.C.get('wording.branchRegex'))
+            parsedbranch = tools.parseBranch(M.currentBranch())
             if not parsedbranch:
                 raise Exception('Could not extract issue number from %s' % M.currentBranch())
             issuenb = parsedbranch['issue']
index 6728ab7..b7f7ad0 100644 (file)
@@ -120,7 +120,7 @@ class PushCommand(Command):
             branch = args.branch
 
         # Extra test to see if the commit message is correct. This prevents easy typos in branch or commit messages.
-        parsedbranch = tools.parseBranch(branch, self.C.get('wording.branchRegex'))
+        parsedbranch = tools.parseBranch(branch)
         if parsedbranch or branch != M.get('stablebranch'):
             message = M.git().messages(count=1)[0]
 
index 1b1597e..287bb7e 100644 (file)
@@ -59,7 +59,7 @@ class TrackerCommand(Command):
         if not args.issue:
             M = self.Wp.resolve()
             if M:
-                parsedbranch = parseBranch(M.currentBranch(), self.C.get('wording.branchRegex'))
+                parsedbranch = parseBranch(M.currentBranch())
                 if parsedbranch:
                     issue = parsedbranch['issue']
         else:
index abbc510..a7aee0d 100644 (file)
@@ -243,7 +243,7 @@ class Moodle(object):
         smartSearch = C.get('smartHeadCommitSearch')
 
         # Parsing the branch
-        parsedbranch = parseBranch(branch, C.get('wording.branchRegex'))
+        parsedbranch = parseBranch(branch)
         if parsedbranch:
             issue = 'MDL-%s' % (parsedbranch['issue'])
         else:
@@ -589,7 +589,7 @@ class Moodle(object):
                 raise Exception('Cannot create a patch from a detached branch')
 
         # Parsing the branch
-        parsedbranch = parseBranch(branch, C.get('wording.branchRegex'))
+        parsedbranch = parseBranch(branch)
         if not parsedbranch:
             raise Exception('Could not extract issue number from %s' % branch)
         issue = 'MDL-%s' % (parsedbranch['issue'])
@@ -725,7 +725,7 @@ class Moodle(object):
                 raise Exception('Cannot update the tracker when on detached branch')
 
         # Parsing the branch
-        parsedbranch = parseBranch(branch, C.get('wording.branchRegex'))
+        parsedbranch = parseBranch(branch)
         if not parsedbranch:
             raise Exception('Could not extract issue number from %s' % branch)
         issue = 'MDL-%s' % (parsedbranch['issue'])
index 523e4fb..cbfcda9 100644 (file)
@@ -127,8 +127,8 @@ def mkdir(path, perms=0755):
     os.umask(oldumask)
 
 
-def parseBranch(branch, pattern):
-    pattern = re.compile(pattern, flags=re.I)
+def parseBranch(branch):
+    pattern = re.compile(C.get('wording.branchRegex'), flags=re.I)
     result = pattern.search(branch)
     if not result:
         return False