9e6c2098b1
Co-authored-by: nova28 <17953305+nova28@users.noreply.github.com> Co-authored-by: Carlos Florencio <carlosmflorencio@gmail.com>
2.5 KiB
2.5 KiB
id, title, status, wave, depends_on, plan, spec
| id | title | status | wave | depends_on | plan | spec |
|---|---|---|---|---|---|---|
| 01-gitlab-repo-content-client | GitLab client repository-content methods | done | 1 | plan.md | ../../specs/gitlab-workflow-sync/spec.md |
Task 01: GitLab Client Repository-Content Methods
Acceptance
gitlab.ClientexposesListRepoTree(ctx, projectPath, path, ref string) ([]RepoTreeEntry, error)andGetRepoFileContent(ctx, projectPath, path, ref string) ([]byte, error), implemented byPATClient(REST),MockClient(seedable), andNoopClient(not-configured error).GLabClientinherits via its embedded*PATClientand needs no change.PATClient.ListRepoTreetargetsGET /projects/:id/repository/treewith a non-recursive listing, percent-encodes the fullprojectPathas one path segment (sogroup/subgroup/projectresolves), and follows pagination until exhausted.GetRepoFileContenttargetsGET /projects/:id/repository/files/:file_path/raw?ref=<ref>with the file path percent-encoded.RepoTreeEntrycarries at leastName,Path, andType("blob"/"tree"), and 404/403 responses surface as errors distinguishable enough for callers to wrap with context.
Verification
cd apps/backend && go test ./internal/gitlab/... -race
Files Likely Touched
apps/backend/internal/gitlab/models.go—RepoTreeEntry.apps/backend/internal/gitlab/client.go— interface methods.apps/backend/internal/gitlab/pat_client.go— REST implementation.apps/backend/internal/gitlab/mock_client.go— in-memory implementation.apps/backend/internal/gitlab/noop_client.go— stubs.apps/backend/internal/gitlab/pat_client_test.go(or a newpat_client_repo_contents_test.go).
Inputs
- Spec
## API Surface→### gitlab.Client. ListProjectBranchesatpat_client.go:531is the closest existing REST method — mirror its endpoint construction,projectRef()helper usage, pagination, and error handling.- All
Clientmethods takeprojectPath(never owner+repo); match that.
Risks
- Nested subgroup paths silently 404 if
projectRef()does not encode the full path as a single segment. Cover with an explicit multi-segment test. - A directory larger than one page truncates the synced workflow set. Paginate and assert it in a test.
Output Contract
Four GitLab client implementations compile against the extended interface, with
tests covering nested paths, pagination, and the not-found path. No consumer
outside internal/gitlab changes in this task.