Add a one-line curl install - #59
Open
leogdion wants to merge 1 commit into
Open
Conversation
The README's curl path was a 12-line copy-paste blob that mktemp'd, curled,
moved, chmod'd, then repeated the whole dance for the agents template. Replace
it with the conventional one-liner:
curl -fsSL https://raw.githubusercontent.com/brightdigit/git-trees/main/install.sh | bash
That requires install.sh to work with no repo around it. It now detects the
case where the expected files are not next to the script, downloads git-trees
and AGENTS.md.template into a mktemp -d, and proceeds exactly as before, with a
trap cleaning up the temp directory on exit.
Downloads go through curl or wget, whichever is present, and each is verified
non-empty before anything is installed — curl -fsSL fails on HTTP errors but
still leaves a zero-byte file behind, and an empty or truncated git-trees
installed onto PATH is the worst outcome here.
A piped script receives no positional arguments, so TREES_DEST is the only way
to choose a destination on that path. The positional argument still wins for
the clone path, which is otherwise unchanged: same ~/.local/bin default, same
install -m 0755, same template no-overwrite guard, same PATH warning and hints.
Piped bash has neither BASH_SOURCE nor $1, and set -u makes a bare reference to
either fatal, so the source-directory probe defaults them. The template guard
also moves from -f to -e/-L, matching the no-clobber behavior the README
already documented for a broken symlink.
Also fixes the README's "All three variables are optional" against an
Environment table that listed five, and adds TREES_DEST to that table.
Closes #54
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This was referenced Aug 21, 2026
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.
The README's curl path was a 12-line copy-paste blob:
mktemp,curl,mv,chmod, then a second guarded block repeating the whole dance for the agents template. Issue #54 asks for the conventional shape — one line:curl -fsSL https://raw.githubusercontent.com/brightdigit/git-trees/main/install.sh | bashNo-repo detection
That one-liner requires
install.shto work with nothing around it. It previously did:Piped into bash,
$SRCis meaningless and it hard-fails. Now, when the expected files are not next to the script, it downloadsgit-treesandAGENTS.md.templateinto amktemp -dand proceeds exactly as before, with atrapremoving the temp directory on exit.Two
set -udetails the piped path exposes: piped bash has noBASH_SOURCEand no$1, and a bare reference to either is fatal underset -u. The first showed up only when actually piping — a copied-file test still hasBASH_SOURCE— asbash: line 20: BASH_SOURCE[0]: unbound variable. Both are defaulted now, and a test pipes the script on stdin to keep it that way.TREES_DESToverrideA piped script receives no positional arguments, so
./install.sh /usr/local/binhas no equivalent when piping — there is nowhere for the argument to go. Hence an env var:TREES_DEST=/usr/local/bin curl -fsSL https://raw.githubusercontent.com/brightdigit/git-trees/main/install.sh | bashThe positional argument still takes precedence (
DEST="${1:-${TREES_DEST:-$HOME/.local/bin}}"), so the clone path is unaffected and both are tested.Download verification
Downloads go through
curlorwget, whichever is present, with a clear error if neither is. Each download is verified non-empty before anything is installed.curl -fsSLfails on HTTP errors, and its status is checked rather than assumed — but it still leaves a zero-byte file behind on some failures, and that case is the one an exit-status check alone misses, so it has its own fixture. An empty or truncatedgit-treesinstalled ontoPATHis the worst outcome here. A failedgit-treesdownload aborts; a failed template download only warns, since the template is optional andgit-treesalready warns without it.Clone path unchanged
Same
~/.local/bindefault, sameinstall -m 0755, same PATH warning, same trailing hints, no download attempted. Verified against a redirectedHOME, with the existing tests still passing untouched.One deliberate change: the template guard moves from
[ ! -f ]to[ ! -e ] && [ ! -L ]. That matches the no-clobber-a-broken-symlink behavior the README already documented and thatroot --agentsimplements; previously a broken symlink there would have been written through.Tests
The
install.shsection oftests/smoke.shis extended and ano-repo bootstrapsection added — 31 new assertions, and the suite stays network-free:TREES_BASE_URLpoints at afile://fixture, so the real download branch runs without touching the network and cannot silently no-op offline. Thecleansection remains last. Coverage: piped-on-stdin invocation, thewgetfallback on aPATHbuilt withoutcurl(macOS ships/usr/bin/curl, so proving the fallback runs means excluding the real one), the neither-downloader error, a zero-byte body, a missing script failing loudly and installing nothing, a missing template warning while the binary still installs, no-clobber on rerun, and temp-dir cleanup.Each new assertion was mutation-tested — the guard, the trap, and the
BASH_SOURCEdefault were each reverted in turn to confirm the corresponding test actually fails. Two early drafts that passed against a broken implementation were replaced (macOSmktemp -dignoresTMPDIRunless the template spells it out, which is whyinstall.shnow does).Docs
## Install— one-liner replaces the blob; clone-and-run stays the recommended full install; both still install the script and seed the agents template.TREES_DESTdocumented for the piped path and added to the## Environmenttable.mainstays pinned, and is still described as the stable release.## Configurationopened with "All three variables are optional" while## Environmentlisted five. It now refers to the table instead of hardcoding a count that drifts.Edits are scoped to install/configuration prose to keep merges clean with the concurrent Homebrew (#49), completions (#51), and subcommand (#50, #55) PRs.
Verification
End-to-end against a
file://URL withHOMEandTREES_DESTin temp dirs: the script lands executable (-rwxr-xr-x,git trees helpruns), the template is seeded byte-identical toAGENTS.md.template, and a rerun after editing that template leaves the edit intact.Closes #54
🤖 Generated with Claude Code
Release coordination (v1.0.3)
One of five PRs into
release-1.0.3(#56 prune, #58 sync, #60 completions, #59 curl install, #57 Homebrew). All five are green on CI (smoke on Linux + macOS).Suggested merge order: #56 → #58 → #60 → #59 → #57. This PR merges cleanly against every other branch.
The AGENTS.md template guard moved from
[ ! -f "$CFG/AGENTS.md" ]to[ ! -e ] && [ ! -L ]. That is a clone-path behavior change, not just an addition: previously a broken symlink at that path would be written through, and now it is treated as occupied. This matches what the README already documents and whatroot --agentsimplements via_seed_agents, but it was outside the strict scope of "add a curl install" — flagging it so it is a deliberate decision rather than a silent one.Also worth a look:
BASH_SOURCE[0]:-$0in theSRCassignment. Piped bash has noBASH_SOURCEand no$1, and underset -ua bare reference is fatal — so without this the whole feature would fail on the very path it exists to add. Found by actually piping the script; a file-copy test cannot catch it, because a copied script does haveBASH_SOURCE.Note: CodeRabbit skipped all five — "reviews are disabled for this base branch." These have not had automated review; that would come when
release-1.0.3merges tomain.The CHANGELOG is deliberately excluded from every PR — it needs the merged PR URLs, so it lands as one commit on
release-1.0.3before taggingv1.0.3.