Skip to content

refactor: prepare gitprovider for multi-provider support - #25651

Merged
johnstcn merged 3 commits into
mainfrom
cj/gitsync-gitlab-1
May 25, 2026
Merged

johnstcn merged 3 commits into
mainfrom
cj/gitsync-gitlab-1

Conversation

@johnstcn

@johnstcn johnstcn commented May 25, 2026 •

Copy link
Copy Markdown
Member

Part of CODAGT-146

Mechanical refactor preparing the gitprovider package for additional provider implementations.

Changes:

  • gitprovider.New now returns (Provider, error) instead of just Provider
  • Extract shared helpers (parseRetryAfter, checkRateLimitError, countDiffLines, escapePathPreserveSlashes) out of github.go into gitprovider.go
  • Update all callers (db2sdk, exp_chats, gitsync) for the new signature
  • Add error logging when provider construction fails in resolveExternalAuth
  • Thread context through provider resolution in gitsync

This is part 1 of a 3-PR stack adding GitLab support to gitsync:

  1. This PR: Refactor shared infrastructure
  2. cj/gitsync-gitlab-2: GitLab provider implementation + unit tests
  3. cj/gitsync-gitlab-3: VCR integration tests + cassettes

Note: TestGetChatDiffContents/SuccessWithCachedRepositoryReference is failing in this PR, but passes in the next PR up the stack.

Generated with Coder by @johnstcn

… support

- Change gitprovider.New to return (Provider, error)
- Extract shared helpers (parseRetryAfter, checkRateLimitError,
  countDiffLines, escapePathPreserveSlashes) from github.go
- Update all callers (db2sdk, exp_chats, gitsync) for new signature
- Add error logging for provider construction failures
- Thread context through provider resolution
@johnstcn johnstcn changed the title refactor(coderd/externalauth): prepare gitprovider for multi-provider support refactor(coderd): prepare gitprovider for multi-provider support May 25, 2026
@johnstcn
johnstcn marked this pull request as ready for review May 25, 2026 15:53
Copilot AI review requested due to automatic review settings May 25, 2026 15:53

This comment was marked as off-topic.

Part of CODAGT-146

Implement GitLab support for the `gitprovider` package, enabling PR
status, diff fetching, branch-to-MR resolution, and URL parsing/building
for GitLab repositories.

Capabilities:
- `FetchPullRequestStatus`: MR metadata, approval state, diff stats via
`ListMergeRequestDiffs`
- `FetchPullRequestDiff` / `FetchBranchDiff`: raw diffs with size guards
and rate limit detection on raw HTTP paths
- `ResolveBranchPullRequest`: find open MRs for a branch
- URL parsing/building: handles nested groups, forks, and self-hosted
instances

Also updates `docs/ai-coder/agents/platform-controls/git-providers.md`
with GitLab configuration and known limitations.

Stacked on #25651. Part 2 of 3.

> Generated with [Coder](https://coder.com) by @johnstcn
@coderagents

coderagents Bot commented May 25, 2026

Copy link
Copy Markdown
Contributor

Documentation Check

Updates Completed

  • docs/ai-coder/agents/platform-controls/git-providers.md - Updated with GitLab configuration, required scopes, self-hosted setup, and known limitations

The documentation has been properly updated to reflect GitLab support, including configuration examples for both gitlab.com and self-hosted instances, scope requirements (read_api and write_repository), and semantic differences vs GitHub.


Automated review via Coder Agents

@johnstcn johnstcn changed the title refactor(coderd): prepare gitprovider for multi-provider support refactor: prepare gitprovider for multi-provider support May 25, 2026
@johnstcn
johnstcn merged commit 579daaf into main May 25, 2026
31 checks passed
@johnstcn
johnstcn deleted the cj/gitsync-gitlab-1 branch May 25, 2026 16:41
@github-actions github-actions Bot locked and limited conversation to collaborators May 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants