From 30029e59548667bdea37e4d9b59df208daf7d2e2 Mon Sep 17 00:00:00 2001 From: eric Date: Sat, 7 Mar 2026 07:49:40 +0100 Subject: [PATCH] fix: release parser --- VERSION | 2 +- packages/repo-lib/lib.nix | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index a76fec0..4bf1cf5 100644 --- a/VERSION +++ b/VERSION @@ -1,3 +1,3 @@ -2.1.0 +3.0.0 stable 0 diff --git a/packages/repo-lib/lib.nix b/packages/repo-lib/lib.nix index 6de7054..5fda3ce 100644 --- a/packages/repo-lib/lib.nix +++ b/packages/repo-lib/lib.nix @@ -189,7 +189,31 @@ let NIXEOF ) export REPO_LIB_STEP_REGEX REPO_LIB_STEP_REPLACEMENT - perl -0pi -e 'my $regex = $ENV{"REPO_LIB_STEP_REGEX"}; my $template = $ENV{"REPO_LIB_STEP_REPLACEMENT"}; s/$regex/do { my $source = $_; my $result = $template; $result =~ s{\\([0-9]+)}{ my $index = $1; if ($index <= $#- && defined $-[$index] && $-[$index] >= 0) { substr($source, $-[$index], $+[$index] - $-[$index]); } else { ""; } }ge; $result; }gems;' "$target_path" + perl - "$target_path" <<'REPO_LIB_PERL_REPLACE' + use strict; + use warnings; + + my $path = shift @ARGV; + my $regex_src = $ENV{"REPO_LIB_STEP_REGEX"} // q{}; + my $template = $ENV{"REPO_LIB_STEP_REPLACEMENT"} // q{}; + + open my $in, q{<}, $path or die "failed to open $path: $!"; + local $/ = undef; + my $content = <$in>; + close $in; + + my $regex = qr/$regex_src/ms; + $content =~ s/$regex/ + my @cap = map { defined $_ ? $_ : q{} } ($1, $2, $3, $4, $5, $6, $7, $8, $9); + my $result = $template; + $result =~ s/\\([1-9])/$cap[$1 - 1]/ge; + $result; + /gems; + + open my $out, q{>}, $path or die "failed to open $path for write: $!"; + print {$out} $content; + close $out; + REPO_LIB_PERL_REPLACE log "Updated ${step.path}" '' else