← 输入框|github.com|刷新
Skip to content

fix(cmd-version): stop upstream verification fetch from pruning the new release tag - #1510

Open
TiantianYZJ wants to merge 1 commit into
python-semantic-release:masterfrom
TiantianYZJ:fix/verification-fetch-no-prune-tags
Open

TiantianYZJ wants to merge 1 commit into
python-semantic-release:masterfrom
TiantianYZJ:fix/verification-fetch-no-prune-tags

Conversation

@TiantianYZJ

Copy link
Copy Markdown

What

GitProject.verify_upstream_unchanged() now passes --no-prune-tags to both of its fetch invocations: the default remote-configuration fetch and the authenticated-URL fetch with an explicit refspec.

Why

Users with fetch.pruneTags=true in their git configuration (e.g. set globally alongside fetch.prune=true) lose the release tag during semantic-release version:

  1. PSR creates the release commit and tag locally,
  2. the upstream verification fetch runs git fetch origin (default path),
  3. fetch.pruneTags=true prunes every local tag that does not exist on the remote yet — including the just-created release tag,
  4. the subsequent tag push fails with error: src refspec refs/tags/v1.0.0 does not match any → GitPushError.

Reported in #1509 (the user-side workaround was git config --local remote.origin.pruneTags false). The verification fetch is a read-only consistency check and should never mutate local tags, so the flag is scoped to this fetch only; the user's own fetch behavior elsewhere is unchanged.

Evidence

Reproduced at the git level (empty remote, local tag pointing to a local object):

scenario result
fetch.prune=true + fetch.pruneTags=true, plain git fetch origin tag pruned (bug)
same config + --no-prune-tags tag kept (fix)
only fetch.pruneTags=true (no prune) tag kept
fetch by URL + explicit refspec (authenticated path) tag kept (path unaffected today)
authenticated path + --no-prune-tags tag kept (flag harmless)

Tests

  • tests/unit/semantic_release/test_gitproject.py (17/17 pass): the default-path and authenticated-path assertions now expect --no-prune-tags; the fetch-failure test mocks the actual call site (repo.git.fetch).
  • Full tests/unit run: the failure/error set is identical with and without this change (23 pre-existing Windows-environment failures confirmed via a master baseline) — no new failures introduced.

Fixes #1509

…ew release tag

A user's `fetch.pruneTags=true` git configuration (e.g. set globally
alongside `fetch.prune=true`) also applies to the upstream verification
fetch in `verify_upstream_unchanged()` when it uses the default
remote-configuration fetch path. That fetch removes every local tag
that is not on the remote yet - including the release tag created
earlier in the same `semantic-release version` run - so the subsequent
tag push fails with:

    error: src refspec refs/tags/v1.0.0 does not match any
    GitPushError: Failed to push tag (v1.0.0) to remote

Pass `--no-prune-tags` to both fetch variants so the verification fetch
never prunes tags regardless of the user's git configuration. The
authenticated-URL path (fetching with an explicit refspec) is unaffected
by pruneTags today; the flag makes the guarantee unconditional.

Fixes python-semantic-release#1509

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Release verification fetch prunes the newly created tag

1 participant