Loading
feat(template): load issue and MR templates from remote repository when --repo is set
What does this MR do?
When --repo is set, glab issue create --template and glab mr create --template now load templates from the target repository (on its default branch) through the API, instead of reading the local checkout.
This continues !3625 (closed), which was closed as stale. The review feedback from that MR is addressed here.
Changes
internal/cmdutils: newLoadGitLabTemplateRemoteandListGitLabTemplatesRemotehelpers that useRepositoryFiles.GetRawFileandRepositories.ListTreeagainst the project's default branch.ctxis passed through to both helpers and on to the API calls withgitlab.WithContext(ctx).- A 404 is detected with
gitlab.HasStatusCode(err, http.StatusNotFound). - Pointers use
new(...)(for exampleRecursive: new(false)).
issue createandmr createswitch to the remote helpers when--repois set.- Tests: unit tests for the helpers, plus command-level tests via
cmdtest.SetupCmdForTestfor both commands covering local (no--repo), remote (--repo), and remote not-found. - Docs regenerated.
How to test
glab issue create --repo <group/project> --template <name>
glab mr create --repo <group/project> --template <name>
go test ./internal/cmdutils/ ./internal/commands/issue/create/ ./internal/commands/mr/create/Closes #8175