Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ensure labels in diff config are defined#12

Merged
dhth merged 3 commits intomainfrom
ensure-labels-in-diff-config-are-defined
Nov 18, 2025
Merged

ensure labels in diff config are defined#12
dhth merged 3 commits intomainfrom
ensure-labels-in-diff-config-are-defined

Conversation

@dhth
Copy link
Owner

@dhth dhth commented Nov 18, 2025

No description provided.

@coderabbitai
Copy link

coderabbitai bot commented Nov 18, 2025

📝 Walkthrough

Walkthrough

Adds documentation for new diff-related configuration and CLI flags: a diffConfig block with baseLabel, headLabel, and cmd (array); an ignoreModules list; -d/--include-diffs flag; and --stdout-plain flag. Adds label membership validation to rawDiffConfig.parse(labels map[string]struct{}), updates callers to pass collected source labels, and adjusts source validation to only retain sources with non-empty labels and existing paths. Tests updated to supply sourceLabels to parse and to cover incorrect-label cases. A test YAML with a diffConfig entry was added.

Pre-merge checks

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Description check ❓ Inconclusive No pull request description was provided by the author, making it impossible to assess whether the intent is clearly communicated. Add a description explaining the purpose of the label validation checks and any relevant context for reviewers.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'ensure labels in diff config are defined' accurately summarizes the main change across the codebase: validation of diff config labels against defined source labels.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between 91e8fae and 6ea78c7.

⛔ Files ignored due to path filters (1)
  • tests/cli/__snapshots__/TestCompareModulesCmd_fails_for_incorrect_config_1.snap is excluded by !**/*.snap
📒 Files selected for processing (2)
  • internal/domain/validation.go (3 hunks)
  • tests/cli/testdata/config/bad.yml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/domain/validation.go
🔇 Additional comments (1)
tests/cli/testdata/config/bad.yml (1)

14-17: Valid test case for label validation.

The new diffConfig block correctly demonstrates a case where the referenced labels (prod and unknown) don't exist in the sources list. This aligns with the PR objective to validate that labels in diff config are defined, and it's appropriate for a "bad.yml" test file.

One minor note: the cmd array contains an empty string as the second element. Verify this is intentional for testing empty argument handling, or if it should be removed.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
README.md (1)

61-75: Clarify diffConfig label constraints in the docs

The example and flags look good, but now that diffConfig.baseLabel/headLabel must refer to labels defined under sources, it would help to explicitly say so here. A short note like “baseLabel/headLabel must match one of the sources[].label values” would make the new validation behavior clearer to users configuring diffs.

Also applies to: 100-103

internal/domain/config_test.go (1)

11-18: Nice coverage of diffConfig parsing; slight test cleanup possible

The updated tests exercise the new label-aware parsing well (including whitespace and incorrect-label cases), which should keep regressions in check. You could simplify the setup a bit with a literal:

sourceLabels := map[string]struct{}{
	"base": {},
	"head": {},
}

Functionally equivalent, just a bit tighter.

Also applies to: 28-49, 64-85, 87-101

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between a41aea9 and 91e8fae.

⛔ Files ignored due to path filters (1)
  • internal/domain/__snapshots__/config_test.snap is excluded by !**/*.snap
📒 Files selected for processing (4)
  • README.md (2 hunks)
  • internal/domain/config.go (1 hunks)
  • internal/domain/config_test.go (5 hunks)
  • internal/domain/validation.go (2 hunks)
🔇 Additional comments (1)
internal/domain/config.go (1)

91-112: Label-aware rawDiffConfig.parse implementation looks correct

The updated parse correctly:

  • trims BaseLabel/HeadLabel,
  • enforces non-emptiness, and
  • verifies each against the provided labels set,

while preserving the existing cmd trimming/validation behavior. With sourceLabels populated using trimmed labels (as suggested in validation.go), this should give clear and accurate errors whenever diffConfig refers to undefined labels.

Also applies to: 114-138

@dhth dhth merged commit 56f4327 into main Nov 18, 2025
10 checks passed
@dhth dhth deleted the ensure-labels-in-diff-config-are-defined branch November 18, 2025 01:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant