From f2067bdb56d074a57aff5e125ad93f41b1a51cad Mon Sep 17 00:00:00 2001 From: Stephan Barth Date: Fri, 25 Oct 2024 15:48:19 +0200 Subject: [PATCH] build(.gitlab-ci/version.pl): Can now automatically determine the remote repository. --- .gitlab-ci/version.pl | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci/version.pl b/.gitlab-ci/version.pl index 7fa0e1324..8a2e277a7 100755 --- a/.gitlab-ci/version.pl +++ b/.gitlab-ci/version.pl @@ -70,6 +70,11 @@ my %parKinds = ( def=>'', help=>'Use this file name to write the changelog to, but use "changelog" to read the old changelog. If not set for both versions the parameter changelog is used.', }, + autovcsurl=>{ + arity=>1, + def=>q#git ls-remote --get-url origin | sed 's/[^@]*@\([^:]*\):\(.*\)\.git$/https:\/\/\1\/\2/'#, + help=>'Automated computation for vcsurl. If both values are set then vcsurl is used."', + }, vcsurl=>{ arity=>1, def=>'', @@ -163,6 +168,12 @@ for my $as(split /,/, $par{change}) { } } +if($par{autovcsurl} and not $par{vcsurl}) { + $par{vcsurl} = qx($par{autovcsurl}); + chomp $par{vcsurl}; + $par{vcsurl}=~s#/*$#/# +} + if($par{changelog} and not $par{vcsurl}) { die "Parameter 'changelog' given, but parameter 'vcsurl' is not. Please state the url of your repository for computation of a changelog.\n" } @@ -576,7 +587,7 @@ if($par{changelog}) { } #print Data::Dumper::Dumper(\%extend); my $preVersion = ''; - if($sects[0][0]=~m/^##\s*\[([^\]\[]+)\]\(/) { + if(defined $sects[0] and defined $sects[0][0] and $sects[0][0]=~m/^##\s*\[([^\]\[]+)\]\(/) { $preVersion = $1; $preVersion =~ s#^v?#v#; }