feat: Add TOML support, new output formats, git integration, GitHub Action, and directory comparison#11
Conversation
…ction, and directory comparison This major feature update adds six highly-requested enhancements: **New Output Formats:** - Add --stat flag for git-style statistics summary with visual bars - Add --side-by-side output format for two-column comparison view - Add --git-diff output format for git diff driver integration **TOML Format Support:** - Add TOML parser for Rust (Cargo.toml) and Python (pyproject.toml) files - Handle TOML arrays of tables (e.g., [[bin]]) - Add comprehensive test coverage for TOML parsing **Directory Comparison:** - Add --recursive/-r flag for comparing entire directories - Automatically detect and compare all config files (.yaml, .json, .hcl, .toml, .tf) - Report added/removed files and diff existing files - Display per-file summaries and overall statistics **Git Diff Driver Integration:** - Create comprehensive setup guide at docs/GIT_DIFF_DRIVER.md - Enable automatic use of configdiff for git diff on config files - Support for .gitattributes configuration **GitHub Action:** - Add action.yml for GitHub Actions marketplace - Create detailed documentation at docs/GITHUB_ACTION.md - Support all CLI flags as action inputs - Enable easy CI/CD integration **Documentation Updates:** - Update README.md with all new features and examples - Update CLAUDE.md to document v0.3.0 development - Add git diff driver setup guide - Add GitHub Action usage guide with examples **Tests:** - Add comprehensive TOML parser tests (8 test cases) - All existing tests continue to pass - Test coverage for array of tables and nested structures Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…hold Add test coverage for all new features added in this PR: **Report Format Tests:** - Add TestGenerateStat with 3 test cases - Add TestGenerateSideBySide with 4 test cases - Add TestGenerateGitDiff with 4 test cases - Coverage for report package increased from 40.0% to 89.6% **Directory Comparison Tests:** - Add TestCollectConfigFiles to verify file scanning - Add TestFileExists with 3 test cases - Add TestCompareDirectories for full directory diff workflow - Add TestCompareWithDirectories for error handling - Coverage for cmd/configdiff increased from 29.4% to 69.1% **Coverage Results:** - Total coverage: 84.3% (above 80% threshold) - All tests passing - New functions fully tested Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Code ReviewI've reviewed PR #11 and found 2 issues that need to be addressed: Issue 1: Missing Test Coverage for New Report FunctionsFiles affected: The three new report format functions lack test coverage, which violates the project's comprehensive testing standards. Functions without tests:
CLAUDE.md violation: Per CLAUDE.md line 10:
Suggested fix: Add comprehensive tests following existing patterns in report/report_test.go:
Issue 2: Exit Code Bug in Directory ComparisonFile: When using The bug: The Current behavior:
Expected behavior: All files should be compared, summary displayed, then exit with code 1 if any changes were found. Suggested fix: Refactor |
**Issue**: When using --exit-code flag with directory comparison, the program would exit immediately upon finding the first file with differences, preventing comparison of remaining files and display of the summary. **Root Cause**: Both compareFiles() and compareDirectories() were calling os.Exit(1) directly when --exit-code was set and changes were found. When compareFiles() was called from compareDirectories(), this caused premature termination. **Previous Behavior**: 1. Start comparing directory files 2. First file with differences triggers os.Exit(1) in compareFiles() 3. Program terminates immediately 4. Remaining files never compared 5. Summary never displayed **Fixed Behavior**: 1. All files are compared 2. Summary is displayed 3. Then exit with code 1 if any changes were found **Changes**: - Refactored compareFiles() to return bool indicating if changes found - Refactored compareDirectories() to return bool indicating if changes found - Moved exit code handling to compare() function (main entry point) - Both functions now return results instead of calling os.Exit directly - The compare() function aggregates results and handles os.Exit **Tests Added**: - TestCompareFilesReturnValue: Verifies compareFiles returns correct boolean - TestDirectoryComparisonDoesNotExitEarly: Ensures all files are compared before exit, even with --exit-code flag set **Verification**: - All existing tests pass - New tests verify the fix - Manual testing confirms all files compared before exit - Coverage remains above threshold (84.1%) Fixes issue #2 from PR review comments. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Code Review - Testing inline commentsThis is a test comment to verify comment functionality. |
Code ReviewFound 4 high-priority issues that need to be addressed before merging: 1. 🐛 Bug: Premature exit during directory comparison with
|
Add GitHub Actions integration with has-changes and diff-output outputs. Convert output format tests to use golden files for better maintainability. Changes: - Add writeGitHubOutputs() to write GitHub Actions outputs - Detect GITHUB_OUTPUT env var and write outputs in correct format - Convert TestGenerateStat to golden file tests (4 test cases) - Convert TestGenerateSideBySide to golden file tests (5 test cases) - Convert TestGenerateGitDiff to golden file tests (5 test cases) - Add comprehensive tests for GitHub Actions output functionality - Fix variable redeclaration in compareFiles() Addresses PR review comments from #11: - Issue 3: GitHub Action outputs now fully implemented - Issue 4: Golden tests added for all new output formats Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* feat: Implement GitHub Action outputs and golden tests Add GitHub Actions integration with has-changes and diff-output outputs. Convert output format tests to use golden files for better maintainability. Changes: - Add writeGitHubOutputs() to write GitHub Actions outputs - Detect GITHUB_OUTPUT env var and write outputs in correct format - Convert TestGenerateStat to golden file tests (4 test cases) - Convert TestGenerateSideBySide to golden file tests (5 test cases) - Convert TestGenerateGitDiff to golden file tests (5 test cases) - Add comprehensive tests for GitHub Actions output functionality - Fix variable redeclaration in compareFiles() Addresses PR review comments from #11: - Issue 3: GitHub Action outputs now fully implemented - Issue 4: Golden tests added for all new output formats Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fix: Use randomized delimiter for GitHub Actions heredoc output Fix heredoc delimiter injection vulnerability by using a cryptographically random delimiter instead of fixed "EOF" string. Security issue: A config file containing "EOF" on its own line could prematurely terminate the heredoc and potentially inject arbitrary GitHub Actions workflow commands. Changes: - Generate random 16-byte delimiter prefixed with "ghadelimiter_" - Update tests to verify random delimiter format - Add test case specifically for EOF injection attack - Add reference to GitHub Actions multiline string documentation Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Summary
This PR implements six high-impact enhancements selected for v0.3.0 release:
Highest Impact Quick Wins ✨
Best Medium Effort Features 🚀
Key Changes
New Output Formats
--stat: Shows per-path statistics with visual bars (likegit diff --stat)--side-by-side: Two-column old/new value comparison--git-diff: Git-compatible diff format for diff driver integrationTOML Format Support
FormatTOMLto parse package[[bin]])Directory Comparison
--recursive/-rflagGit Integration
docs/GIT_DIFF_DRIVER.md.gitattributesconfiguration examplesGitHub Action
action.ymldocs/GITHUB_ACTION.mdDocumentation
Testing
Files Changed
Examples
TOML Diff
Directory Comparison
Statistics Output
GitHub Action Usage
Next Steps
🤖 Generated with Claude Code