feat: add 'uvbox git' subcommand for git repository sources (#19) - #21
Closed
hasansezertasan wants to merge 12 commits into
Conversation
hasansezertasan
marked this pull request as draft
April 10, 2026 14:30
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Extracts ldflag construction into a pure, testable function and adds validateGitSource to enforce the git+ prefix constraint. Regression tests lock in pypi and wheel ldflag output; new tests cover git source injection behavior. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…oBuild - Replace inline ldflags construction in goBuild with buildGoBuildLdflags(GitSource, WheelsToEmbed) - Add GitSource package-level var alongside Config/Output/Nfpm/ReleaseVersion - Register gitCmd cobra subcommand (ExactArgs(1), same flags as pypiCmd/wheelCmd) - Add validateGitSourceFlag helper, called from preRun Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The smoke test surfaced a pre-existing bug in boxer's ldflag handling: Go's GOFLAGS parser uses strings.Fields (whitespace split, no quote handling), so any ldflag string containing -X flags fails to parse with "unknown flag -X". This silently broke the wheel path in commit f19680f when ldflags moved to GOFLAGS for Windows compatibility, and would have broken git the same way. To unblock the git feature without touching the wheel path (which remains broken in main and needs a separate fix), embed the git source via a committed placeholder file box/git_source.txt + //go:embed in box/box_package_git.go. boxer writes the git spec into this file before go build via writeGitSourceFile, replacing the empty placeholder for git builds and leaving it empty for pypi/wheel builds. This sidesteps GOFLAGS entirely for git. The wheel path's GOFLAGS bug is left untouched and should be addressed in a separate PR by the original author of f19680f, who can verify the Windows fix properly. Verified end-to-end: uvbox git git+https://github.com/VaasuDevanS/cowsay-python --darwin --arm ./dist/cowsay -t "uvbox git works!" # prints cow ✓ ./cowsay self update # "Already up-to-date" ✓ ./cowsay self path # cowsay-637049bd... ✓ uvbox pypi (regression) # cowsay-2fea8a21... ✓ different dir Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Match the existing wheels/placeholder pattern: gitignore the dynamically generated file and create it on demand via go generate. Keeps the box package free of empty committed files and lets `mise run generate:box` handle bootstrapping for tests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
hasansezertasan
force-pushed
the
feat/hasansezertasan/brainstrorming-lets-address-this-issue-httpsgithub
branch
from
April 10, 2026 14:34
d01fcef to
89bc268
Compare
Author
|
Closing in favor of a renamed branch — the auto-generated branch name was unwieldy. Reopening as a draft from |
hasansezertasan
deleted the
feat/hasansezertasan/brainstrorming-lets-address-this-issue-httpsgithub
branch
April 10, 2026 14:39
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #19.
Summary
Adds a new
uvbox git <git-spec>subcommand alongside the existingpypiandwheelsource types. The git spec is passed through touv tool install --fromverbatim, so any formuvaccepts works (@main,@v1.0.0,@<commit>,ssh://, etc.).Implements the approach @Coruscant11 chose in this comment: subcommand with the git spec as a positional CLI argument, no changes to the
uvbox.tomlschema.The runtime install path runs
uv tool install --from <spec> <name> --upgradeon every install/update — no version-discovery infrastructure, no tag scanning.auto-update = truere-installs on every run, delivering thepycrucible delete_after_run-equivalent behavior the issue requested.Design notes
box/config_identifier_test.golocks in a byte-stable golden hash forComputeIdentifierto guarantee existing binaries find the same XDG dir.ComputeIdentifier(only when set), so binaries built fromgit+url@mainandgit+url@v1.0.0get separate isolated install dirs. No cross-contamination with pypi-built binaries of the same package.git+. Everything else is delegated touv, which surfaces malformed specs loudly on first run.Pre-existing bug discovered (and worked around)
The original spec proposed embedding the git source via
-ldflags \"-X main.GIT_SOURCE=...\". The smoke test surfaced that this does not work because of a pre-existing bug introduced in #14 (commit f19680f, "fix: Use environment variables for ldflags"):This silently broke the
uvbox wheelpath in main since #14 was merged — it sets-X main.INSTALL_WHEELS=yes, which fails the same way. No test exercises wheel mode end-to-end so nobody noticed. Reproduction:This PR does not fix the wheel bug — touching it requires re-validating the original Windows-via-uvx fix from #14 on Windows, which is out of scope here. The wheel path remains broken in main and should be addressed in a separate PR.
For git, this PR sidesteps GOFLAGS entirely by embedding the source in a small file (
box/git_source.txt) read at compile time via//go:embed. boxer'swriteGitSourceFilewrites the spec into this file beforego build. Empty file = pypi/wheel build, non-empty = git build. Same end result, different transport.Files
Runtime (`box/`):
box/box_package_git.go(new) —GIT_SOURCE(loaded from embeddedgit_source.txt),uvToolInstallGit,buildUvToolInstallFromArgspure helperbox/box_package.go— one new branch inuvToolInstalldispatching to git whenGIT_SOURCE != \"\"(existing pypi/wheel logic untouched)box/config.go—ComputeIdentifierconditionally appendsGIT_SOURCE(no-op when empty)box/generate.go— adds emptygit_source.txtplaceholder generation, mirroring the existingwheels/placeholderpatternbox/config_identifier_test.go(new) — golden-hash regression test + git distinction testsbox/box_package_git_test.go(new) — pure-helper command-shape testsBuild-time (`boxer/`):
boxer/git.go(new) —buildGoBuildLdflagspure helper (now without git, since git uses file embed),validateGitSource,writeGitSourceFileboxer/main.go— newgitCmdcobra command,GitSourceCLI var,validateGitSourceFlagin preRun,writeGitSourceFilecall ininsertFilesIntoBoxRepositoryboxer/git_test.go(new) — ldflag regression tests for pypi/wheel,writeGitSourceFiletests,validateGitSourcetestsDocs:
README.md— feature bullet updated, new "Build from a Git Repository" section, behavior of[package.version]for git builds, private repo auth noteexamples/git/simple-app.toml(new) — minimal example.gitignore— addsbox/git_source.txtTest Plan
boxtest suite passes (go test ./...) including theComputeIdentifiergolden-hash regression guardboxertest suite passes including ldflag regression guards for the existing pypi/wheel pathsuvbox git git+https://github.com/VaasuDevanS/cowsay-python --darwin --armbuilds, the resulting binary runs end-to-end (./cowsay -t \"hi\"prints the cow),self updatereports "Already up-to-date",self pathshows a git-distinct identifieruvbox pypistill works, produces a different identifier hash (separate XDG dir from the git build of the same package)Reviewers can reproduce the smoke test:
🤖 Generated with Claude Code