Repository navigation
feat(git): git.history pages a branch's own commits with pushed state - #36962
Conversation
git.history gains optional branchOnly and skip params. A branch-only page lists only commits the base lacks, with per-commit stats and whether the upstream has each one, plus ahead/behind/unpushed counts. Older clients send neither param and get the same reply as before; older hosts ignore them, so clients detect support from the echoed branch and skip fields. Mobile may now call git.remoteCommitUrl to open a commit on its host.
|
No actionable comments were generated in the recent review.
|
ELI5
The desktop can now answer "which commits does this branch add on top of main, and which of those haven't been pushed?" It answers a page at a time, so a phone can scroll past 50. Nothing on screen changes in this PR. The mobile Commits screen that uses it comes next.
What Changed
git.historytakes two new optional params:branchOnly(with the existingbaseRef): the page lists only the commits HEAD has and the base lacks (git log HEAD ^<base>).skip: the page starts that many commits in (--skip).statistics(files, insertions, deletions), parsed from--shortstat;pushed, fromgit rev-list HEAD ^<upstream> ^<base>(that set is bounded by the branch's own commits). The upstream is the same effective upstreamgit.upstreamStatususes, so this matches the Sync and Push state. With no upstream, nothing counts as pushed;branch: { baseRef, ahead, behind, unpushed }.aheadandbehindcome from onerev-list --left-right --count base...HEAD.skipis echoed back when sent, so a client can tell a host that pages from one that ignores the param.mainwith baseorigin/main) has nothing to cut out, so it keeps HEAD's full history instead of returning an empty page. Remote names containing/are split at a configured remote.--shortstatline that git prints after a record's NUL, at the start of the next record.git.remoteCommitUrl, the same call desktop's "Open on GitHub" uses (GitHub, GitLab and Bitbucket).Why
On mobile, the Commits tab lists the repo's last 50 commits from HEAD with no paging. It doesn't stop where the branch began, and it can't tell pushed commits from unpushed ones. The approved Source Control mocks replace it with a "this branch only" screen: Not pushed / On origin groups, a "Branched from main" marker and paging. The loader is shared by every route (local, WSL, SSH and runtime hosts), so the rule goes there once, and the client only lays out what the host returns.
Alternatives I ruled out:
git.historykeeps a single owner.Mixed versions:
GitHistoryis a non-strictz.object) and reply as before. Clients detect that by the missingbranch/skipecho and show the full history.Linked Issue
None. This is the backend half of the approved mobile Source Control redesign (the Commits screen). The mobile PR stacks on it.
Visual Proof
N/A: there is no UI in this PR. The mobile Commits screen PR that uses it carries the before/after.
Testing
src/shared/git-history-real-repository.test.tsadds a real-git regression test. It checks that the page:skip, which is echoed back;origin/<branch>on that branch;gh/teamcorrectly;These pass locally:
git-history.test.ts,git.test.ts, the mobile allowlist/routing tests, and the request-authorization and local-git-provider suites.Platforms: macOS, with real git. The loader is platform-neutral and uses git's English-pinned output.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
Four review rounds (Codex and Claude). Accepted and fixed:
mainchecked out and baseorigin/main, the page came back empty.git.upstreamStatus. This covers legacy worktrees that trackorigin/mainbut publish toorigin/<branch>, and agents that pushed withgit push origin HEAD.branchOnlyandskip.Left as is:
skip(P3: there is nothing to page).Agent skill upstream boundary
Notes
skipis a validated non-negative int. The base and upstream reach git only as resolved OIDs.--shortstatand the tworev-listcalls run only on branch-only pages, and they're bounded by the branch's own commits.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)