|
| 1 | +# TASK_065: Fix Default Branch Assumptions |
| 2 | + |
| 3 | +## Purpose |
| 4 | +Fix hardcoded assumptions about default branch names ("main"/"master") throughout the codebase to support any configured default branch name (like "develop", "trunk", etc.). |
| 5 | + |
| 6 | +## Status |
| 7 | +**in_progress** - Started: 2025-09-16 19:04 |
| 8 | + |
| 9 | +## Requirements |
| 10 | +- [ ] Improve GitHelpers.getDefaultBranch() to use `git config init.defaultBranch` when no remote HEAD is available |
| 11 | +- [ ] Update capture-plan.ts to use dynamic default branch detection instead of hardcoded checks |
| 12 | +- [ ] Update config.ts to dynamically determine default protected branches based on actual project default |
| 13 | +- [ ] Update pre-tool-validation.ts to use GitHelpers for fallback instead of hardcoded array |
| 14 | +- [ ] Update relevant tests to properly mock getDefaultBranch() behavior |
| 15 | +- [ ] Ensure all changes maintain backward compatibility |
| 16 | + |
| 17 | +## Success Criteria |
| 18 | +- [ ] Code works correctly with any default branch name (not just "main"/"master") |
| 19 | +- [ ] GitHelpers.getDefaultBranch() follows proper fallback hierarchy: remote HEAD → git config → branch existence → final fallback |
| 20 | +- [ ] No hardcoded branch name assumptions remain in the identified files |
| 21 | +- [ ] All existing tests pass |
| 22 | +- [ ] New behavior is properly tested |
| 23 | + |
| 24 | +## Technical Approach |
| 25 | +1. **GitHelpers Enhancement**: Add `git config init.defaultBranch` check as intermediate fallback |
| 26 | +2. **Dynamic Detection**: Replace all hardcoded checks with calls to GitHelpers.getDefaultBranch() |
| 27 | +3. **Config Awareness**: Make protected branches configuration aware of project's actual default branch |
| 28 | +4. **Graceful Degradation**: Maintain existing fallback behavior as last resort |
| 29 | + |
| 30 | +## Current Focus |
| 31 | +Analyzing existing GitHelpers.getDefaultBranch() implementation and planning improvements to the fallback hierarchy. |
| 32 | + |
| 33 | +## Next Steps |
| 34 | +1. Examine current GitHelpers.getDefaultBranch() implementation |
| 35 | +2. Add git config fallback to the method |
| 36 | +3. Update capture-plan.ts hardcoded checks |
| 37 | +4. Modify config.ts default protected branches logic |
| 38 | +5. Update pre-tool-validation.ts fallback mechanism |
| 39 | +6. Review and update tests as needed |
0 commit comments