File: config_rev.pl

package info (click to toggle)
verilog-mode 20161124.fd230e6-2
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid, stretch
  • size: 3,764 kB
  • ctags: 5,143
  • sloc: lisp: 12,430; perl: 293; makefile: 146; sh: 35; fortran: 2
file content (35 lines) | stat: -rwxr-xr-x 1,167 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/perl -w
# DESCRIPTION: Query's git to get version number
######################################################################
#
# Copyright 2005-2013 by Wilson Snyder.  This is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
#
######################################################################

my $dir = $ARGV[0]; defined $dir or die "%Error: No directory argument,";
chdir $dir;
my $file = $ARGV[1]; defined $file or die "%Error: No file argument,";

my $rev = 'UNKNOWN_REV';
my $data = `git log --pretty=format:'%ad-%h' --date=short -1 $file`;
if ($data =~ /(^20.*)/i) {
    $rev = $1;
}

$data = `git status $file`;
if ($data =~ /Changed but not updated/i
    || $data =~ /Changes to be committed/i) {
    $rev .= "-mod";
}

# Filter the code
my $wholefile = join('',<STDIN>);
$wholefile =~ s/__VMVERSION__-__VMREVISION__/$rev/mg;
$wholefile =~ s/__VMPACKAGER__/vpo/mg;
print $wholefile;

# Die after the print, so at least the header has good contents
$rev =~ /UNKNOWN/ and warn "%Warning: No git revision found,";