Repository navigation
Make the plugin forge-agnostic (descriptor + capability flags, no behavior change) - #5
solalbaudoincs wants to merge 7 commits into
Conversation
The GitHub specifics that lived outside github.go (PR URL parsing, fork PR head refs, clone and sign-in commands, merge-method vocabulary, host display) now sit on a forge descriptor (forge.go), with capability flags on the source interface the TUI consults to hide a tab or key a forge doesn't support. GitHub and demo behavior is unchanged; a GitLab sibling can now bring its own descriptor.
The signed-out screen, error wording, login command and toast titles now come from the forge descriptor, so a sibling forge spells its own. Tests: caps-gated UI covered (Review tab hidden, merge key hidden); TestSignedOutScreen asserts via the descriptor.
…orge cloneCmd built its Env from nothing, so a clone ran gh with no PATH, HOME or GH_TOKEN (the command's Env now starts from os.Environ, as before); and the signed-out screen and sign-in errors lost gh's exact words. Both go through the descriptor now (loginText, cliName), which renders GitHub byte-identical to main while a sibling forge can spell its own. Tests cover both.
…nfig) (#1) * feat: GitLab merge requests behind the forge descriptor A gitlabSource over GitLab's REST API (v4) maps merge requests onto the plugin's pull requests, and gitlabForge spells GitLab's URLs, fork refs, merge methods and sign-in. "forge": "gitlab" in config.json switches the plugin to it; GitHub stays the default, and the demo stays on GitHub. The descriptor now also builds the picker's source and answers the label hooks and status (newSource, api), so no call site names GitHub's client. The multi-host cursor and repo paging are shared (fanOut, pageHosts), and repo paths may nest (group/sub/project) when the forge says so. * refactor: comments and the truncation notice name the forge in use The forge's comments still spoke of GitLab as a forge to come, and the list-cap notice was built at start-up, before the config chose the forge, so it said GitHub on GitLab. --------- Co-authored-by: Solal Baudoin <solal.baudoin@macbook-air-solalbaudoin.cheetah-koi.ts.net>
loadAll fired the Review tab's load whatever the forge: with the GitLab source, which answers nothing for it, a signed-out error from that load flipped the whole popup to the signed-out screen and hid the lists. Ask only for the tabs the forge can answer. Co-authored-by: Solal Baudoin <solal.baudoin@macbook-air-solalbaudoin.cheetah-koi.ts.net>
Forge-agnostic core + GitLab support (from upstream PR mrolafsson#5)
|
Thank you so much for all of this! 🙏 It's a huge amount of careful work. The GitHub wording stays exactly the same, there's no new dependency, and the GitLab REST client and its tests are thorough. It's really nice to see someone want to bring the plugin family to GitLab. I've thought about it a lot, and I don't think I can take it into herdr-github, mainly because I couldn't maintain it well. I don't use GitLab, so I'd have no way to test that side. Every new feature would also need a GitLab version or a capability flag. Today's change is an example: "Update branch" (#1) adds What I'd suggest is shipping it as One small thing for anyone reading: the description still says GitLab is out of scope, but the branch now includes it. Could you update the description, or close this in favour of the fork, whichever you prefer? Thanks again, really, for the thought and care that went into this! |
Summary
No behavior change for GitHub. This moves the GitHub-specific knowledge that lives outside
github.gobehind a forge descriptor, and adds capability flags the TUI consults — groundwork for a GitLab sibling plugin, as discussed in #4.go build/go vet/gofmtclean; full suite 165 passed (159 baseline + 6 new; baseline verified green before starting).The forge descriptor (
forge.go, new)A small struct-valued var,
theForge, one instance per forge. GitHub getsgithubForge; the demo runs on it too (it impersonates GitHub today). What it carries:prFromPathpull/Npath parsing inagents.go(transcript links)prHeadRefrefs/pull/N/headinworktree.go,demo.gotokentokenFnstill points where it did;ghTokenitself is unchanged ingithub.go)cloneCmdgh repo cloneinvocation inrepos.go(Env still starts fromos.Environ())methodNames/methodVerbsdetail.goname,defaultHost,loginCmd,loginText,cliNamenotifynow takes only a body, titled with the forge's name),errSignedOut, the sign-in error prefixDeliberately left out:
knownHoststays onconfig(user config, already forge-neutral), and the GraphQL endpoint stays ingithub.go(it's the GitHub client's API detail).Capability flags (
source.go)caps{reviewRequested, autoMerge}on thesourceinterface. Both current sources report full capability — zero behavior change — but the TUI now consults the flags: the Review tab only appears whenreviewRequested(tabShown,cycleTabintui.go/groups.go), and the merge menu/key only whenautoMerge(detail.go). This generalizes what the demo implicitly lacked.Tests
forge_test.go(URL path parsing, default host, clone inherits the environment),caps_test.go(Review tab hidden, merge key hidden),screen_test.go(signed-out screen wording matches main exactly).TestSignedOutScreen): it asserted GitHub's wording literally; it now asserts viatheForge.loginText— same meaning, same string for GitHub.Commits
6388bc0— the descriptor, and everything threaded through it0dbf243— forge-neutral wording, sign-in and toasts via the forgebba781f— a doc comment thetabShowninsertion had split, fixedaf46c7b— gofmtaccb96f— fix round:cloneCmd's Env now starts fromos.Environ()(it had been built from an empty slice, breaking every clone), and the signed-out screen / sign-in errors keep GitHub's exact previous wording throughloginText/cliName(a sibling forge can spell its own)PLAN.md(the implementation plan) is included in the diff — drop it if you'd rather not keep it in-tree.GitLab itself stays out of scope here; the follow-up would be a sibling plugin standing
gitlabForgebehind the same seams.