Files
modules/contrib/pre-commit
Kent Mein e0af17e7fc Added a hook script to automatically bump the version #
Of modules to the next commit # so that
next time we commit changes it will be updated.  This is a little bit
tricky because of the way pre-commit's work.  (It's making the
change for the next commit not the current one).
2014-02-14 14:12:18 -06:00

42 lines
1021 B
Perl
Executable File

#!/usr/bin/perl
# This file is a pre-commit git hook to automatically update the
# MODULES_CURRENT_VERSION in modulecmd.tcl
# Put this in modules/.git/hooks/pre-commit and make it executable.
use strict;
use warnings;
use Cwd 'abs_path';
my ($ROOT, $OUTFILE, $INFILE, $line, $value);
$ROOT = abs_path($0);
print "ROOT BASE = $ROOT\n";
$ROOT =~ /(.*)\.git\/hooks\/pre-commit/;
$ROOT = $1;
print "ROOT = $ROOT\n";
$value = `cd $ROOT;git rev-list HEAD --count`;
$value ++;
$value ++;
system("cp $ROOT/modulecmd.tcl $ROOT/modulecmd.tmp");
unlink("$ROOT/modulecmd.tcl");
open($OUTFILE, ">","$ROOT/modulecmd.tcl") or die
"Unable to open $ROOT/modulecmd.tcl";
open($INFILE, "<","$ROOT/modulecmd.tmp") or die
"Unable to open $ROOT/modulecmd.tmp";
while(<$INFILE>) {
$line = $_;
if ($line =~ /set MODULES_CURRENT_VERSION (.*)/) {
print $OUTFILE "set MODULES_CURRENT_VERSION 1.$value\n";
} else {
print $OUTFILE $line;
}
}
close $OUTFILE;
unlink("$ROOT/modulecmd.tmp");
system("chmod 755 $ROOT/modulecmd.tcl");