Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

+ -

  Comment: Make it work at any directory. (Score 1) on 2008.12.22 15:17

by motoster on 2008.12.22 15:17 (#66585)
Attached to: Vim: source control diffs
Hello, Ovid.

The fact that your script only works if the cwd is file's directory kind of frustate me, as I normally work on the root dir of the project.

Here is a patch to make it work wherever the cwd is.

--- svn_revisions.pl.ovid    2008-12-22 10:59:09.000000000 -0400
+++ svn_revisions.pl    2008-12-22 11:12:55.000000000 -0400
@@ -2,6 +2,7 @@

use strict;
use warnings;
+use File::Basename qw(dirname);

my $file = shift || die "You must supply a filename to $0";

@@ -28,7 +29,8 @@
}

sub branch_name {
-    chomp(my @svn_info = qx(svn info .));
+    my $dir = dirname($file);
+    chomp(my @svn_info = qx(svn info $dir));
     my ($branch_name) = $svn_info[1] =~ m{/([^/]+)\z};
     return $branch_name;
}
Read More 2 comments
Comments: 2