Archive for the 'Tools' Category

Cat with line numbers

“cat” has always been an easy way to quickly look up a relatively small text file. However sometimes there is a need to have line numbers displayed too.

This is how it is done with cat:

cat -n file.txt

or even

cat file.txt | nl

FogBugz and Kiln World Tour Talk by Joel Spolsky

Joel Spolsky’s talk on the latest features in FogBugz 8 and Kiln 2.
The same awesome talk I was able to attended last October in ATL. He not only showed all great features and benefits of FogBugz and Kiln but made fun of traditional slides and presentations.

Subversion: How to require comments

Normally developers agree and promise to write comments for each commit. Often the comments are still not written though.

Subversion pre-commit hook allows to make comments required. For instance file pre-commit.tmpl contains a sample script which will reject commits if no log message is supplied, or the message is too short. However it doesn’t report back any error message (i.e. a generic “commit failed” is returned to SVN client), and there is no provision for making sure the comment is a minimum length.

Ryan Stille came up with excellent Perl script which does the job in more transparent way compare to the original shell script. It allows setting minimum length of the comment and custom error message when the message is absent or too short.

# config section
$minchars = 4;
$svnlook = '/usr/bin/svnlook';
$repos = $ARGV[0];
$txn = $ARGV[1];
$comment = `$svnlook log -t "$txn" "$repos"`;
if ( length($comment) == 0 ) {
  print STDERR "A comment is required!";
elsif ( length($comment) < $minchars ) {
  print STDERR "Comment must be at least $minchars characters.";

Note that pre-commit.tmpl has to be renamed without the “.tmpl” on it and set as executable.

Of course there is no guarantee that all comments will be relevant. But at least it could work as reminder that the comment is needed right now for current commit.