Merge branch '145-build-system-rewrite' into test

This commit is contained in:
Sarah Vaupel 2025-02-20 13:34:46 +01:00
commit 988dddc0a2

View File

@ -6,8 +6,11 @@ use warnings;
use Data::Dumper; use Data::Dumper;
# Version changes: # Version changes:
# v[x].[y].[z] -- Main version number # [x].[y].[z] -- Main version number
# v[x].[y].[z]-test-[branchstring]-[num] -- test/branch/devel 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 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; # 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 # increments from there. Increment version number, but on global conflict use new version number
@ -133,8 +136,10 @@ if($par{'h'}) {
exit 0 exit 0
} }
my $branchNameEscaped = `$par{vcsbranch}`;
chomp $branchNameEscaped;
if($par{autokind}) { if($par{autokind}) {
my $branch = `$par{vcsbranch}`; my $branch = $branchNameEscaped;
my @rules = split /,/, $par{autokind}; my @rules = split /,/, $par{autokind};
RULES: { RULES: {
for my $r(@rules) { for my $r(@rules) {
@ -151,7 +156,7 @@ if($par{autokind}) {
warn "$0: No autokind rule matches; leaving the kind unchanged.\n" warn "$0: No autokind rule matches; leaving the kind unchanged.\n"
} }
} }
$branchNameEscaped =~ s/[^0-9a-zA-Z]+/-/g;
if($par{'v'}) { if($par{'v'}) {
warn "VERBOSE: Parameters\n"; warn "VERBOSE: Parameters\n";
@ -232,6 +237,7 @@ sub parseVersion {
$v=~m#^(?<pre>[a-z]*)(?<ma>[0-9]+)\.(?<mi>[0-9]+)$# || $v=~m#^(?<pre>[a-z]*)(?<ma>[0-9]+)\.(?<mi>[0-9]+)$# ||
$v=~m#^(?<pre>[a-z]*)(?<ma>[0-9]+)\.(?<mi>[0-9]+)\.(?<p>[0-9]+)$# || $v=~m#^(?<pre>[a-z]*)(?<ma>[0-9]+)\.(?<mi>[0-9]+)\.(?<p>[0-9]+)$# ||
$v=~m#^(?<pre>[a-z]*)(?<ma>[0-9]+)\.(?<mi>[0-9]+)\.(?<p>[0-9]+)-test-(?<sp>(?<brn>[a-z]+)-?(?<brv>[0-9\.]+))$# || $v=~m#^(?<pre>[a-z]*)(?<ma>[0-9]+)\.(?<mi>[0-9]+)\.(?<p>[0-9]+)-test-(?<sp>(?<brn>[a-z]+)-?(?<brv>[0-9\.]+))$# ||
$v=~m#^(?<pre>[a-z]*)(?<ma>[0-9]+)\.(?<mi>[0-9]+)\.(?<p>[0-9]+)-(?<sp>(?<brv>[0-9\.]+)\+(?<brn>[0-9A-Za-z\-]+))$# || # [x].[y].[z]-[num]+[branchname]
$v=~m#^(?<pre>[a-z]*)(?<ma>[0-9]+)\.(?<mi>[0-9]+)\.(?<p>[0-9]+)-(?<sp>.*)$# $v=~m#^(?<pre>[a-z]*)(?<ma>[0-9]+)\.(?<mi>[0-9]+)\.(?<p>[0-9]+)-(?<sp>.*)$#
) { ) {
%cap = %+ %cap = %+
@ -288,7 +294,7 @@ sub vsCompare {
#for($v, $w) { #for($v, $w) {
# $_ = parseVersion($_) unless ref $_; # $_ = parseVersion($_) unless ref $_;
#} #}
if('v' eq $v->{prefix} and 'v' eq $w->{prefix}) { if($v->{prefix}=~m/^v?$/ and $w->{prefix}=~m/^v?$/) {
return( return(
($v->{major} // 0) <=> ($w->{major} // 0) || ($v->{major} // 0) <=> ($w->{major} // 0) ||
($v->{minor} // 0) <=> ($w->{minor} // 0) || ($v->{minor} // 0) <=> ($w->{minor} // 0) ||
@ -297,9 +303,9 @@ sub vsCompare {
($v->{branchversion} // 0) <=> ($w->{branchversion} // 0) || ($v->{branchversion} // 0) <=> ($w->{branchversion} // 0) ||
($v->{subpatch} // '') cmp ($w->{subpatch} // '') ($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; return 1;
} elsif('v' ne $v->{prefix} and 'v' eq $w->{prefix}) { } elsif(!$v->{prefix}=~m/^v?$/ and $w->{prefix}=~m/^v?$/) {
return -1; return -1;
} else { } else {
return vsStringDebug($v) cmp vsStringDebug($w) return vsStringDebug($v) cmp vsStringDebug($w)
@ -339,13 +345,21 @@ sub vsJustVersion {
sub vsTestVersion { sub vsTestVersion {
my $v = shift; my $v = shift;
# [x].[y].[z]-[num]+[branchname]
my $ret = my $ret =
'v' .
($v->{major} // 0) . "." . ($v->{major} // 0) . "." .
($v->{minor} // 0) . "." . ($v->{minor} // 0) . "." .
($v->{patch} // 0) . "-test-" . ($v->{patch} // 0) . "-" .
($v->{branchname} // 'a') . ($v->{branchversion} // '0.0.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 return $ret
} }
@ -385,8 +399,9 @@ VERSION: for my $v(@versions) {
# $tag=$1; # $tag=$1;
# last VERSION # 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; $v->{version} = $1;
warn "$0: Found version number in log: '$v->{version}'\n" if $par{v};
push @versionPast, $v->{version} push @versionPast, $v->{version}
} }
next if $v->{subject}=~m#^\s*(?:Merge (?:branch|remote)|Revert )#; 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 @allVersions = split /\n/, `$par{vcstags}`;
my @sortAll = sort {vsCompare($b, $a)} @allVersions; #my @sortAll = sort {vsCompare($b, $a)} @allVersions;
my @sortSee = sort {vsCompare($b, $a)} @versionPast; #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 "all: $sortAll[0] -- see: $sortSee[0]\n";
# #
#print vsString($tag), "\n"; #print vsString($tag), "\n";
@ -479,7 +497,7 @@ sub justVersionInc {
my $newVersion = undef; my $newVersion = undef;
if($mainVersion) { if($mainVersion) {
$newVersion = "v" . justVersionInc($highStart, \%reactCollect); $newVersion = justVersionInc($highStart, \%reactCollect);
} else { } else {
my $v = parseVersion($highStart); my $v = parseVersion($highStart);
if(exists $v->{branchname}) { if(exists $v->{branchname}) {
@ -589,7 +607,7 @@ if($par{changelog}) {
my $preVersion = ''; my $preVersion = '';
if(defined $sects[0] and defined $sects[0][0] and $sects[0][0]=~m/^##\s*\[([^\]\[]+)\]\(/) { if(defined $sects[0] and defined $sects[0][0] and $sects[0][0]=~m/^##\s*\[([^\]\[]+)\]\(/) {
$preVersion = $1; $preVersion = $1;
$preVersion =~ s#^v?#v#; # $preVersion =~ s#^v?#v#;
} }
my $today = do { my $today = do {
my @time = localtime; my @time = localtime;
@ -618,11 +636,3 @@ All notable changes to this project will be documented in this file. See [standa