Skip to content

Commit 3f519c0

Browse files
committed
docs: create TASK_065 files
1 parent 4a13fb7 commit 3f519c0

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

.claude/plans/065.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Plan: 065
2+
3+
Captured: 2025-09-16T23:04:30.687Z
4+
5+
## Plan: Fix Default Branch Assumptions
6+
7+
I've identified several places where the code assumes hardcoded default branch names ("main" or "master"). Here's my plan to fix them:
8+
9+
### Issues Found:
10+
1. **GitHelpers.getDefaultBranch()** - Currently tries remote tracking, then checks for "main", then "master", finally defaults to "main"
11+
2. **capture-plan.ts** - Hardcodes check for `currentBranch !== 'main' && currentBranch !== 'master'`
12+
3. **config.ts** - Default protected branches are hardcoded as `['main', 'master']`
13+
4. **pre-tool-validation.ts** - Falls back to hardcoded `['main', 'master']` if not configured
14+
15+
### Changes to Make:
16+
17+
1. **Improve GitHelpers.getDefaultBranch()** to be more robust:
18+
- Keep existing remote HEAD detection (already good)
19+
- If no remote, use `git config init.defaultBranch` to get user's configured default
20+
- Only fall back to checking for "main"/"master" existence as last resort
21+
22+
2. **Update capture-plan.ts**:
23+
- Replace hardcoded check with `currentBranch !== gitHelpers.getDefaultBranch(projectRoot)`
24+
25+
3. **Update config.ts**:
26+
- Change default protected branches to dynamically include the actual default branch
27+
- Will require making the config initialization aware of the project's default branch
28+
29+
4. **Update pre-tool-validation.ts**:
30+
- Use GitHelpers to get actual default branch for fallback instead of hardcoded array
31+
32+
5. **Update tests**:
33+
- Ensure tests properly mock getDefaultBranch() where needed
34+
- Tests already mostly do this correctly
35+
36+
This will ensure the code works with any default branch name (like "develop", "trunk", etc.) without assumptions.

.claude/tasks/TASK_065.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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

Comments
 (0)