Skip to content

Commit a791382

Browse files
committed
add git filters for version printing
1 parent a231e14 commit a791382

File tree

5 files changed

+95
-4
lines changed

5 files changed

+95
-4
lines changed

.git_filters/rcs-keywords.clean

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/perl -p
2+
#
3+
# @brief Git filter to implement rcs keyword expansion as seen in cvs and svn.
4+
# @author Martin Turon
5+
#
6+
# Copyright (c) 2009-2011 Turon Technologies, Inc. All rights reserved.
7+
8+
s/(\$Id)((::)*)([^\$]*)\$/TR($1,$4,$2)/eo;
9+
s/(\$Date)((::)*)([^\$]*)\$/TR($1,$4,$2)/eo;
10+
s/(\$Author)((::)*)([^\$]*)\$/TR($1,$4,$2)/eo;
11+
s/(\$Source)((::)*)([^\$]*)\$/TR($1,$4,$2)/eo;
12+
s/(\$File)((::)*)([^\$]*)\$/TR($1,$4,$2)/eo;
13+
s/(\$Rev)((::)*)([^\$]*)\$/TR($1,$4,$2)/eo;
14+
s/(\$Revision)((::)*)([^\$]*)\$/TR($1,$4,$2)/eo;
15+
16+
sub TR{
17+
my ($pre,$from,$fix)=@_;
18+
return $pre.$fix.(" " x length($from)).'$';
19+
}

.git_filters/rcs-keywords.smudge

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/usr/bin/perl
2+
#
3+
# @brief Git filter to implement rcs keyword expansion as seen in cvs and svn.
4+
# @author Martin Turon
5+
#
6+
# Usage:
7+
# .git_filter/rcs-keywords.smudge file_path < file_contents
8+
#
9+
# To add keyword expansion:
10+
# <project>/.gitattributes - *.c filter=rcs-keywords
11+
# <project>/.git_filters/rcs-keywords.smudge - copy this file to project
12+
# <project>/.git_filters/rcs-keywords.clean - copy companion to project
13+
# ~/.gitconfig - add [filter] lines below
14+
#
15+
# [filter "rcs-keywords"]
16+
# clean = .git_filters/rcs-keywords.clean
17+
# smudge = .git_filters/rcs-keywords.smudge %f
18+
#
19+
# Copyright (c) 2009-2011 Turon Technologies, Inc. All rights reserved.
20+
21+
$path = shift;
22+
$path =~ /.*\/(.*)/;
23+
$filename = $1;
24+
25+
if (0 == length($filename)) {
26+
$filename = $path;
27+
}
28+
29+
# Need to grab filename and to use git log for this to be accurate.
30+
$rev = `git log --date=iso -- | head -n 3`;
31+
$rev =~ /^Author:\s*(.*)\s*$/m;
32+
$author = $1;
33+
$author =~ /\s*(.*)\s*<.*/;
34+
$name = $1;
35+
$rev =~ /^Date:\s*(.*)\s*$/m;
36+
$date = $1;
37+
$rev =~ /^commit (.*)$/m;
38+
$ident = $1;
39+
$shortident = substr($ident,0, 6);
40+
41+
while (<STDIN>) {
42+
s/\$Date(((::)*)[^\$]*)\$/TR("\$Date",$1,$date,$2,"\$")/eo;
43+
s/\$Author(((::)*)[^\$]*)\$/TR("\$Author",$1,$author,$2,"\$")/eo;
44+
s/\$Id(((::)*)[^\$]*)\$/TR("\$Id",$1,"$filename | $date | $name",$2,"\$")/eo;
45+
s/\$File(((::)*)[^\$]*)\$/TR("\$File",$1,$filename,$2,"\$")/eo;
46+
s/\$Source(((::)*)[^\$]*)\$/TR("\$Source",$1,$path,$2,"\$")/eo;
47+
s/\$Rev(((::)*)[^\$]*)\$/TR("\$Rev",$1,$shortident,$2,"\$")/eo;
48+
s/\$Revision(((::)*)[^\$]*)\$/TR("\$Revision",$1,$ident,$2,"\$")/eo;
49+
} continue {
50+
print or die "-p destination: $!\n";
51+
}
52+
53+
sub TR{
54+
my ($pre,$from,$to,$fix,$post)=@_;
55+
return $pre.$to.$post if($fix eq '');
56+
57+
$pre.=$fix;
58+
if(length($from)<length($to)+length($fix)){
59+
$to=substr($to,0,length($from)-length($fix));
60+
}else{
61+
$to.=' ' x (length($from)-length($to)-length($fix));
62+
}
63+
return $pre.$to.$post;
64+
}

.gitattributes

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# .gitattributes
2+
# Map file extensions to git filters
3+
4+
*.h filter=rcs-keywords
5+
*.c filter=rcs-keywords
6+
*.cc filter=rcs-keywords
7+
*.m filter=rcs-keywords
8+
*.mm filter=rcs-keywords

README.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Department of Bioengineering
77
Northeastern University
88
360 Huntington Ave, Boston, MA 02115
9-
*Version: 1.9.0 (Century Egg)
9+
*Version: 1.9.5 (Century Egg)
1010
*License: GPL v2 or later (see COPYING)
1111
(this license does not cover the binaries under the bin/
1212
directory, see Section III for more details)

iso2meshver.m

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
% -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
2121
%
2222

23-
major=2;
24-
minor=0;
25-
patchnum=0;
23+
major=1;
24+
minor=9;
25+
patchnum=5;
2626
extra='$Rev:: $';
2727
extra=regexprep(extra,'[\s$:]', '');
2828

0 commit comments

Comments
 (0)