From fd642ddb8437e47e72a17998bba4c4eaab3119f3 Mon Sep 17 00:00:00 2001 From: decentral1se Date: Wed, 1 Oct 2025 11:18:30 +0200 Subject: [PATCH] fix: fail if release conflicts See https://git.coopcloud.tech/toolshed/organising/issues/638 --- cli/recipe/release.go | 19 ++++++++++++++----- tests/integration/recipe_release.bats | 24 ++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/cli/recipe/release.go b/cli/recipe/release.go index 675c362f..df27866e 100644 --- a/cli/recipe/release.go +++ b/cli/recipe/release.go @@ -135,14 +135,23 @@ your private key and enter your passphrase beforehand. log.Fatal(err) } - if tagString == "" && (!internal.Major && !internal.Minor && !internal.Patch) { - var err error - tagString, err = getLabelVersion(recipe, false) - if err != nil { - log.Fatal(err) + labelVersion, err := getLabelVersion(recipe, false) + if err != nil { + log.Fatal(err) + } + + for _, tag := range tags { + previousTagLeftHand := strings.Split(tag, "+")[0] + newTagStringLeftHand := strings.Split(labelVersion, "+")[0] + if previousTagLeftHand == newTagStringLeftHand { + log.Fatal(i18n.G("%s+... conflicts with a previous release: %s", newTagStringLeftHand, tag)) } } + if tagString == "" && (!internal.Major && !internal.Minor && !internal.Patch) { + tagString = labelVersion + } + isClean, err := gitPkg.IsClean(recipe.Dir) if err != nil { log.Fatal(err) diff --git a/tests/integration/recipe_release.bats b/tests/integration/recipe_release.bats index 7113e1a4..81aff599 100644 --- a/tests/integration/recipe_release.bats +++ b/tests/integration/recipe_release.bats @@ -127,3 +127,27 @@ teardown() { assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/release/0.4.0+1.21.0" assert_file_contains "$ABRA_DIR/recipes/$TEST_RECIPE/release/0.4.0+1.21.0" "those are some release notes for the next release" } + +@test "recipe release conflict fails" { + tagHash=$(_get_tag_hash "0.2.0+1.21.0") + run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" checkout "$tagHash" + assert_success + + run sed -i "s/nginx:1.21.0/nginx:1.29.1/g" "$ABRA_DIR/recipes/$TEST_RECIPE/compose.yml" + assert_success + + run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" diff + assert_success + assert_output --regexp 'nginx:1.29.1' + + run sed -i "s/0.2.0+1.21.0/0.2.0+1.29.1/g" "$ABRA_DIR/recipes/$TEST_RECIPE/compose.yml" + assert_success + + run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" diff + assert_success + assert_output --regexp 'coop-cloud\.\$\{STACK_NAME\}\.version=0\.2\.0\+1\.29\.1' + + run $ABRA recipe release "$TEST_RECIPE" --no-input --minor + assert_failure + assert_output --partial '0.2.0+... conflicts with a previous release: 0.2.0+1.21.0' +}