|
| 1 | +# Plan: Fix Annotated Tag Detection Bug |
| 2 | + |
| 3 | +**Status**: In Progress (Phase 1 & 2 Complete, Phase 3 In Progress) |
| 4 | +**Priority**: High |
| 5 | +**Context**: zerv flow and zerv version commands do not properly detect annotated tags, causing version detection to fail when repositories use annotated tags instead of lightweight tags. |
| 6 | + |
| 7 | +## Goals |
| 8 | + |
| 9 | +1. Add comprehensive support for annotated tags in test utilities |
| 10 | +2. Create test cases that replicate the annotated tag bug |
| 11 | +3. Fix any issues in tag detection logic for annotated tags |
| 12 | +4. Ensure both annotated and lightweight tags work correctly |
| 13 | + |
| 14 | +## Implementation Plan |
| 15 | + |
| 16 | +### Phase 1: Enhance Test Infrastructure |
| 17 | + |
| 18 | +1. **Add annotated tag support to GitOperations trait** |
| 19 | + - Extend the `GitOperations` trait with a new method: `create_annotated_tag(&self, test_dir: &TestDir, tag: &str, message: &str) -> io::Result<()>` |
| 20 | + - Implement for both `NativeGit` and `DockerGit` |
| 21 | + - Use `git tag -a <tag> -m "<message>"` command |
| 22 | + |
| 23 | +2. **Add annotated tag support to GitRepoFixture** |
| 24 | + - Add `create_annotated_tag(self, tag: &str, message: &str) -> Self` method |
| 25 | + - Add `with_annotated_tag(self, tag: &str, message: &str) -> Self` builder-style method |
| 26 | + - Add static constructor: `GitRepoFixture::tagged_annotated(tag: &str, message: &str) -> Result<Self>` |
| 27 | + |
| 28 | +### Phase 2: Create Comprehensive Test Cases |
| 29 | + |
| 30 | +1. **Create annotated tag test mirroring existing lightweight tag test** |
| 31 | + - Duplicate `test_get_latest_tag_comprehensive` as `test_get_latest_tag_comprehensive_annotated` |
| 32 | + - Use annotated tags instead of lightweight tags |
| 33 | + - Test all scenarios: single tag, multiple tags, mixed formats, commit distances |
| 34 | + |
| 35 | +2. **Test mixed tag type scenarios** |
| 36 | + - Repository with both annotated and lightweight tags on same commit |
| 37 | + - Repository with annotated tags on different commits |
| 38 | + - Timestamp behavior differences between tag types |
| 39 | + |
| 40 | +3. **Test edge cases** |
| 41 | + - Annotated tag with special characters in message |
| 42 | + - Multiple annotated tags with different timestamps |
| 43 | + - Annotated tags with GPG signatures (if applicable) |
| 44 | + |
| 45 | +### Phase 3: Investigate and Fix Bug |
| 46 | + |
| 47 | +1. **Debug current tag detection with annotated tags** |
| 48 | + - Run existing git commands against repositories with annotated tags |
| 49 | + - Identify which commands fail or return unexpected results |
| 50 | + - Check if `git tag --merged` handles annotated tags correctly |
| 51 | + - Verify timestamp extraction works for both tag types |
| 52 | + |
| 53 | +2. **Fix tag detection logic if needed** |
| 54 | + - Update `get_merged_tags()` if it doesn't include annotated tags |
| 55 | + - Fix timestamp handling in `get_tag_timestamp()` if there are issues |
| 56 | + - Ensure `get_tag_commit_hash()` works correctly for annotated tags |
| 57 | + |
| 58 | +3. **Update git command execution** |
| 59 | + - Check if any git commands need different flags for annotated tags |
| 60 | + - Verify error handling covers annotated tag-specific failures |
| 61 | + |
| 62 | +### Phase 4: Integration Testing |
| 63 | + |
| 64 | +1. **Test with zerv flow command** |
| 65 | + - Create integration test using `TestCommand` with annotated tag repository |
| 66 | + - Verify version output is correct |
| 67 | + - Test all format options (auto, semver, pep440) |
| 68 | + |
| 69 | +2. **Test with zerv version command** |
| 70 | + - Similar integration test for standalone version command |
| 71 | + - Verify consistency between flow and version commands |
| 72 | + |
| 73 | +3. **Test real-world scenarios** |
| 74 | + - Import a real git repository with annotated tags |
| 75 | + - Test version detection on complex histories |
| 76 | + |
| 77 | +## Testing Strategy |
| 78 | + |
| 79 | +### Unit Tests |
| 80 | + |
| 81 | +- Test new annotated tag creation methods in test utilities |
| 82 | +- Test tag type detection (`git cat-file -t`) |
| 83 | +- Test timestamp extraction for both tag types |
| 84 | +- Test version parsing with annotated tags |
| 85 | + |
| 86 | +### Integration Tests |
| 87 | + |
| 88 | +- Use `ZERV_TEST_NATIVE_GIT=false ZERV_TEST_DOCKER=true` for Docker-based tests |
| 89 | +- Create comprehensive test scenarios covering all tag combinations |
| 90 | +- Test with multiple version formats |
| 91 | + |
| 92 | +### Manual Verification |
| 93 | + |
| 94 | +- Create test repositories manually with annotated tags |
| 95 | +- Verify zerv commands work correctly |
| 96 | +- Compare behavior with lightweight tags |
| 97 | + |
| 98 | +## Success Criteria |
| 99 | + |
| 100 | +1. ✅ All tests pass with annotated tags |
| 101 | +2. ✅ zerv flow detects annotated tags correctly |
| 102 | +3. ✅ zerv version detects annotated tags correctly |
| 103 | +4. ✅ Mixed repositories (both tag types) work correctly |
| 104 | +5. ✅ No regression in lightweight tag functionality |
| 105 | +6. ✅ Test coverage includes annotated tag scenarios |
| 106 | + |
| 107 | +## Documentation Updates |
| 108 | + |
| 109 | +1. Update testing documentation to mention annotated tag support |
| 110 | +2. Add examples of creating annotated tags in tests |
| 111 | +3. Document any differences in behavior between tag types |
| 112 | + |
| 113 | +## Files to Modify |
| 114 | + |
| 115 | +### New Files |
| 116 | + |
| 117 | +- None |
| 118 | + |
| 119 | +### Modified Files |
| 120 | + |
| 121 | +- `src/test_utils/git/mod.rs` - Add annotated tag method to trait |
| 122 | +- `src/test_utils/git/native.rs` - Implement annotated tag creation |
| 123 | +- `src/test_utils/git/docker.rs` - Implement annotated tag creation with verification |
| 124 | +- `src/test_utils/git/fixtures.rs` - Add annotated tag fixture methods |
| 125 | +- `src/vcs/git.rs` - Add comprehensive annotated tag tests |
| 126 | +- `tests/integration_tests/` - Add integration tests for annotated tags |
| 127 | + |
| 128 | +## Risk Assessment |
| 129 | + |
| 130 | +**Low Risk**: |
| 131 | + |
| 132 | +- Adding new methods to test utilities doesn't affect existing code |
| 133 | +- Tests are additive and don't change existing behavior |
| 134 | + |
| 135 | +**Medium Risk**: |
| 136 | + |
| 137 | +- Bug fixes to tag detection logic might affect lightweight tag behavior |
| 138 | +- Need thorough regression testing |
| 139 | + |
| 140 | +**Mitigation**: |
| 141 | + |
| 142 | +- Run full test suite after each change |
| 143 | +- Keep lightweight tag tests intact |
| 144 | +- Test with real repositories before merging |
0 commit comments