File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -594,8 +594,11 @@ function release::create_tags() {
594594 local major_tag
595595 major_tag=$( release::major_tag " $new_version " )
596596
597- git tag -a -m " $new_version " " $new_version "
598- git tag -f -a -m " $major_tag " " $major_tag " " ${new_version} ^{}"
597+ # Silence git's own stdout ("Updated tag 'v0' (was ...)" when -f replaces an
598+ # existing tag) so it cannot leak into this function's stdout, which the
599+ # caller captures as the major tag name. Errors still surface on stderr.
600+ git tag -a -m " $new_version " " $new_version " > /dev/null
601+ git tag -f -a -m " $major_tag " " $major_tag " " ${new_version} ^{}" > /dev/null
599602
600603 echo " $major_tag "
601604}
Original file line number Diff line number Diff line change @@ -405,3 +405,21 @@ function test_create_tags_returns_major_tag_name() {
405405 cd " $origin " || return 1
406406 rm -rf " $repo "
407407}
408+
409+ # Regression: when the major tag already exists, `git tag -f` prints
410+ # "Updated tag 'v0' (was ...)" to stdout. That must not leak into the
411+ # returned major tag name (it previously did, producing an invalid push
412+ # refspec during a real release).
413+ function test_create_tags_returns_clean_name_when_major_tag_already_exists() {
414+ local repo origin result
415+ repo=" $( _create_tags_setup_repo) "
416+ origin=" $( pwd) "
417+
418+ cd " $repo " || return 1
419+ git tag v0 # pre-existing major tag -> -f takes the update path
420+ result=" $( release::create_tags ' 0.40.0' ) "
421+ assert_same " v0" " $result " # exactly "v0", no "Updated tag ..." noise
422+
423+ cd " $origin " || return 1
424+ rm -rf " $repo "
425+ }
You can’t perform that action at this time.
0 commit comments