VCS Adapters
Use the VCS adapters to resolve a PR/MR by its ID and compute the diff automatically. Supported platforms: GitHub, GitLab, and Bitbucket.
Overview
- Set
vcs.platform
togithub
,gitlab
, orbitbucket
in your config. - Configure
vcs.repository
,vcs.access_token
, and optionallyvcs.api_base
andvcs.timeout
. - For GitLab, also set
vcs.project_id
for project identification. - Use
${ENV_VAR}
syntax in config to reference environment variables. - Run
php bin/aicr review --id <number> --output summary
.
GitHub setup
- Token:
vcs.access_token
in config or${GITHUB_TOKEN}
env variable - Repository:
vcs.repository
asowner/repo
format - API Base:
vcs.api_base
(defaults tohttps://api.github.com
) - Permissions: read PRs; write if you plan to post comments.
GitLab setup
- Token:
vcs.access_token
in config or${GITLAB_TOKEN}
env variable (uses PRIVATE-TOKEN authentication) - Project ID:
vcs.project_id
as numeric ID or full pathnamespace/repo
- Repository:
vcs.repository
(used as fallback for project identification) - API Base:
vcs.api_base
(defaults tohttps://gitlab.com/api/v4
, customize for self-hosted)
Bitbucket setup
- Repository:
vcs.repository
asworkspace/repository
format - Token:
vcs.access_token
in config or${BITBUCKET_TOKEN}
env variable (uses Bearer authentication) - API Base:
vcs.api_base
(defaults tohttps://api.bitbucket.org/2.0
) - Timeout:
vcs.timeout
in seconds (optional, defaults to 30) - Permissions: read Pull Requests; write if you plan to post comments
How it works without --diff-file
- Resolve base/head branches from the PR number (GitHub), MR IID (GitLab), or PR ID (Bitbucket) via the platform API.
- Run
git fetch --all
, fetch both branches and computegit diff base...head
. - Analyze the resulting unified diff with the pipeline.
Posting comments
Pass --comment
to post the human summary back to the PR/MR via the adapter.
Troubleshooting
- 401/403: check
vcs.access_token
presence and scopes/permissions. - Not found: verify
vcs.repository
/vcs.project_id
and PR/MR ID (--id
) correctness. - Self-hosted GitLab: ensure
vcs.api_base
ends with/api/v4
. - Environment variables: use
${VAR_NAME}
syntax in config file to reference environment variables.