Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 465045 - Gerrit -> Bugzilla: support "Bug: xxxxxx" at the end of the commit message too
Summary: Gerrit -> Bugzilla: support "Bug: xxxxxx" at the end of the commit message too
Status: RESOLVED FIXED
Alias: None
Product: Community
Classification: Eclipse Foundation
Component: Gerrit (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Eclipse Webmaster CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-20 13:38 EDT by Andreas Sewe CLA
Modified: 2015-07-13 12:54 EDT (History)
10 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Sewe CLA 2015-04-20 13:38:44 EDT
Hi,

a change like [1] triggers the very helpful Genie (thanks for the feature!), but a change like [2] did not; I had to add the See Also field myself in Bugzilla.

From my observations I assume that Genie is not triggered by commit headers of the form

  Bug: xxxxxx

even though they are shown as links in Gerrit. Is this correct? And can the behavior be changed to also trigger Genie?

[1] <https://git.eclipse.org/r/#/c/45962/>
[2] <https://git.eclipse.org/r/#/c/46099/>
Comment 1 Denis Roy CLA 2015-04-21 09:34:51 EDT
Bug: XXXXX is acceptable, but I don't think we're examining the entire commit message.

+1 on supporting this at the end of the commit message as well.
Comment 2 Matthias Sohn CLA 2015-04-21 10:37:32 EDT
+1
Comment 3 Markus Keller CLA 2015-06-05 09:15:57 EDT
+1

The format also works in cGit, e.g. for [1] from above:
http://git.eclipse.org/c/recommenders/org.eclipse.recommenders.git/commit/?id=b7dea17ab82db2693a458b8117fde762689501c9

But I think it doesn't work in Bugzilla. Test: Bug: 465032
Comment 4 Lars Vogel CLA 2015-06-05 09:53:59 EDT
+1
Comment 5 Stephan Herrmann CLA 2015-06-06 08:08:16 EDT
Regarding the position within the commit message: I've seen the patterns

  Bug 465045 - Workaround for Bug 123456 in component X
  Bug 465045 - Follow-up after Bug 123456

create see-also links in Bug 123456, which IMHO is wrong.
Comment 6 Denis Roy CLA 2015-06-06 09:24:59 EDT
(In reply to Stephan Herrmann from comment #5)
> Regarding the position within the commit message: I've seen the patterns
> 
>   Bug 465045 - Workaround for Bug 123456 in component X
>   Bug 465045 - Follow-up after Bug 123456
> 
> create see-also links in Bug 123456, which IMHO is wrong.

That is a good point.  We can examine the commit message line-by-line and use ^Bug: as the pattern.


(In reply to Markus Keller from comment #3)
> But I think it doesn't work in Bugzilla. Test: Bug: 465032

If there's an expectation that each pattern works everywhere, we'll cut back and reduce/standardize the patterns we linkify.
Comment 7 Markus Keller CLA 2015-06-08 10:51:33 EDT
(In reply to Denis Roy from comment #6)
> That is a good point.  We can examine the commit message line-by-line and
> use ^Bug: as the pattern.

For the "Bug: xxxxxx" case, that's good. The Git convention [1] is actually to use only the last paragraph of a commit message for such "extra fields", but matching all lines shouldn't hurt.

[1] https://wiki.eclipse.org/EGit/User_Guide#Footer_Tags

For the "Bug xxxxxx" case, note that some committers write commit messages like "Fixed bug xxxxxx: <bug summary>".

Without a colon, I think the Genie should just be triggered on the very first occurrence of "[Bb]ug\s*(\d+)" in the commit message.
Comment 8 Timur Achmetow CLA 2015-06-16 16:52:02 EDT
+1
Comment 9 Matthias Sohn CLA 2015-06-17 03:41:33 EDT
any ETA when we can get this
Comment 10 Andrey Loskutov CLA 2015-07-05 13:15:53 EDT
Please can we get this fixed soon? We have this pattern in our style guide for EGit/JGit projects, and despite this one must always connect all commits & reviews manually to bugzilla.
Comment 11 Markus Keller CLA 2015-07-06 06:36:00 EDT
Created https://github.com/eclipsewebmaster/admintools/pull/1

With the fix, "^Bug: (\d+)" overrides other bug references in the summary. This is to support e.g. commit messages like this:

---
Fix NPE introduced by bug 12345

Bug: 54321
Signed-off-by: Fixer <fixer@example.com>
---
Comment 12 Denis Roy CLA 2015-07-07 15:19:23 EDT
(In reply to Markus Keller from comment #11)
> Created https://github.com/eclipsewebmaster/admintools/pull/1
> 
> With the fix, "^Bug: (\d+)" overrides other bug references in the summary.
> This is to support e.g. commit messages like this:

Thanks for the pull request!

Should we make the pattern match m/([Bb]ug:?\s*#?)(\d+)/ as per line 106, for consistency?  I'm sure some may wonder why bug 123456 or bug:123456 won't be supported.
Comment 13 Andrey Loskutov CLA 2015-07-07 17:30:11 EDT
(In reply to Denis Roy from comment #12)
> (In reply to Markus Keller from comment #11)
> > Created https://github.com/eclipsewebmaster/admintools/pull/1
> > 
> > With the fix, "^Bug: (\d+)" overrides other bug references in the summary.
> > This is to support e.g. commit messages like this:
> 
> Thanks for the pull request!
> 
> Should we make the pattern match m/([Bb]ug:?\s*#?)(\d+)/ as per line 106,
> for consistency?  I'm sure some may wonder why bug 123456 or bug:123456
> won't be supported.

I think that having kind of "standard" one-line attributes format like below is more consistent, relaxing it further is not necessary:

Bug: 465045
Change-Id: sdfgsdfg
Signed-off-by: sfgdgdsfg

So can we get our "^Bug: (\d+)" pattern soon ? :-)
Comment 14 Markus Keller CLA 2015-07-08 06:21:55 EDT
(In reply to Andrey Loskutov from comment #13)
I agree, no more magic necessary for the footer tag. The footer format is pretty standardized in Git and we better support the standard only. The pattern in the subject line matches "prose text", so it's good that that one is forgiving.


(In reply to Sam Davis from bug 434811 comment #62)
> On the Mylyn project we use
> 
> Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=12345
> 
> in the commit message footer, because providing a URL is more useful than
> just a bug id. It would be nice to not have to also add bug: 12345 since it
> would be redundant. Any chance of supporting this format too?

That request was redirected to this bug. I think it makes sense to support full bug URLs as well.

Sam, is "Task-Url:" really a widely-used footer tag?

I'd prefer to only add:
^Bug: (?:https://bugs\.eclipse\.org/(?:bugs/show_bug\.cgi\?id=)?)?(\d+)

That would support these formats:
Bug: 12345
Bug: https://bugs.eclipse.org/12345
Bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=12345

The last one is already recommended in https://wiki.eclipse.org/Development_Resources/Contributing_via_Git#The_Commit_Record
Comment 15 Denis Roy CLA 2015-07-08 07:16:50 EDT
(In reply to Markus Keller from comment #14)
> I'd prefer to only add:
> ^Bug: (?:https://bugs\.eclipse\.org/(?:bugs/show_bug\.cgi\?id=)?)?(\d+)

May I suggest:
^Bug: (?:https://bugs\.\w+\.org/(?:bugs/show_bug\.cgi\?id=)?)?(\d+)

To support LocationTech and Polarsys bugs?


Will you be updating your pull request? Andrey seems quite anxious  :)
Comment 16 Markus Keller CLA 2015-07-08 08:32:42 EDT
(In reply to Denis Roy from comment #15)
> Will you be updating your pull request? Andrey seems quite anxious  :)

Done: https://github.com/eclipsewebmaster/admintools/pull/2

We can take care of the "Task-Url:" tag later or in another bug if really necessary.
Comment 17 Denis Roy CLA 2015-07-08 14:06:21 EDT
(In reply to Markus Keller from comment #16)
> (In reply to Denis Roy from comment #15)
> > Will you be updating your pull request? Andrey seems quite anxious  :)
> 
> Done: https://github.com/eclipsewebmaster/admintools/pull/2

One last request:

The regexp is actually not complete.  The slashes would need to be escaped, and there's no / delimiter at the end.

This regexp is complete, and using # as a delimiter avoids escaping slashes.  With local sample data, it covers all three use cases of Bug:

if($_ =~ m#^Bug: (?:https://bugs\.\w+\.org/(?:bugs/show_bug\.cgi\?id=)?)?(\d+)#) {

If you can update your PR I will pull it in immediately and put it into production.
Comment 18 Markus Keller CLA 2015-07-08 16:16:13 EDT
(In reply to Denis Roy from comment #17)
> If you can update your PR I will pull it in immediately and put it into
> production.

I think I've just done that, but I'm a Github newbie. I just amended my commit and force-pushed it to the Github branch off which I had created the pull request. It looks like this has silently replaced my original pull request with the fixed patch.
Comment 19 Denis Roy CLA 2015-07-08 16:41:13 EDT
Looks good to me.  It's live now.
Comment 20 Sam Davis CLA 2015-07-08 17:32:08 EDT
(In reply to comment #14) 
> Sam, is "Task-Url:" really a widely-used footer tag?

Yes, this is in the default commit template provided by Mylyn. It would be nice to have the Eclipse Bugzilla support the default that contributors (to any Eclipse project) using Mylyn will put in their commit messages.
Comment 22 Denis Roy CLA 2015-07-09 08:41:10 EDT
"Bug: xxxxxx" at the end of the commit message now works, as shown in the previous comment.
Comment 23 Sam Davis CLA 2015-07-13 12:54:54 EDT
I've opened 472532: support Task-Url: in commit messages
https://bugs.eclipse.org/bugs/show_bug.cgi?id=472532