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.platformtogithub,gitlab, orbitbucketin your config. - Configure
vcs.repository,vcs.access_token, and optionallyvcs.api_baseandvcs.timeout. - For GitLab, also set
vcs.project_idfor 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_tokenin config or${GITHUB_TOKEN}env variable - Repository:
vcs.repositoryasowner/repoformat - 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_tokenin config or${GITLAB_TOKEN}env variable (uses PRIVATE-TOKEN authentication) - Project ID:
vcs.project_idas 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.repositoryasworkspace/repositoryformat - Token:
vcs.access_tokenin config or${BITBUCKET_TOKEN}env variable (uses Bearer authentication) - API Base:
vcs.api_base(defaults tohttps://api.bitbucket.org/2.0) - Timeout:
vcs.timeoutin 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_tokenpresence and scopes/permissions. - Not found: verify
vcs.repository/vcs.project_idand PR/MR ID (--id) correctness. - Self-hosted GitLab: ensure
vcs.api_baseends with/api/v4. - Environment variables: use
${VAR_NAME}syntax in config file to reference environment variables.
