1
0
Fork 0
mirror of https://code.forgejo.org/actions/forgejo-release synced 2025-06-08 03:58:19 +02:00

fix: override=true must not needlessly delete a tag

If the tag to be set is exactly the same as the tag that exists, do
not delete it.

When the tag is recreated although it is not necessary, it may trigger
workflows that have already been triggered and send the workflow in a
loop.

- split `get_tag` & `matched_tag` out of ensure_tag
- in case of an override, only delete the tag if it fails `matched_tag`
- trace shell lines to help debug
- add testing
This commit is contained in:
limiting-factor 2025-02-23 16:03:14 +01:00
parent 9d4ddfbaad
commit 0079bcb471
2 changed files with 35 additions and 9 deletions

View file

@ -45,15 +45,18 @@ test_ensure_tag() {
# idempotent
#
ensure_tag
api GET repos/$REPO/tags/$TAG >$TMP_DIR/tag1.json
mv $TAG_FILE $TMP_DIR/tag1.json
ensure_tag
api GET repos/$REPO/tags/$TAG >$TMP_DIR/tag2.json
mv $TAG_FILE $TMP_DIR/tag2.json
diff -u $TMP_DIR/tag[12].json
#
# sanity check on the SHA of an existing tag
#
(
SHA=12345
! matched_tag
! ensure_tag
)
api DELETE repos/$REPO/tags/$TAG