Support X.Y.Z.D Perl versions
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/cdbf4ad8 Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/cdbf4ad8 Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/cdbf4ad8 Branch: refs/heads/master Commit: cdbf4ad857dafe81c71187c0de4167dc1a2487d6 Parents: 0ba3c4b Author: Nick Wellnhofer <[email protected]> Authored: Tue Oct 4 14:03:30 2016 +0200 Committer: Nick Wellnhofer <[email protected]> Committed: Tue Oct 4 14:03:30 2016 +0200 ---------------------------------------------------------------------- devel/bin/update_version | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/cdbf4ad8/devel/bin/update_version ---------------------------------------------------------------------- diff --git a/devel/bin/update_version b/devel/bin/update_version index aa44a9b..929d965 100755 --- a/devel/bin/update_version +++ b/devel/bin/update_version @@ -26,28 +26,33 @@ my $usage = "$0 version\n"; my $version = shift(@ARGV) or die $usage; # standardize version strings -my ( $x, $y, $z, $dev ); +my ( $x, $y, $z, $dev_sep, $dev ); if ( $version =~ m/^(\d+)\.(\d+)\.(\d+)$/ ) { ( $x, $y, $z, $dev ) = ( $1, $2, $3, 0 ); } -elsif ( $version =~ m/^(\d+)\.(\d+)\.(\d+)_(\d+)$/ ) { - ( $x, $y, $z, $dev ) = ( $1, $2, $3, $4 ); +elsif ( $version =~ m/^(\d+)\.(\d+)\.(\d+)([._])(\d+)$/ ) { + ( $x, $y, $z, $dev_sep, $dev ) = ( $1, $2, $3, $4, $5 ); } elsif ( $version =~ m/^(\d+)\.(\d\d\d)(\d\d\d)$/ ) { ( $x, $y, $z, $dev ) = ( int($1), int($2), int($3), 0 ); } -elsif ( $version =~ m/^(\d+)\.(\d\d\d)(\d\d\d)_(\d\d\d)$/ ) { - ( $x, $y, $z, $dev ) = ( int($1), int($2), int($3), int($4) ); +elsif ( $version =~ m/^(\d+)\.(\d\d\d)(\d\d\d)(_)?(\d\d\d)$/ ) { + ( $x, $y, $z, $dev_sep, $dev ) + = ( int($1), int($2), int($3), defined($4) ? $4 : '.', int($5) ); } else { die "Unknown version syntax. Try X.Y.Z or X.YYYZZZ\n"; } my $x_y_z_version = sprintf( "%d.%d.%d", $x, $y, $z ); my $x_y_z_d_version = $dev - ? sprintf( "%d.%d.%d_%d", $x, $y, $z, $dev ) + ? $dev_sep eq '_' + ? sprintf( "%d.%d.%d_%d", $x, $y, $z, $dev ) + : sprintf( "%d.%d.%d.%d", $x, $y, $z, $dev ) : sprintf( "%d.%d.%d", $x, $y, $z ); my $x_yyyzzz_version = $dev - ? sprintf( "%d.%03d%03d_%03d", $x, $y, $z, $dev ) + ? $dev_sep eq '_' + ? sprintf( "%d.%03d%03d_%03d", $x, $y, $z, $dev ) + : sprintf( "%d.%03d%03d%03d", $x, $y, $z, $dev ) : sprintf( "%d.%03d%03d", $x, $y, $z ); print "Using version: $x_y_z_version ( $x_yyyzzz_version )\n";
