Google code issue tracker integration with version control using git commit template

October 17, 2009 – 11:39 pm by Stefano MAESTRI
Share

I’m using google code for one of my open source project. And I think it is definitively a good code site.

All open source community code site have its pros and cons (I’ve tried a lot of them sourceforge, github, jboss.org, google code etc), and every one have some beautiful unique feature. But one of my most loved feature is definitively google code’s integration of issue tracker and version control. In a nutshell it permit to create, update and close issues just adding some keyword on your commit.

It’s great in general, but it’s really amazing if you are using a distributed Version Control. And I’m using git for local repository and git-svn to synchronize it with central subversion repository.
Imagine this situation: you are working with your laptop off-line (i.e into an air plane where also GSM connection isn’t available) and you find a bug or you have an idea for an enhancement. What do you do in this case? Of course take care of the bugged code, fix it, write a test for that and then commit it into your git local repository. What is the missing step in this work flow? Of course create an issue into your issue tracker system to keep community up to date, and don’t forget it if you can’t completely finish it now. At this point come very useful the google code feature permitting you to create, update, or fix an issue when you are committing a change.

There is only one problem with this integration: remember the structure the commit message have to fit and all (or at least the most useful) values you can assign to various fields. I’ve solved this problem creating 3 template for the commit messages and I use them with git. Using template during a git commit is very easy: just make a commit like this

git commit -a -t tempalteFile

Git will Use the contents of the given file as the initial version of the commit message. The editor is invoked and you can make subsequent changes. If a message is specified using the -m or -F options, this option has no effect.

Here you have my 3 template file:

NewIssue.tmpl

#commit comment here
 
#next line doesn't need any number. ssue number will be automaticaly assigned after commit
New issue
#A summary is always needed. Please complete next line
Summary:
#Uncomment the rigt Status
#Status: Accepted
#Status: Fixed
#Status: New
#Uncommet right Labels and/or add labels to the list (comma or space separate)
#Labels: Type-Defect Priority-Medium
#Labels: Type-Defect Priority-High
#Labels: Type-Defect Priority-Critical
#Labels: Type-Enhancement Priority-Medium
#Labels: Type-Enhancement Priority-Low
#Labels: Type-Enhancement Priority-High
 
#Comment text for the issue tracker goes here

UpdateIssue.tmpl

#commit comment here
 
#Complete next line with issue number
Update issue
#summary is rarely updated. If you need that uncomment and complete next line
#Summary:
#Uncomment the new Status you would get your issue. No uncomment status will keep the previous status
#Status: Accepted
#Status: Fixed
#Status: New
#Uncommet Labels and/or add labels to the list (comma or space separate) if you want update/add Labels
#Labels: Type-Defect Priority-Medium
#Labels: Type-Defect Priority-High
#Labels: Type-Defect Priority-Critical
#Labels: Type-Enhancement Priority-Medium
#Labels: Type-Enhancement Priority-Low
#Labels: Type-Enhancement Priority-High
 
#Comment text for the issue tracker goes here

FixIssue.tmpl

#commit comment here
 
#Complete next line with issue number
Fixes issue
 
#Comment text for the issue tracker goes here

The same thing should be possible also with svn and other SCM.

Hoping it could help some other people enjoying this google code feature developing open source code during their trips :)

Have fun!

 
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • DZone
  • Reddit
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Slashdot
  • Technorati
  • YahooMyWeb
  • LinkedIn
  • StumbleUpon
  • TwitThis
  • Wikio

Writing an irc bot for svn commit notification

October 15, 2009 – 1:40 pm by Stefano MAESTRI
Share

Recently I’ve started working with a new team. Since we are based in 2 different site a bit far each other we are using extensively an IRC channel to communicate.

We are using subversion as SCM and we need to keep all members of the team up to date about svn commits. The solution I’ve put in place during an insomniac night in an hotel is a post-commit hook invoking an irc bot script written in perl connecting to the server and shotting a message there. Quite simple, and it is taking its goal.

In $SVN_REPOSITORY/hooks edit and make executable the file post-commit

#!/bin/sh
 
REPOS="$1"
TXN="$2"
SVNLOOK=/usr/bin/svnlook
 
# get last commit message
COMMIT=`$SVNLOOK log "$REPOS"`
USER=`whoami`
 
# call bot with arguments reposname, revison and commit message in one string
/usr/bin/perl /usr/local/bin/svn_irc_bot.pl "$USER $REPOS r$TXN: $COMMIT"
 
# all checks passed, so allow the commit
exit 0

then edit and make executable the file /usr/local/bin/svn_irc_bot.pl

#!/usr/bin/perl -w
#svn_irc_bot.pl
 
my $server = ""; #put here your address
my $port = 6667;
my $nick = "svn_bot";
my $ident = "svn_bot";
my $realname = "svn_bot";
my $chan = "#YourChannel";#put here your channel name
my $pass = "svn_bot";
my $svn_commit = $ARGV[0];
use IO::Socket;
 
my $irc=IO::Socket::INET->new(
PeerAddr=>$server,
PeerPort=>$port,
Proto=>'tcp') or die "DEAD!";
 
