Merge lp:~craighewetson-deactivatedaccount/qbzr/jira_support into lp:qbzr

Proposed by Craig Hewetson
Status: Merged
Approved by: Alexander Belchenko
Approved revision: 1505
Merged at revision: 1503
Proposed branch: lp:~craighewetson-deactivatedaccount/qbzr/jira_support
Merge into: lp:qbzr
Diff against target: 61 lines (+23/-0)
3 files modified
NEWS.txt (+1/-0)
lib/bugs.py (+7/-0)
lib/tests/test_bugs.py (+15/-0)
To merge this branch: bzr merge lp:~craighewetson-deactivatedaccount/qbzr/jira_support
Reviewer Review Type Date Requested Status
Alexander Belchenko Approve
Craig Hewetson (community) Needs Resubmitting
Review via email: mp+168411@code.launchpad.net

Description of the change

Added a new regex matcher for jira bug urls.

To post a comment you must log in.
Revision history for this message
Alexander Belchenko (bialix) wrote :

I wonder if prefix always abbreviation and suffix always number? If so, it would be better to change regexp a bit to match only letters (for prefix) and digits (for suffix), e.g.

_jira_bug_id_re = lazy_regex.lazy_compile(r'(?:.*/browse/)([a-zA-Z]+-\d+)($)')

or if prefix is always uppercased then

_jira_bug_id_re = lazy_regex.lazy_compile(r'(?:.*/browse/)([A-Z]+-\d+)($)')

What do you think? Is there any rules re jira abbreviations?

Revision history for this message
Craig Hewetson (craighewetson-deactivatedaccount) wrote :

Based on this:
https://confluence.atlassian.com/display/JIRACOM/Configuring+Project+Keys
The default is: <project key>-<issue number>
The suffix should always be digits.
The prefix is more interesting, the jira crowd seems to be making their project key format alot more stricter:
https://confluence.atlassian.com/display/JIRA/End+of+Support+Announcements+for+JIRA#EndofSupportAnnouncementsforJIRA-20130513projectkey

Basically the following project keys (prefix of the jira issue) are valid:
 PRODUCT_2013
 R2D2
 MY_EXAMPLE_PROJECT
etc so ... it seems that the prefix rule are:
    1) The first character is a letter
    2) Only letters, numbers or the underscore character is used

So I propose the following regex:
 _jira_bug_id_re = lazy_regex.lazy_compile(r'(?:.*/browse/)([A-Z]+[A-Z0-9_]*-\d+)($)')

Does this look right?

1504. By Craig Hewetson

Add jira (--fixes) support for qlog.
Added some more tests and made the regex more stricter

Revision history for this message
Craig Hewetson (craighewetson-deactivatedaccount) wrote :

Added a few more tests and it looks better.

review: Needs Resubmitting
Revision history for this message
Alexander Belchenko (bialix) wrote :

NOTE: Please don't mix tabs and spaces (I see some oddness in tests).

I think you don't need plus in regexp of prefix, i.e.

_jira_bug_id_re = lazy_regex.lazy_compile(r'(?:.*/browse/)([A-Z][A-Z0-9_]*-\d+)($)')

that way you require first character always be uppercase letter after that zero or several letters, digits or underscores.

Plus means one or more, IIRC. In that case we don't need plus, really.

review: Needs Fixing
Revision history for this message
Alexander Belchenko (bialix) wrote :

Please, revise tabs vs. spaces and test without extra plus. Otherwise it looks pretty good.

I don't remember whether you have commit rights or not?
If so, then you need to add some note in NEWS about your change and then push to trunk.

1505. By Craig Hewetson

Updated NEWS
Change regex for jira issue urls
fixed tab and space mixing

Revision history for this message
Craig Hewetson (craighewetson-deactivatedaccount) wrote :

The changes have been made, please merge into trunk when you have time.
I don't have write access to trunk. Don't bother assigning those permissions to me, I don't mind going through this process to get code checked in.

