diff --git a/utils/version.pl b/utils/version.pl index 4a0c6ffc1..6177e4b57 100644 --- a/utils/version.pl +++ b/utils/version.pl @@ -6,8 +6,11 @@ use warnings; use Data::Dumper; # Version changes: -# v[x].[y].[z] -- Main version number -# v[x].[y].[z]-test-[branchstring]-[num] -- test/branch/devel version number +# [x].[y].[z] -- Main version number +# XXX old +# [x].[y].[z]-test-[branchstring]-[num] -- test/branch/devel version number +# XXX new +# [x].[y].[z]-[num]+[branchname] # on main/master: Biggest version so far, increment by occuring changes # on other branches: find version; be it branch string, old format or main version number; # increments from there. Increment version number, but on global conflict use new version number @@ -133,8 +136,10 @@ if($par{'h'}) { exit 0 } +my $branchNameEscaped = `$par{vcsbranch}`; +chomp $branchNameEscaped; if($par{autokind}) { - my $branch = `$par{vcsbranch}`; + my $branch = $branchNameEscaped; my @rules = split /,/, $par{autokind}; RULES: { for my $r(@rules) { @@ -151,7 +156,7 @@ if($par{autokind}) { warn "$0: No autokind rule matches; leaving the kind unchanged.\n" } } - +$branchNameEscaped =~ s/[^0-9a-zA-Z]+/-/g; if($par{'v'}) { warn "VERBOSE: Parameters\n"; @@ -232,6 +237,7 @@ sub parseVersion { $v=~m#^(?
[a-z]*)(?[0-9]+)\.(? [0-9]+)$# || $v=~m#^(? [a-z]*)(?[0-9]+)\.(? [0-9]+)\.(? [0-9]+)$# || $v=~m#^(?
[a-z]*)(?[0-9]+)\.(? [0-9]+)\.(? [0-9]+)-test-(?
(? [a-z]+)-?(? [0-9\.]+))$# || + $v=~m#^(? [a-z]*)(?[0-9]+)\.(? [0-9]+)\.(? [0-9]+)-(?
(? [0-9\.]+)\+(? [0-9A-Za-z\-]+))$# || # [x].[y].[z]-[num]+[branchname] $v=~m#^(? [a-z]*)(?[0-9]+)\.(? [0-9]+)\.(? [0-9]+)-(?
.*)$# ) { %cap = %+ @@ -288,7 +294,7 @@ sub vsCompare { #for($v, $w) { # $_ = parseVersion($_) unless ref $_; #} - if('v' eq $v->{prefix} and 'v' eq $w->{prefix}) { + if($v->{prefix}=~m/^v?$/ and $w->{prefix}=~m/^v?$/) { return( ($v->{major} // 0) <=> ($w->{major} // 0) || ($v->{minor} // 0) <=> ($w->{minor} // 0) || @@ -297,9 +303,9 @@ sub vsCompare { ($v->{branchversion} // 0) <=> ($w->{branchversion} // 0) || ($v->{subpatch} // '') cmp ($w->{subpatch} // '') ) - } elsif('v' eq $v->{prefix} and 'v' ne $w->{prefix}) { + } elsif($v->{prefix}=~m/^v?$/ and !$w->{prefix}=~m/^v?$/) { return 1; - } elsif('v' ne $v->{prefix} and 'v' eq $w->{prefix}) { + } elsif(!$v->{prefix}=~m/^v?$/ and $w->{prefix}=~m/^v?$/) { return -1; } else { return vsStringDebug($v) cmp vsStringDebug($w) @@ -339,13 +345,21 @@ sub vsJustVersion { sub vsTestVersion { my $v = shift; + # [x].[y].[z]-[num]+[branchname] my $ret = - 'v' . ($v->{major} // 0) . "." . ($v->{minor} // 0) . "." . - ($v->{patch} // 0) . "-test-" . - ($v->{branchname} // 'a') . - ($v->{branchversion} // '0.0.0'); + ($v->{patch} // 0) . "-" . + ($v->{branchversion} // '0.0.0') . "+" . + $branchNameEscaped; + # old version format + #my $ret = + #'v' . + #($v->{major} // 0) . "." . + #($v->{minor} // 0) . "." . + #($v->{patch} // 0) . "-test-" . + #($v->{branchname} // 'a') . + #($v->{branchversion} // '0.0.0'); return $ret } @@ -385,8 +399,9 @@ VERSION: for my $v(@versions) { # $tag=$1; # last VERSION #} - if($v->{meta}=~m#tag\s*:\s*([vtd]b?[0-9\.]+(?:-.*)?)\)#) { + if($v->{meta}=~m#tag\s*:\s*((?:[vtd]|db|)[0-9\.]+(?:[a-zA-Z\-\+0-9\.]*)?)[\),]#) { $v->{version} = $1; + warn "$0: Found version number in log: '$v->{version}'\n" if $par{v}; push @versionPast, $v->{version} } next if $v->{subject}=~m#^\s*(?:Merge (?:branch|remote)|Revert )#; @@ -444,8 +459,11 @@ for my $r(reverse @change) { my @allVersions = split /\n/, `$par{vcstags}`; -my @sortAll = sort {vsCompare($b, $a)} @allVersions; -my @sortSee = sort {vsCompare($b, $a)} @versionPast; +#my @sortAll = sort {vsCompare($b, $a)} @allVersions; +#my @sortSee = sort {vsCompare($b, $a)} @versionPast; +# we want the latest version and do not sort +my @sortAll = @allVersions; +my @sortSee = @versionPast; #print "all: $sortAll[0] -- see: $sortSee[0]\n"; # #print vsString($tag), "\n"; @@ -479,7 +497,7 @@ sub justVersionInc { my $newVersion = undef; if($mainVersion) { - $newVersion = "v" . justVersionInc($highStart, \%reactCollect); + $newVersion = justVersionInc($highStart, \%reactCollect); } else { my $v = parseVersion($highStart); if(exists $v->{branchname}) { @@ -589,7 +607,7 @@ if($par{changelog}) { my $preVersion = ''; if(defined $sects[0] and defined $sects[0][0] and $sects[0][0]=~m/^##\s*\[([^\]\[]+)\]\(/) { $preVersion = $1; - $preVersion =~ s#^v?#v#; + # $preVersion =~ s#^v?#v#; } my $today = do { my @time = localtime; @@ -618,11 +636,3 @@ All notable changes to this project will be documented in this file. See [standa - - - - - - - -