Skip to content

Commit a13ac69

Browse files
committedJan 17, 2025·
DBIXS_REVISION from git instead of svn
The svn version was "static" as in "dead" as of the move to git. Don't know if the new situation really adds value, but at least it now has more value than the previous version
1 parent e7543eb commit a13ac69

File tree

2 files changed

+23
-47
lines changed

2 files changed

+23
-47
lines changed
 

‎dbixs_rev.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
/* Fri Jul 13 13:32:02 2012 */
2-
/* Mixed revision working copy (15349:15353) */
3-
#define DBIXS_REVISION 15349
1+
/* Fri Jan 17 15:09:59 2025 */
2+
#define DBIXS_REVISION 1698

‎dbixs_rev.pl

+21-44
Original file line numberDiff line numberDiff line change
@@ -5,49 +5,26 @@
55

66
my $dbixs_rev_file = "dbixs_rev.h";
77

8-
my $is_make_dist;
9-
my $svnversion;
10-
11-
if (is_dbi_svn_dir(".")) {
12-
$svnversion = `svnversion -n`;
13-
}
14-
elsif (is_dbi_svn_dir("..")) {
15-
# presumably we're in a subdirectory because the user is doing a 'make dist'
16-
$svnversion = `svnversion -n ..`;
17-
$is_make_dist = 1;
18-
}
19-
else {
20-
# presumably we're being run by an end-user because their file timestamps
21-
# got messed up
22-
print "Skipping regeneration of $dbixs_rev_file\n";
23-
utime(time(), time(), $dbixs_rev_file); # update modification time
8+
sub skip_update {
9+
my $reason = shift;
10+
print "Skipping regeneration of $dbixs_rev_file: ", $reason, "\n";
11+
utime (time (), time (), $dbixs_rev_file); # update modification time
2412
exit 0;
25-
}
26-
27-
my @warn;
28-
die "Neither current directory nor parent directory are an svn working copy\n"
29-
unless $svnversion and $svnversion =~ m/^\d+/;
30-
push @warn, "Mixed revision working copy ($svnversion:$1)"
31-
if $svnversion =~ s/:(\d+)//;
32-
push @warn, "Code modified since last checkin"
33-
if $svnversion =~ s/[MS]+$//;
34-
warn "$dbixs_rev_file warning: $_\n" for @warn;
35-
die "$0 failed\n" if $is_make_dist && @warn;
36-
37-
write_header($dbixs_rev_file, DBIXS_REVISION => $svnversion, \@warn);
38-
39-
sub write_header {
40-
my ($file, $macro, $version, $comments_ref) = @_;
41-
open my $fh, ">$file" or die "Can't open $file: $!\n";
42-
unshift @$comments_ref, scalar localtime(time);
43-
print $fh "/* $_ */\n" for @$comments_ref;
44-
print $fh "#define $macro $version\n";
45-
close $fh or die "Error closing $file: $!\n";
46-
print "Wrote $macro $version to $file\n";
47-
}
48-
49-
sub is_dbi_svn_dir {
50-
my ($dir) = @_;
51-
return (-d "$dir/.svn" && -f "$dir/MANIFEST.SKIP");
52-
}
13+
} # skip_update
5314

15+
-d ".git" or skip_update ("No git env");
16+
17+
my @n = eval { qx{git log --pretty=oneline} };
18+
@n or skip_update ("Git log was empty");
19+
20+
open my $fh, ">$dbixs_rev_file" or die "Can't open $dbixs_rev_file: $!\n";
21+
print $fh "/* ", scalar localtime, " */\n";
22+
23+
chomp (my @st = qx{git status -s --show-stash});
24+
print $fh "/* $_ */\n" for grep { !m/\b$dbixs_rev_file\b/ } @st;
25+
26+
my $def = "DBIXS_REVISION";
27+
my $rev = scalar @n;
28+
print $fh "#define $def $rev\n";
29+
close $fh or die "Error closing $dbixs_rev_file: $!\n";
30+
print "Wrote $def $rev to $dbixs_rev_file\n";

0 commit comments

Comments
 (0)
Please sign in to comment.