#print $irc "USER $ident $ident $ident $ident :$realname\n";
print $irc "NICK $nick\r\n";
#print $irc "PRIVMSG nickserv/@/services.dal.net :identify $pass\n";
print $irc "USER $ident 8 * :Perl IRC Hacks Robot\r\n";
 
print $irc "join $chan\n";
 
while(my $in = <$irc>)
{
if($in=~/004/)
{
print $irc "PRIVMSG $chan :$svn_commit \n";
last;
}
 
if($in=~/^PING(.*)$/i)
{
print $irc "PONG :$1\n";
}
}
close($irc);
#EOF

If user named “fooUser” make a commit on “fooRepository” for release 409 with a comment like “this is a fooComment” on irc channel you will get something like:

<svn_bot> fooUser fooRepository r409: this is a fooComment

I took the base of code here. Then I’ve modified it a little to get result I like.

 
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • DZone
  • Reddit
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Slashdot
  • Technorati
  • YahooMyWeb
  • LinkedIn
  • StumbleUpon
  • TwitThis
  • Wikio

Wise 1.1 released

August 10, 2009 – 4:32 pm by Stefano MAESTRI
Share

A new quite cool release of wise-core, my JBoss.org project.

At the moment here you have a cross post of Wise’s blog:

http://jbosswise.blogspot.com/2009/08/wise-11-released.html

 
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • DZone
  • Reddit
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Slashdot
  • Technorati
  • YahooMyWeb
  • LinkedIn
  • StumbleUpon
  • TwitThis
  • Wikio

Analysing jar dependencies

July 18, 2009 – 7:50 pm by Alessio SOLDANO
Share

Something like 2 months ago I wrote a post on how different classloaders can potentially cause you problems if you’re not that careful on where your libs are loaded from. Well, I’ve just had to face another issue of that type, with a library of mine loaded from the bootstrap classloader and referencing a class from servlet API that I don’t want to be loaded by that classloader too. The easy solution of course would have been to pull my lib out of the endorsed dir (the one the bootstrap classloader loads libs from), but how could I be sure that I did not break anything in my app? Besides running tests, I finally decided to give JBoss Tattletale a try… I saw all the hype around it when it was released some month ago, but I did not have the chance to use it for a practical issue before.

Well, in less than five minutes I checked out he project, built it and ran it against my endorsed lib dir. I got a report and some graphs basically showing no libraries in that dir (hence loaded by the bootstrap classloader) where directly depending on my library, thus it’s safe to pull it out of the endorsed dir. The easy solution was indeed OK and thanks to this tool I have a theoretical proof of that ;-)

Take a look at JBoss Tattletale, it’s really a cool tool. Perhaps you can start from its author’s blog: http://blog.hibernate.org/11166.lace

 
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • DZone
  • Reddit
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Slashdot
  • Technorati
  • YahooMyWeb
  • LinkedIn
  • StumbleUpon
  • TwitThis
  • Wikio

java.lang.NoClassDefFoundError and the bootstrap classloader

May 26, 2009 – 3:51 pm by Alessio SOLDANO
Share

Seasoned java developers know that the infamous java.lang.NoClassDefFoundError you can get at runtime might be due to a lot of different issues, the most trivial being libraries missing in classpath.

Of course tracking down the real problem might result quite more complex when multiple classloaders are involed. Things get even more subtle when the bootstrap classloader comes into play ;-)

I usually deal with a project requiring a couple of libraries to be installed to and loaded from a location specified when providing the virtual machine with the endorsed dir parameter (-Dendorsed.dirs=my_endorsed_dir). I’m not spending a lot of words on the reason for doing so, it should be enought to know I need to overwrite some classes already shipped with the JDK.

As you know the classes in libraries added to the endorsed dirs are loaded by the bootstrap classloader, before the system classloaders do their job with the other classes.

Yesterday I was adding a new API (interfaces only) to another module (ModuleB) of my project. After that I implemented the interfaces in my ModuleA, which builds to a jar that goes to endorsed dir. Compile phase all green, but NoClassDefFoundError at runtime.

Exception in thread “main” java.lang.NoClassDefFoundError: it/javalinux/blog/Foo
at java.lang.ClassLoader.findBootstrapClass(Native Method)
at java.lang.ClassLoader.findBootstrapClass0(ClassLoader.java:891)
at java.lang.ClassLoader.loadClass(ClassLoader.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

The classpath is OK. The libraries contain all the classes, including the Foo class. What’s happening then?

Well, I definitely did a mistake, ie. I put the Foo class in ModuleA while it implements FooInterface from ModuleB. Nothing dangerous in that besides *only one* of them is loaded by the bootclassloader, hence the NoClassDefFoundError.The Foo class is indeed available, but it’s loaded by another classloader.

So, aways think about the way your project classes are loaded and… look carefully at the exception dump, even in the java.lang.Classloader package section ;-)

 
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • DZone
  • Reddit
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Slashdot
  • Technorati
  • YahooMyWeb
  • LinkedIn
  • StumbleUpon
  • TwitThis
  • Wikio