feat(check): add --base flag for cross-file rule parity between local and CI#339
Merged
Conversation
… and CI `ctx.changedFiles` was empty by default, making cross-file dependency rules (e.g., "if config.yml changed, manifest.yml must also change") silently pass locally. These rules only worked in CI via a non-obvious `git reset --soft` workaround. Now `archgate check` auto-detects the base branch and populates `changedFiles` with the branch diff (`git diff <base>...HEAD`). The resolution priority is: `--staged` flag (skips base) → `--base <ref>` flag → `.archgate/config.json` `baseBranch` → git auto-detect → empty. Changes: - Add `detectBaseRef()` and `getFilesChangedSinceRef()` to git-files.ts - Add `--base [ref]` flag to `check` and `review-context` commands - Extend `ProjectConfigSchema` with optional `baseBranch` field - Extend `runChecks` and `buildReviewContext` options with `base` - Add `used_base` to check telemetry event - Add unit tests for new git helpers and integration tests for --base - Document Bun.env parallel test leakage pattern in agent memory Closes #338 Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
Deploying archgate-cli with
|
| Latest commit: |
88cb873
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://a1bbbfb9.archgate-cli.pages.dev |
| Branch Preview URL: | https://feat-check-base-flag.archgate-cli.pages.dev |
Contributor
Code Coverage
Full HTML report available in workflow artifacts. Per-directory breakdown
|
… tests Extract duplicated base resolution logic from check.ts and review-context.ts into a shared resolveBaseRef() function in git-files.ts. Add integration tests for review-context --base to close the coverage gap. Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
Update CLI reference, rule API, concepts, writing-rules guide, and CI integration guide to document the new --base flag and automatic base branch detection for changedFiles. Includes both English and Portuguese (pt-br) translations. Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ctx.changedFileswith the branch diff (git diff <base>...HEAD), giving local developers the same cross-file rule coverage that CI gets — without needinggit reset --softworkarounds--base [ref]flag tocheckandreview-contextcommands with resolution priority:--staged→--base <ref>→ configbaseBranch→ git auto-detect → emptybaseBranchfield to.archgate/config.jsonfor project-level overrideCloses #338
Test plan
bun run validatepasses (lint, typecheck, format, test, ADR check, knip, build)detectBaseRef()detects local main/master branches, returns null for non-git dirsgetFilesChangedSinceRef()returns correct branch diff, empty when on base branch--base mainwith cross-file rule fires violation when only one file changed--base mainpasses when both files changed--stagedtakes precedence over base auto-detectionbun run cli checkon main → changedFiles empty (no diff)bun run cli check --base main→ changedFiles populated