mkversion: add --undecided

This commit is contained in:
Philippe Teuwen 2020-05-21 11:50:03 +02:00
parent 53cb36447f
commit 4382f8c9be
2 changed files with 10 additions and 7 deletions

View file

@ -18,7 +18,7 @@ my $fullgitinfo = 'RRG/Iceman';
my $ctime; my $ctime;
# GIT status 0 = dirty, 1 = clean , 2 = undecided # GIT status 0 = dirty, 1 = clean , 2 = undecided
my $clean = 2; my $clean = 2;
my $undecided = (defined $ARGV[0]) && ($ARGV[0] =~ '--undecided');
# Do we have acces to git command? # Do we have acces to git command?
####### #######
# solves some bug on macos i.e: # solves some bug on macos i.e:
@ -37,8 +37,9 @@ if ( defined($commandGIT) ) {
# now avoiding the "fatal: No names found, cannot describe anything." error by fallbacking to abbrev hash in such case # now avoiding the "fatal: No names found, cannot describe anything." error by fallbacking to abbrev hash in such case
my $gitversion = `git describe --dirty --always`; my $gitversion = `git describe --dirty --always`;
my $gitbranch = `git rev-parse --abbrev-ref HEAD`; my $gitbranch = `git rev-parse --abbrev-ref HEAD`;
$clean = $gitversion =~ '-dirty' ? 0 : 1; if (not $undecided) {
$clean = $gitversion =~ '-dirty' ? 0 : 1;
}
if ( defined($gitbranch) and defined($gitversion) ) { if ( defined($gitbranch) and defined($gitversion) ) {
$fullgitinfo = $fullgitinfo.'/'. $gitbranch . '/' . $gitversion; $fullgitinfo = $fullgitinfo.'/'. $gitbranch . '/' . $gitversion;

View file

@ -21,10 +21,12 @@ if [ "$commandGIT" != "" ]; then
# now avoiding the "fatal: No names found, cannot describe anything." error by fallbacking to abbrev hash in such case # now avoiding the "fatal: No names found, cannot describe anything." error by fallbacking to abbrev hash in such case
gitversion=$(git describe --dirty --always) gitversion=$(git describe --dirty --always)
gitbranch=$(git rev-parse --abbrev-ref HEAD) gitbranch=$(git rev-parse --abbrev-ref HEAD)
if [ "$gitversion" != "${gitversion%-dirty}" ]; then if [ "$1" != "--undecided" ]; then
clean=0 if [ "$gitversion" != "${gitversion%-dirty}" ]; then
else clean=0
clean=1 else
clean=1
fi
fi fi
if [ "$gitbranch" != "" ] && [ "$gitversion" != "" ]; then if [ "$gitbranch" != "" ] && [ "$gitversion" != "" ]; then
fullgitinfo="${fullgitinfo}/${gitbranch}/${gitversion}" fullgitinfo="${fullgitinfo}/${gitbranch}/${gitversion}"