feat: butter changes list / show, and resolve a build's commit to its change - #11
Merged
Merged
Conversation
… its change The changes API (commits and changelists across git, Perforce, and Lore) had no CLI command, so "did my commit land in ButterStack?" could only be answered in the web UI. - `butter changes list --project <id>` with --source lore|git|perforce, --since, --identifier, --orphaned, --limit, --after <cursor>, --json. Lore and Perforce share one source type server-side and are split here by the lore- identifier prefix. --json keeps the pagination envelope. - `butter changes show <change_id|commit>`: an all-digit argument is the change id; anything else (full SHA, p4-<n>, lore-<n>) is resolved through the exact identifier filter first. A Perforce build stores p4-<n> while its change stores <n>, so the prefix is stripped. - `builds show` prints the `changes show` command for its commit. - A 403 naming read:changes says to run `butter auth login` again, since tokens issued before the scope joined the CLI set do not carry it. - The read-only scope preset now includes read:changes. The paging flag is --after, not --cursor: --cursor is already the boolean client flag of `butter mcp install`.
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.
Adds the missing read path for changes (commits and changelists across git, Perforce, and Lore), so "did my commit land in ButterStack?" and "which change did this build come from?" can be answered from the terminal instead of the web UI.
What
butter changes list --project <id>: same row shape asbuilds list. Filters:--source lore|git|perforce,--since <date>,--identifier <id>,--orphaned,--limit <n>,--after <cursor>. Prints the--aftervalue for the next page.--jsonreturns the whole{changes, pagination}envelope (not just the array likebuilds list), because without it a script has nonext_cursor.butter changes show <change_id|commit> --project <id> [--json]: an all-digit argument is the change id thatlistprints; anything else (full git SHA, a Perforce build'sp4-<n>,lore-<n>) is resolved through the API's exactidentifierfilter first, then the detail is fetched. Detail shows identifier, source, author, approvals, tasks, latest build, description, linked builds, and files (first 20).builds shownow printsbutter changes show <commit> --project <id>under the Commit line, which is the build-to-change join.403 insufficient_scopenamingread:changesprints a line saying to runbutter auth loginagain.read-onlyscope preset now includesread:changes.Things to look at twice
p4-prefix. A Perforce BuildRun storesp4-<n>but its change stores the bare<n>, and the API'sidentifierfilter is exact and unvalidated, so passingp4-207through returns200 []. The client strips it and addssource_type=Changelist.showis read as a change id; the error message and README point atchanges list --identifier <n>for that case.source_type=Changelistserver-side, so--source lore|perforcefilters the page client-side by thelore-prefix. A filtered page can hold fewer than--limitrows (documented).build_runs_changelistsjoin, with a commit hash that is not the change identifier. That attribution belongs server-side.--after, not--cursor:--cursoris already a boolean flag (butter mcp install --cursor) and can never carry a value.Depends on
The server must allow
read:changeson CLI-issued tokens. Until ButterStack/butter_stack#1961's PR deploys,butter auth logincannot mint a token with it, and these commands get a 403 with the reissue hint. Tokens issued before that deploy needbutter auth loginagain.Verification
npm test: 44/44 (12 new tests: list rendering and paging hint, flag-to-query mapping, lore/perforce split,--jsonenvelope, bad--source, show by id, show byp4-<n>, show by SHA with--json, no-match error, 403 reissue hint, usage error,builds showhint).butter auth loginloopback minted a token carryingread:changes, thenchanges list,changes list --source perforce,changes show p4-207,changes show <sha> --json,changes show lore-12, and a no-match lookup all behaved as above. A token withoutread:changesgot the 403 plus the reissue line.No version bump in this PR; a release is needed to publish it.