From 97158a4d7f147a344433139be40501c4d8653cd4 Mon Sep 17 00:00:00 2001 From: Ben Tasker <2900301+bentasker@users.noreply.github.com> Date: Tue, 27 May 2025 12:23:43 +0100 Subject: [PATCH 1/4] fix: make checkout expected-commit bump less greedy Signed-off-by: Ben Tasker <2900301+bentasker@users.noreply.github.com> --- pkg/renovate/bump/bump.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/renovate/bump/bump.go b/pkg/renovate/bump/bump.go index db96ccc2e..2d1931d01 100644 --- a/pkg/renovate/bump/bump.go +++ b/pkg/renovate/bump/bump.go @@ -225,8 +225,7 @@ func updateGitCheckout(ctx context.Context, node *yaml.Node, expectedGitSha stri if err != nil { log.Infof("git-checkout node does not contain a tag, assume we need to update the expected-commit sha") } else { - versionPattern := regexp.MustCompile(`\${{vars\..+}}`) - if !strings.Contains(tag.Value, "${{package.version}}") && !versionPattern.MatchString(tag.Value) { + if !strings.Contains(tag.Value, "${{package.version}}") && !strings.Contains(tag.Value, "${{vars.mangled-package-version}}") { log.Infof("Skipping git-checkout node as it does not contain a version substitution so assuming it is not the main checkout") return nil } From 8f985dc7b516b8273cd5903980f91130c6308a53 Mon Sep 17 00:00:00 2001 From: Ben Tasker <2900301+bentasker@users.noreply.github.com> Date: Tue, 27 May 2025 12:33:55 +0100 Subject: [PATCH 2/4] fix: don't clobber expected-commit hash if it's a variable Signed-off-by: Ben Tasker <2900301+bentasker@users.noreply.github.com> --- pkg/renovate/bump/bump.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/renovate/bump/bump.go b/pkg/renovate/bump/bump.go index 2d1931d01..00743efdd 100644 --- a/pkg/renovate/bump/bump.go +++ b/pkg/renovate/bump/bump.go @@ -236,7 +236,7 @@ func updateGitCheckout(ctx context.Context, node *yaml.Node, expectedGitSha stri if expectedGitSha != "" { // Update expected hash nodes. nodeCommit, err := renovate.NodeFromMapping(withNode, "expected-commit") - if err == nil { + if err == nil && !strings.Contains(nodeCommit.Value, "${{") { nodeCommit.Value = expectedGitSha log.Infof(" expected-commit: %s", expectedGitSha) } From 4eb88d54e92a7d200972ebe0b586ae75e400a2f0 Mon Sep 17 00:00:00 2001 From: Ben Tasker <2900301+bentasker@users.noreply.github.com> Date: Tue, 27 May 2025 12:34:58 +0100 Subject: [PATCH 3/4] fix: remove (now) unused regexp import Signed-off-by: Ben Tasker <2900301+bentasker@users.noreply.github.com> --- pkg/renovate/bump/bump.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/renovate/bump/bump.go b/pkg/renovate/bump/bump.go index 00743efdd..cff95c29d 100644 --- a/pkg/renovate/bump/bump.go +++ b/pkg/renovate/bump/bump.go @@ -22,7 +22,6 @@ import ( "fmt" "io" "net/http" - "regexp" "strconv" "strings" From 97f139990848486480c93f757567ce643df04009 Mon Sep 17 00:00:00 2001 From: Ben Tasker <2900301+bentasker@users.noreply.github.com> Date: Mon, 16 Jun 2025 15:49:33 +0100 Subject: [PATCH 4/4] docs: document that `mangled-package-version` will result in `git-checkout` blocks being bumped by `melange bump` calls Signed-off-by: Ben Tasker <2900301+bentasker@users.noreply.github.com> --- docs/VAR-TRANSFORMS.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/VAR-TRANSFORMS.md b/docs/VAR-TRANSFORMS.md index e9901f6ea..35fd54258 100644 --- a/docs/VAR-TRANSFORMS.md +++ b/docs/VAR-TRANSFORMS.md @@ -46,6 +46,21 @@ pipeline: uri: https://github.com/openjdk/jdk17u/archive/refs/tags/jdk-${{vars.mangled-package-version}}.tar.gz ``` +`mangled-package-version` can also be used with `git-checkout`: + +```yaml +pipeline: + - uses: git-checkout + with: + repository: https://github.com/openjdk/jdk12u + tag: ${{vars.mangled-package-version}} + expected-commit: 5018cdd1904357c04c9c41e0f8fe8994916cb638 +``` + + +Note: If `melange bump` is run, it will attempt to update the `expected-commit` value. + + Other example: In some case, you need to join two or more regex match subgroups with `_`. Here you must use `${1}` instead of `$1`. More information [here](https://github.com/golang/go/issues/32885#issuecomment-507477621)