From d4dcd9f1eae9401f6cae2c5b6cce6be307ece52f Mon Sep 17 00:00:00 2001 From: Frederic Massart Date: Wed, 9 Apr 2014 20:29:49 +0800 Subject: [PATCH] Simplify calls to tools.parseBranch --- lib/commands/backport.py | 2 +- lib/commands/pull.py | 2 +- lib/commands/push.py | 2 +- lib/commands/tracker.py | 2 +- lib/moodle.py | 6 +++--- lib/tools.py | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/commands/backport.py b/lib/commands/backport.py index f408c5f..dac4cd4 100644 --- a/lib/commands/backport.py +++ b/lib/commands/backport.py @@ -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'] diff --git a/lib/commands/pull.py b/lib/commands/pull.py index 2432b80..11dd02f 100644 --- a/lib/commands/pull.py +++ b/lib/commands/pull.py @@ -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'] diff --git a/lib/commands/push.py b/lib/commands/push.py index 6728ab7..b7f7ad0 100644 --- a/lib/commands/push.py +++ b/lib/commands/push.py @@ -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] diff --git a/lib/commands/tracker.py b/lib/commands/tracker.py index 1b1597e..287bb7e 100644 --- a/lib/commands/tracker.py +++ b/lib/commands/tracker.py @@ -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: diff --git a/lib/moodle.py b/lib/moodle.py index abbc510..a7aee0d 100644 --- a/lib/moodle.py +++ b/lib/moodle.py @@ -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']) diff --git a/lib/tools.py b/lib/tools.py index 523e4fb..cbfcda9 100644 --- a/lib/tools.py +++ b/lib/tools.py @@ -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 -- 2.11.0