Skip to content

Commit 1361d45

Browse files
bats: Introduce numeric_version function
1 parent 19b1d13 commit 1361d45

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

lib/containers/bats.pm

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ our @EXPORT = qw(
4040
install_gotestsum
4141
install_ncat
4242
mount_tmp_vartmp
43+
numeric_version
4344
patch_junit
4445
patch_sources
4546
run_command
@@ -623,17 +624,24 @@ sub bats_tests {
623624
return ($ret);
624625
}
625626

627+
sub numeric_version {
628+
my $version = shift;
629+
630+
# Sometimes version strings have a leading "v" or a trailing "-ce"
631+
# Strip leading & trailing non-digits from version
632+
$version =~ s/^\D+//;
633+
$version =~ s/\D+$//;
634+
return $version;
635+
}
636+
626637
sub patch_sources {
627638
my ($package, $branch, $tests_dir) = @_;
628639

629640
my $text = script_output("curl " . data_url("containers/patches.yaml"), quiet => 1);
630641
my $yaml = YAML::PP->new()->load_string($text);
631642
my $patches = $yaml->{$package} // {};
632643

633-
# Strip leading & trailing non-digits from version
634-
my $version = $branch;
635-
$version =~ s/^\D+//;
636-
$version =~ s/\D+$//;
644+
my $version = numeric_version($branch);
637645

638646
my @patches = split(/\s+/, get_var("GITHUB_PATCHES", ""));
639647
if (!@patches) {

0 commit comments

Comments
 (0)