feat: add per-project config file support for unsafe branches#36
Open
ericanderson wants to merge 9 commits intomainfrom
Open
feat: add per-project config file support for unsafe branches#36ericanderson wants to merge 9 commits intomainfrom
ericanderson wants to merge 9 commits intomainfrom
Conversation
- Add SafetyConfig interface with support for: - Custom protected branch lists - Additional protected patterns (regex) - Allow/disallow unpushed commits - Require/skip merged PR validation - Custom safety rules with regex patterns - Implement configuration file discovery: - Environment variable: GHOULS_CONFIG - Repository root: .ghouls.json, .ghoulsrc.json, ghouls.config.json - User home: ~/.config/ghouls/config.json - Update branch safety checks to use configuration - Add comprehensive unit tests (69 new tests) - Add detailed documentation with examples - Maintain backward compatibility with existing behavior Resolves #17 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Owner
Author
|
config file in repo should be |
ericanderson
added a commit
that referenced
this pull request
Aug 7, 2025
- Changed repository-level config file path from multiple options (.ghouls.json, .ghoulsrc.json, ghouls.config.json) to single standardized path: .config/ghouls.json - Updated all tests to reflect the new config file location - Updated README documentation to show the new path structure - Maintains existing functionality for environment variable and user home config locations Addresses feedback on PR #36 to use .config/ghouls.json as the repository config file location.
- Changed repository-level config file path from multiple options (.ghouls.json, .ghoulsrc.json, ghouls.config.json) to single standardized path: .config/ghouls.json - Updated all tests to reflect the new config file location - Updated README documentation to show the new path structure - Maintains existing functionality for environment variable and user home config locations Addresses feedback on PR #36 to use .config/ghouls.json as the repository config file location.
039d7a4 to
86b6c1b
Compare
- Changed repository-level config file path from multiple options (.ghouls.json, .ghoulsrc.json, ghouls.config.json) to single standardized path: .config/ghouls.json - Updated all tests to reflect the new config file location - Updated README documentation to show the new path structure - Maintains existing functionality for environment variable and user home config locations Addresses feedback on PR #36 to use .config/ghouls.json as the repository config file location.
- Replace hardcoded regex patterns with configurable glob patterns using micromatch - Add release/* release-* hotfix/* patterns to default protected branches - Unify all branch protection logic into single micromatch.isMatch() call - Add comprehensive test coverage for glob pattern functionality - Maintain backward compatibility with exact string matching - Remove 13 lines of special-cased release/hotfix regex code This makes branch protection rules fully configurable through the config file while simplifying the codebase and improving maintainability.
- Implement $GHOULS_DEFAULT placeholder similar to Turborepo's $TURBO_DEFAULT$
- Allow users to extend default protected branches instead of replacing them
- Add expandDefaultPlaceholder() function with smart deduplication
- Support flexible positioning of placeholder anywhere in the array
- Add 17 comprehensive test cases covering all usage patterns
- Update README.md with detailed documentation and examples
- Maintain full backward compatibility with existing configurations
Usage example:
{
"protectedBranches": ["$GHOULS_DEFAULT", "custom-branch", "feature-*"]
}
This enables users to safely extend defaults while automatically receiving
new default patterns in future versions.
- Remove custom validateConfigWithZod wrapper function - Use Zod's native safeParse with formatZodErrors utility - Reorganize config types from src/types/ to src/config/ - Split GhoulsConfig schema and effective config logic - Maintain all existing error formatting and validation - All tests pass with improved error messages Resolves TODO to use Zod's error customization features.
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
Implements per-project configuration file support for customizing branch safety rules, resolving issue #17.
Key Features
Configuration File Discovery
Searches for configuration files in order of precedence:
GHOULS_CONFIG=/path/to/config.json.ghouls.json,.ghoulsrc.json,ghouls.config.json~/.config/ghouls/config.jsonImplementation Details
SafetyConfig,GhoulsConfiginterfaces with comprehensive validationisBranchSafeToDelete()andfilterSafeBranches()to support configurationExample Configuration
{ "version": "1.0", "safety": { "protectedBranches": ["main", "develop", "staging", "production"], "additionalProtectedPatterns": ["release/.*", "hotfix/.*"], "allowUnpushedCommits": false, "requireMergedPR": true, "customSafetyRules": [ { "name": "temp-branches", "pattern": "temp/.*", "reason": "temporary experiment branch" } ] } }Test Plan
🤖 Generated with Claude Code