uv
2608f742 - Allow updating Git sources by name (#12897)

Commit
304 days ago
Allow updating Git sources by name (#12897) Closes: #4567 ## Summary When adding a package with Git reference options (`--rev`, `--tag`, `--branch`) that already has a Git source defined, use the existing Git URL with the new reference instead of reporting an error. This allows commands like `uv add requests --branch main` to work when requests is already defined with a Git source in the project configuration. Previously, you would need to provide the whole Git url again for this to work: ```bash uv add git+https://github.com/psf/requests --branch main ``` <!-- What's the purpose of the change? What does it do, and why? --> ## Test Plan - [x] Add unit tests for project - [x] Add unit tests for script - [x] Tested locally for project and script environments like below ### Testing Project In a directory using the `uv` executable from this PR (via replacing every `uv` with `cargo run --`) initialize a project and virtual environment ```bash uv init uv venv ``` move into the environment ```bash # on mac source .venv/bin/activate ``` and add a dependency with a git url ```bash uv add git+https://github.com/Textualize/rich --branch master ``` Then change the branch of the project to see that the branch can be changed without need of the whole git url: ```bash uv add rich --branch py310 ``` ### Testing Script Create the following file, e.g. `script.py`: ```python import time from rich.progress import track print("Starting") for i in track(range(20), description="For example:"): time.sleep(0.05) print("Done") ``` Now using `uv` (referencing the executable of this PR) add the dependency ```bash uv add --script script.py 'git+https://github.com/Textualize/rich' --branch master ``` and check we can execute the script: ```bash uv run script.py ``` To test the change update the branch ```bash uv add --script script.py rich --branch py310 ``` and check that the dependency is updated and the script is executed: ```bash uv run script.py ``` <!-- How was it tested? --> ---- This is my first time contributing to `uv` (yay, 🤗) so let me know if there is something obvious i am missing. Unit tests will follow soon. --------- Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
Author
Parents
Loading