Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the SVN-Hooks CPAN distribution.

Report information
The Basics
Id: 53706
Status: resolved
Priority: 0/
Queue: SVN-Hooks

People
Owner: GNUSTAVO [...] cpan.org
Requestors: Chris.Rule [...] l-3com.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: SVN::Hooks add-on - AddJiraComments
Date: Thu, 14 Jan 2010 17:42:29 -0600
To: <bug-SVN-Hooks [...] rt.cpan.org>
From: <Chris.Rule [...] l-3com.com>
I'm using SVN::Hooks version 0.24 to do Jira issue validation and email notification under perl v5.8.8 on unix. I needed the ability to also add comments to each Jira issue for each subversion commit. To do this I created a new SVN::Hooks plugin. I've included the source below. The license is the same as for SVN::Hooks. Enjoy. Chris Rule

Message body is not shown because sender requested not to inline it.

Subject: Re: [rt.cpan.org #53706] SVN::Hooks add-on - AddJiraComments
Date: Thu, 14 Jan 2010 22:00:06 -0200
To: bug-SVN-Hooks [...] rt.cpan.org
From: Gustavo Leite de Mendonça Chaves <gnustavo [...] cpan.org>
On Thu, Jan 14, 2010 at 9:45 PM, Chris.Rule via RT < bug-SVN-Hooks@rt.cpan.org> wrote: Show quoted text
> Thu Jan 14 18:45:01 2010: Request 53706 was acted upon. > Transaction: Ticket created by Chris.Rule@l-3com.com > Queue: SVN-Hooks > Subject: SVN::Hooks add-on - AddJiraComments > Broken in: (no value) > Severity: (no value) > Owner: Nobody > Requestors: Chris.Rule@l-3com.com > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=53706 > > > > I'm using SVN::Hooks version 0.24 to do Jira issue validation and email > notification under perl v5.8.8 on unix. I needed the ability to also add > comments to each Jira issue for each subversion commit. > > To do this I created a new SVN::Hooks plugin. I've included the source > below. The license is the same as for SVN::Hooks. >
Hey, Chris. Thanks. It's cool and gave me some other ideas... But have you considered the JIRA Subversion Plugin<http://confluence.atlassian.com/display/JIRAEXT/JIRA+Subversion+plugin>? It probably does what you want but instead of logging the commits as JIRA comments it uses another tab in the issue specific for the Subversion logs. What do you think? Gustavo.
Subject: RE: [rt.cpan.org #53706] SVN::Hooks add-on - AddJiraComments
Date: Thu, 14 Jan 2010 18:08:12 -0600
To: <bug-SVN-Hooks [...] rt.cpan.org>
From: <Chris.Rule [...] l-3com.com>
We are already using the subversion plugin, but I can't figure out a way to get Jira to show me a list of issues that have been worked between two dates (generally some date in the past to now). By "have been worked" I mean there is code modifications in subversion against the issues. We are also using Fisheye. In Fisheye I can get a list of files that have been changed between two dates, but I need a list of the issues affected with their summaries. Since the comments are now being added with each commit, I can simply search the comments between dates which Jira does allow. Chris Rule Show quoted text
-----Original Message----- From: Gustavo Leite de Mendonça Chaves via RT [mailto:bug-SVN-Hooks@rt.cpan.org] Sent: Thursday, January 14, 2010 6:00 PM To: Chris.Rule@l-3com.com Subject: Re: [rt.cpan.org #53706] SVN::Hooks add-on - AddJiraComments <URL: http://rt.cpan.org/Ticket/Display.html?id=53706 > On Thu, Jan 14, 2010 at 9:45 PM, Chris.Rule via RT < bug-SVN-Hooks@rt.cpan.org> wrote:
> Thu Jan 14 18:45:01 2010: Request 53706 was acted upon. > Transaction: Ticket created by Chris.Rule@l-3com.com > Queue: SVN-Hooks > Subject: SVN::Hooks add-on - AddJiraComments > Broken in: (no value) > Severity: (no value) > Owner: Nobody > Requestors: Chris.Rule@l-3com.com > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=53706 > > > > I'm using SVN::Hooks version 0.24 to do Jira issue validation and email > notification under perl v5.8.8 on unix. I needed the ability to also add > comments to each Jira issue for each subversion commit. > > To do this I created a new SVN::Hooks plugin. I've included the source > below. The license is the same as for SVN::Hooks. >
Hey, Chris. Thanks. It's cool and gave me some other ideas... But have you considered the JIRA Subversion Plugin<http://confluence.atlassian.com/display/JIRAEXT/JIRA+Subversion+plugin>? It probably does what you want but instead of logging the commits as JIRA comments it uses another tab in the issue specific for the Subversion logs. What do you think? Gustavo.
Subject: Re: [rt.cpan.org #53706] SVN::Hooks add-on - AddJiraComments
Date: Thu, 14 Jan 2010 22:36:46 -0200
To: bug-SVN-Hooks [...] rt.cpan.org
From: Gustavo Leite de Mendonça Chaves <gnustavo [...] cpan.org>
On Thu, Jan 14, 2010 at 10:08 PM, Chris.Rule via RT < bug-SVN-Hooks@rt.cpan.org> wrote: Show quoted text
> Queue: SVN-Hooks > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=53706 > > > We are already using the subversion plugin, but I can't figure out a way to > get Jira to show me a list of issues that have been worked between two dates > (generally some date in the past to now). By "have been worked" I mean there > is code modifications in subversion against the issues. >
Show quoted text
> We are also using Fisheye. In Fisheye I can get a list of files that have > been changed between two dates, but I need a list of the issues affected > with their summaries. Since the comments are now being added with each > commit, I can simply search the comments between dates which Jira does > allow. >
Ah. Got it. I have a feeling that the two plugins could be merged. Better yet, perhaps I could extend the CheckJira in a way that would allow you to implement the functionality you want and more... I could, for instance, add an argument the the check_one/check_all functions. They already receive the JIRA::Client object and the RemoteIssue's objects. If they also received the SVN::Look object one could extract all the commit information and use it to add the comments. Something like this: CHECK_JIRA(..., check_one => sub { my ($jira, $issue, $svnlook) = @_; ... paste here the meat of your post_commit sub... }); In order to allow for the substitutions inside the comment string one could do tricks with closures. Besides being more general, there would be a single JIRA::Client object connecting the hook to JIRA. WIth the two separate plugins there would be two. The addition of a third argument to check_one is backward compatible. But check_all has an unbounded number of parameters. I can think of a few solutions (inserting a second argument and making an incompatible change, defining a new option, let the user check the argument type (horror)...) but no one is perfect. What do you think of this "extend and embrace" approach? :-) Gustavo.
Subject: RE: [rt.cpan.org #53706] SVN::Hooks add-on - AddJiraComments
Date: Fri, 15 Jan 2010 09:16:59 -0600
To: <bug-SVN-Hooks [...] rt.cpan.org>
From: <Chris.Rule [...] l-3com.com>
I think merging the two is a very good idea; if nothing else to only have a single JIRA::Client object that has to be defined. I had implemented this as a post-commit script because at that point I know the commit has happened. I think this functionality would need to stay the same. Wouldn't want to add a comment to some issues then have later issues cause the commit to be aborted for some reason. Given this, attempting to use the existing check_one or check_all subs may be problematic since these would also be called in the pre-commit script. I wouldn't want to have to say "if (pre-commit) do something" in the scripts. To easy to do something that I wouldn't want, forget to add the check, and could break existing scripts. Show quoted text
>> In order to allow for the substitutions inside the comment string one could do tricks with closures.
Wow! Something I've never run into with Perl. This seems pretty obscure but it might work. Not sure how though. Sounds like a good thought, Chris Rule Show quoted text
-----Original Message----- From: Gustavo Leite de Mendonça Chaves via RT [mailto:bug-SVN-Hooks@rt.cpan.org] Sent: Thursday, January 14, 2010 6:37 PM To: Chris.Rule@l-3com.com Subject: Re: [rt.cpan.org #53706] SVN::Hooks add-on - AddJiraComments <URL: https://rt.cpan.org/Ticket/Display.html?id=53706 > ... I have a feeling that the two plugins could be merged. Better yet, perhaps I could extend the CheckJira in a way that would allow you to implement the functionality you want and more... I could, for instance, add an argument the the check_one/check_all functions. They already receive the JIRA::Client object and the RemoteIssue's objects. If they also received the SVN::Look object one could extract all the commit information and use it to add the comments. Something like this: CHECK_JIRA(..., check_one => sub { my ($jira, $issue, $svnlook) = @_; ... paste here the meat of your post_commit sub... }); In order to allow for the substitutions inside the comment string one could do tricks with closures. Besides being more general, there would be a single JIRA::Client object connecting the hook to JIRA. WIth the two separate plugins there would be two. The addition of a third argument to check_one is backward compatible. But check_all has an unbounded number of parameters. I can think of a few solutions (inserting a second argument and making an incompatible change, defining a new option, let the user check the argument type (horror)...) but no one is perfect. What do you think of this "extend and embrace" approach? :-) Gustavo.
Subject: Re: [rt.cpan.org #53706] SVN::Hooks add-on - AddJiraComments
Date: Fri, 15 Jan 2010 13:44:06 -0200
To: bug-SVN-Hooks [...] rt.cpan.org
From: Gustavo Leite de Mendonça Chaves <gnustavo [...] cpan.org>
On Fri, Jan 15, 2010 at 1:17 PM, Chris.Rule via RT < bug-SVN-Hooks@rt.cpan.org> wrote: Show quoted text
> Queue: SVN-Hooks > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=53706 > > > I think merging the two is a very good idea; if nothing else to only have a > single JIRA::Client object that has to be defined. > > I had implemented this as a post-commit script because at that point I know > the commit has happened. I think this functionality would need to stay the > same. Wouldn't want to add a comment to some issues then have later issues > cause the commit to be aborted for some reason. Given this, attempting to > use the existing check_one or check_all subs may be problematic since these > would also be called in the pre-commit script. I wouldn't want to have to > say "if (pre-commit) do something" in the scripts. To easy to do something > that I wouldn't want, forget to add the check, and could break existing > scripts. >
Of course! I forgot about the pre/post commit hooks. But this also solves the problem with modifying the check_all function signature, because I don't need to. All I have to do is to add another option to CHECK_JIRA. Perhaps an options called "post_commit" which would accept a ref to a subroutine with the following signature: ($jira, $svnlook, @issues). This soubroutine would be called during the post_commit phase and not during the pre_commit phase. Show quoted text
> >> In order to allow for the substitutions inside the comment string one
> could do tricks with closures. > Wow! Something I've never run into with Perl. This seems pretty obscure but > it might work. Not sure how though. >
A closure is simply a routine defined inside another but which uses a local variable of the outer routine. In this case I was thinking about something along these lines: sub add_comment { my ($format) = @_; sub closure { my ($jira, $svnlook, @issues) = @_; ... extract the commit info from $svnlook my $comment = $format; ... make all substitutions inside $comment foreach my $issue (@issues) { $jira->addComment($issue, $comment); } } return \&closure; } CHECK_JIRA(... post_commit => add_comment("Subversion Commit rev {rev} by {author} on {date}\n{logmessage}")); With add_comment defined in your svn-hooks.conf you can have several CHECK_JIRA calls, each one specifying a different comment format. How this seems to you? I'll try to release a new version of SVN::Hooks along these lines during the weekend. Gustavo.
Subject: RE: [rt.cpan.org #53706] SVN::Hooks add-on - AddJiraComments
Date: Fri, 15 Jan 2010 11:16:50 -0600
To: <bug-SVN-Hooks [...] rt.cpan.org>
From: <Chris.Rule [...] l-3com.com>
That should work and is definitely more flexible. I think an example would be useful to show how to use it with closure since closure is an advanced perl technique. Unfortunately I don't seem to have a good enough imagination today to think of what else you would want to do in a post-commit script with Jira besides adding a comment. It might also be a good idea to also have a simpler example that shows the svnlook information extraction: sub add_comment { my ($jira, $svnlook, @issues) = @_; # Extract useful information into local variables from svnlook. my $repo = $svnlook->repo(); my $rev = $svnlook->rev(); my $author = $svnlook->author(); my $logMessage = $svnlook->log_msg(); my $revdate = $svnlook->date(); foreach my $issue (@issues) { $jira->addComment($issue, ("Subversion Commit rev $rev by $author on $date\n$logMessage); } } CHECK_JIRA(... post_commit => \&add_comment); I was wondering if there should be some "helper" subs available to do things like make the substitutions or do the addComment, but I think just having examples would be good enough. Sounds like a plan. Chris Rule Show quoted text
-----Original Message----- From: Gustavo Leite de Mendonça Chaves via RT [mailto:bug-SVN-Hooks@rt.cpan.org] Sent: Friday, January 15, 2010 9:45 AM To: Chris.Rule@l-3com.com Subject: Re: [rt.cpan.org #53706] SVN::Hooks add-on - AddJiraComments ... Of course! I forgot about the pre/post commit hooks. But this also solves the problem with modifying the check_all function signature, because I don't need to. All I have to do is to add another option to CHECK_JIRA. Perhaps an options called "post_commit" which would accept a ref to a subroutine with the following signature: ($jira, $svnlook, @issues). This soubroutine would be called during the post_commit phase and not during the pre_commit phase.
> >> In order to allow for the substitutions inside the comment string one
> could do tricks with closures. > Wow! Something I've never run into with Perl. This seems pretty obscure but > it might work. Not sure how though. >
A closure is simply a routine defined inside another but which uses a local variable of the outer routine. In this case I was thinking about something along these lines: sub add_comment { my ($format) = @_; sub closure { my ($jira, $svnlook, @issues) = @_; ... extract the commit info from $svnlook my $comment = $format; ... make all substitutions inside $comment foreach my $issue (@issues) { $jira->addComment($issue, $comment); } } return \&closure; } CHECK_JIRA(... post_commit => add_comment("Subversion Commit rev {rev} by {author} on {date}\n{logmessage}")); With add_comment defined in your svn-hooks.conf you can have several CHECK_JIRA calls, each one specifying a different comment format. How this seems to you? I'll try to release a new version of SVN::Hooks along these lines during the weekend. Gustavo.
Subject: Re: [rt.cpan.org #53706] SVN::Hooks add-on - AddJiraComments
Date: Sat, 16 Jan 2010 20:14:02 -0200
To: bug-SVN-Hooks [...] rt.cpan.org
From: Gustavo Leite de Mendonça Chaves <gnustavo [...] cpan.org>
Chris, I changed the CheckJira plugin along the lines we discussed this week. Before uploading it as a new official version I'd like to have your feedback. Can you implement what you want with it? Is the example in the POD clear enough? (I made it very short.) You can just substitute the attached version for the one you already have. Thanks. Gustavo.

Message body is not shown because sender requested not to inline it.

Subject: Re: [rt.cpan.org #53706] SVN::Hooks add-on - AddJiraComments
Date: Sun, 17 Jan 2010 22:45:48 -0200
To: bug-SVN-Hooks [...] rt.cpan.org
From: Gustavo Leite de Mendonça Chaves <gnustavo [...] cpan.org>
Chris, I noticed a problem with the CheckJira I sent to you yesterday. Please, use the one attached here instead. Gustavo.

Message body is not shown because sender requested not to inline it.

Subject: RE: [rt.cpan.org #53706] SVN::Hooks add-on - AddJiraComments
Date: Tue, 19 Jan 2010 10:02:27 -0600
To: <bug-SVN-Hooks [...] rt.cpan.org>
From: <Chris.Rule [...] l-3com.com>
Gustavo, Looks like it works. The only thing I would change in the POD description is to change the perl comment in the add_comment function example. Instead of: # interpolate commit info in the comment I would expand it to: # Substitute keywords in the input comment with calls # into the $svnlook reference. Otherwise it looks great. Neat trick BTW on that substitution code. Would never have thought of that. Thanks, Chris Rule Show quoted text
-----Original Message----- From: Gustavo Leite de Mendonça Chaves via RT [mailto:bug-SVN-Hooks@rt.cpan.org] Sent: Sunday, January 17, 2010 6:46 PM To: Chris.Rule@l-3com.com Subject: Re: [rt.cpan.org #53706] SVN::Hooks add-on - AddJiraComments <URL: http://rt.cpan.org/Ticket/Display.html?id=53706 > Chris, I noticed a problem with the CheckJira I sent to you yesterday. Please, use the one attached here instead. Gustavo.
Chris, I just uploaded SVN::Hooks 0.25 to PAUSE. It should appear shortly on CPAN. It contains the changed CheckJira. Thanks a lot for your cooperation. Gustavo.