File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / quagga / lib / gitversion.pl
Revision 1.1: download - view: text, annotated - select for diffs - revision graph
Sun Jul 21 23:54:39 2013 UTC (10 years, 11 months ago) by misho
CVS tags: MAIN, HEAD
Initial revision

    1: #!/usr/bin/perl -w
    2: use strict;
    3: 
    4: my $dir = shift;
    5: chdir $dir || die "$dir: $!\n";
    6: 
    7: my $gitdesc = `git describe --always --dirty || echo -- \"0-gUNKNOWN\"`;
    8: chomp $gitdesc;
    9: my $gitsuffix = ($gitdesc =~ /([0-9a-fA-F]{7}(-dirty)?)$/) ? $1 : "-gUNKNOWN";
   10: 
   11: printf STDERR "git suffix: %s\n", $gitsuffix;
   12: printf "#define GIT_SUFFIX \"%s\"\n", $gitsuffix;
   13: 
   14: my $gitcommit = `git log -1 --format=\"%H\" || echo DEADBEEF`;
   15: chomp $gitcommit;
   16: open(BRANCHES, "git branch -a -v --abbrev=40|") || die "git branch: $!\n";
   17: my @names = ();
   18: while (<BRANCHES>) {
   19: 	chomp $_;
   20: 	if (/\s+(.*?)\s+$gitcommit/) {
   21: 		my $branch = $1;
   22: 		if ($branch =~ /^remotes\/(.*?)(\/.*)$/) {
   23: 			my $path = $2;
   24: 			my $url = `git config --get "remote.$1.url"`;
   25: 			chomp $url;
   26: 			$url =~ s/^(git:|https?:|git@)\/\/github\.com/github/i;
   27: 			$url =~ s/^(ssh|git):\/\/git\.sv\.gnu\.org\/srv\/git\//savannah:/i;
   28: 			$url =~ s/^(ssh|git):\/\/git\.savannah\.nongnu\.org\//savannah:/i;
   29: 
   30: 			push @names, $url.$path;
   31: 		} else {
   32: 			push @names, 'local:'.$branch;
   33: 		}
   34: 	}
   35: }
   36: 
   37: printf STDERR "git branches: %s\n", join(", ", @names);
   38: 
   39: my $cr = "\\r\\n\\";
   40: printf <<EOF, $gitdesc, join($cr."\n\\t", @names);
   41: #define GIT_INFO "$cr
   42: This is a git build of %s$cr
   43: Associated branch(es):$cr
   44: \\t%s$cr
   45: "
   46: EOF
   47: 
   48: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>