review: Needs Resubmitting
Revision history for this message
Alexander Belchenko (bialix) :
review: Approve
Revision history for this message
Alexander Belchenko (bialix) wrote :

Well, I've added you to the qbzr dev team. Now you should be able to push.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS.txt'
2--- NEWS.txt 2012-10-31 18:25:08 +0000
3+++ NEWS.txt 2013-06-14 11:15:30 +0000
4@@ -12,6 +12,7 @@
5 * Fix: Fails to modify or remove merge tool configuration. (Bug #1045827)
6 * qlog:
7 * Support for FusionForge bug tracker. (Jérémy Subtil, Bug #1072044)
8+ * Support for Jira bug tracker. (Craig Hewetson, Bug #1189421)
9
10
11 0.23.0 "Birch" - 2012/07/12
12
13=== modified file 'lib/bugs.py'
14--- lib/bugs.py 2012-10-31 18:25:08 +0000
15+++ lib/bugs.py 2013-06-14 11:15:30 +0000
16@@ -36,6 +36,10 @@
17 r'|aid=' # FusionForge bug tracker URL
18 r')(\d+)(?:\b|$)')
19
20+
21+_jira_bug_id_re = lazy_regex.lazy_compile(r'(?:.*/browse/)([A-Z][A-Z0-9_]*-\d+)($)')
22+
23+
24 _unique_bugtrackers = ('lp', 'deb', 'gnome')
25 # bugtracker config settings
26 _bugtracker_re = lazy_regex.lazy_compile('(bugtracker|trac|bugzilla)_(.+)_url')
27@@ -45,6 +49,9 @@
28 match = _bug_id_re.search(bug_url)
29 if match:
30 return match.group(1)
31+ match = _jira_bug_id_re.search(bug_url)
32+ if match:
33+ return match.group(1)
34 return None
35
36
37
38=== modified file 'lib/tests/test_bugs.py'
39--- lib/tests/test_bugs.py 2012-10-31 18:25:08 +0000
40+++ lib/tests/test_bugs.py 2013-06-14 11:15:30 +0000
41@@ -57,6 +57,21 @@
42 def test_fusionforge(self):
43 self.assertEquals('292', get_bug_id('https://fusionforge.org/tracker/index.php?func=detail&aid=292'))
44
45+ def test_jira(self):
46+ self.assertEquals('AB-1234', get_bug_id('http://jiraserver/browse/AB-1234'))
47+ self.assertEquals('A_B-1234', get_bug_id('http://jiraserver/browse/A_B-1234'))
48+ self.assertEquals('AB_1-1234', get_bug_id('http://jiraserver/browse/AB_1-1234'))
49+ self.assertEquals('AB_1A-1234', get_bug_id('http://jiraserver/browse/AB_1A-1234'))
50+ self.assertEquals(None, get_bug_id('http://jiraserver/browse/1A-1234'))
51+ self.assertEquals(None, get_bug_id('http://jiraserver/browse/_1A-1234'))
52+ self.assertEquals(None, get_bug_id('http://jiraserver/browse/A-1234A'))
53+ self.assertEquals(None, get_bug_id('http://jiraserver/browse/a-1'))
54+ self.assertEquals(None, get_bug_id('http://jiraserver/browse/a'))
55+ self.assertEquals(None, get_bug_id('http://jiraserver/browse/A'))
56+ self.assertEquals(None, get_bug_id('http://jiraserver/browse/A-'))
57+ self.assertEquals(None, get_bug_id('http://jiraserver/browse/A_1'))
58+ self.assertEquals('A-1', get_bug_id('http://jiraserver/browse/A-1'))
59+ self.assertEquals('ZZ12_SA__2__-122222222', get_bug_id('http://jiras1212erver/browse/ZZ12_SA__2__-122222222'))
60
61 class TestGetBugTags(TestCase):
62

Subscribers

People subscribed via source and target branches