August 27th, 2007 2 Comments »
I needed to present products and their corresponding branches and tags in Subversion in a Rails app. So I’ve come up with this quite simple solution.
The GenericModel class (attached) is ihnerited by Tag, Branch and Product.
The Product class supports methods find, branches and tags for which it uses ‘svn/client’.
The config.yml (which is read into OpenStruct) is very simple:
svn:
url: http://svn/svn/repos
user: roman
password: roman
The Product class tries to provide interface similar to the ActiveRecord (of course I didn’t immitate everything, just the basic stuff). Implementing interfaces in a contract-less language is an adventure
generic_model.rb
product.rb
August 24th, 2007 1 Comment »
Today I extended my Bugzilla gateway to support “products” in Bugzilla.
To my surprise, I found out that Bugzilla’s XML-RPC doesn’t return the associated “components” and “versions”.
The fix is quite simple:
--- Bugzilla/WebService/Product.pm.orig Fri Aug 24 20:46:07 2007
+++ Bugzilla/WebService/Product.pm Fri Aug 24 21:10:47 2007
@@ -60,6 +60,8 @@
id => type('int')->value($_->id),
name => type('string')->value($_->name),
description => type('string')->value($_->description),
+ components => $_->components,
+ versions => $_->versions
}
} @requested_accessible;
I’ll try to submit it to the Bugzilla’s bugzilla
But what’s really missing, is the ability to change bugs via the XML-RPC API, or for the very least – adding comments.
The current way of doing it via the mail gateway is a little bit ugly.
Update: It turns out that there’s a bug opened already: https://bugzilla.mozilla.org/show_bug.cgi?id=385282
And this bug has a patch which allows appending comments to a bug.
August 14th, 2007 3 Comments »
I finally posted my Bugzilla plugin on Rubyforge.
The project page is:
http://rubyforge.org/projects/rubzilla/
The source can be found here:
svn://rubyforge.org/var/svn/rubzilla/bugzilla/trunk
License:
BSD
It is probably not complete, and has some bugs, and surely lacks documentation, but this is better than nothing
August 12th, 2007 No Comments »
To install Bugzilla on FC6:
yum install perl-DBD-MySQL perl-TimeDate perl-MIME-tools
perl-AppConfig perl-Template-Toolkit
Optional:
yum install perl-PatchReader perl-GD perl-Chart perl-GDGraph perl-Template-GD
Configuring Subversion to send email upon commit
Copy the /usr/share/doc/subversion-1.4.X/tools/hook-scripts/commit-email.pl to hooks directory and patch it with my changes:
--- commit-email.pl.orig 2007-02-07 11:57:50.000000000 +0200
+++ commit-email.pl 2007-08-01 16:31:40.000000000 +0300
@@ -347,6 +347,7 @@
# $author - declared above for use as a command line parameter in
# revprop-change mode. In commit mode, gets filled in below.
+my @log;
if ($mode eq 'commit')
{
######################################################################
@@ -357,7 +358,7 @@
$author = shift @infolines;
my $date = shift @infolines;
shift @infolines;
- my @log = map { "$_\n" } @infolines;
+ @log = map { "$_\n" } @infolines;
######################################################################
# Modified directory name collapsing.
@@ -516,6 +517,11 @@
my $subject = $subject_base;
my $diff_wanted = ($project->{show_diff} and $mode eq 'commit');
+ if (join('', @log) =~ /bug.*?(\d+)/im)
+ {
+ $subject_prefix = "[Bug $1]";
+ }
+
if ($subject_prefix =~ /\w/)
{
$subject = "$subject_prefix $subject";
Edit the post-commit file under hooks directory in subversion repository:
/home/svn/hooks/commit-email.pl "$REPOS" "$REV" -h domain.example.com --diff n bugzilla@bugzilla.host
Configuring sendmail to send the mail to the Bugzilla email gateway
Install perl-MIME-tools package:
yum install perl-MIME-tools
Patch /usr/local/bugzilla/contrib/bugzilla_email_append.pl :
--- bugzilla_email_append.pl.orig 2007-08-01 16:05:01.000000000 +0300
+++ bugzilla_email_append.pl 2007-08-02 10:43:53.000000000 +0300
@@ -32,7 +32,7 @@
use MIME::Parser;
BEGIN {
- chdir ".."; # this script lives in contrib, change to main
+ chdir '/usr/local/bugzilla';
push @INC, "contrib";
push @INC, "."; # this script lives in contrib
}
@@ -91,6 +91,7 @@
print "The subject is $Subject\n";
my ($bugid) = ($Subject =~ /\[Bug ([\d]+)\]/);
+exit 0 unless $bugid;
print "The bugid is $bugid\n";
# make sure the bug exists
@@ -122,6 +123,11 @@
SendSQL($long_desc_query);
+# I'll exit at this point, since Bugzilla::BugMail::Send yields:
+# Can't call method "active_names" on an undefined value at globals.pl line 203.
+# and this make the sendmail filter fail miserably.
+exit 0;
+
Bugzilla::BugMail::Send( $found_id, { changer => $SenderShort } );
sub DealWithError {
Make this script trusted by sendmail:
cd /etc/smrsh; ln -s /usr/local/bugzilla/contrib/bugzilla_email_append.pl .
Edit /etc/aliases and add:
bugzilla: |bugzilla_email_append.pl
Then don’t forget to run newaliases.
Change user to the “mail” user (you’ll need to change its shell for this test), and try running the bugzilla_email_append.pl.
Change permissions in /usr/local/bugzilla for files and/or directories it complains about (if it does).
That’s it. When there will be commit with ‘Bug 123′ in the comment, the bug will be updated with this information (including the files involved).
August 11th, 2007 1 Comment »
Lately I’ve been playing with the Bugzilla 3.0 XML-RPC API.
It turned out to be quite basic and inconsistent, but nevertheless – it’s a progress.
It’s also a CPU hog, so I’d not recommend running Bugzilla without mod_perl (latest versions finally added this long-time awaited feature).
The last time I wanted to integrate Bugzilla in one of our projects, I’d to write a class which mimicked a browser and this way contacted Bugzilla.
But this time I’ve come up with a nice Ruby module for Bugzilla, which has API similar of that of ActiveRecord, making integration of it in Ruby-on-rails application quite simple.
I’ll probably add some comments, throw in some more tests and open a project on rubyforge or something. Not to forget to notify the Bugzilla guys, perhaps they’ll find some use for this code.