astral-sh / uv

An extremely fast Python package and project manager, written in Rust.
https://docs.astral.sh/uv
Apache License 2.0
19.39k stars 574 forks source link

Consider branch or tag precedence in ambiguous git references #298

Open zanieb opened 10 months ago

zanieb commented 10 months ago

We currently will use a branch name over a tag name if they both exist.

Similarly, git checkout prefers switching to a branch:

❯ git tag v0.1.0
❯ gcm
Switched to branch 'main'
Your branch is up to date with 'origin/main'.
❯ gcb v0.1.0
Switched to a new branch 'v0.1.0'
❯ gcm
Switched to branch 'main'
Your branch is up to date with 'origin/main'.
❯ gco v0.1.0
warning: refname 'v0.1.0' is ambiguous.
Switched to branch 'v0.1.0'

but for installing packages I would much rather match a tag than a branch if there's a collision.

_Originally posted by @zanieb in https://github.com/astral-sh/puffin/pull/297#discussion_r1380659592_

zanieb commented 10 months ago

It'd probably be good to warn as part of #287 if there's an ambiguous ref.