Skip to content

Commit 2f48422

Browse files
authored
Add comprehensive tag and stash management API
Add comprehensive tag and stash management API
2 parents f8c414c + 7038d1d commit 2f48422

File tree

9 files changed

+2553
-29
lines changed

9 files changed

+2553
-29
lines changed

CLAUDE.md

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
- Author struct: name, email, timestamp with Display implementation
5757
- CommitMessage: subject and optional body parsing
5858
- CommitDetails: full commit info including file changes and diff stats
59-
- **Core types**: Hash (in src/types.rs), IndexStatus, WorktreeStatus, FileEntry (in src/commands/status.rs), Branch, BranchList, BranchType (in src/commands/branch.rs), Commit, CommitLog, Author, CommitMessage, CommitDetails, LogOptions (in src/commands/log.rs), RepoConfig (in src/commands/config.rs), Remote, RemoteList, FetchOptions, PushOptions (in src/commands/remote.rs), RestoreOptions, RemoveOptions, MoveOptions (in src/commands/files.rs), DiffOutput, FileDiff, DiffStatus, DiffOptions, DiffStats, DiffChunk, DiffLine, DiffLineType (in src/commands/diff.rs)
59+
- **Core types**: Hash (in src/types.rs), IndexStatus, WorktreeStatus, FileEntry (in src/commands/status.rs), Branch, BranchList, BranchType (in src/commands/branch.rs), Commit, CommitLog, Author, CommitMessage, CommitDetails, LogOptions (in src/commands/log.rs), RepoConfig (in src/commands/config.rs), Remote, RemoteList, FetchOptions, PushOptions (in src/commands/remote.rs), RestoreOptions, RemoveOptions, MoveOptions (in src/commands/files.rs), DiffOutput, FileDiff, DiffStatus, DiffOptions, DiffStats, DiffChunk, DiffLine, DiffLineType (in src/commands/diff.rs), Tag, TagList, TagType, TagOptions (in src/commands/tag.rs), Stash, StashList, StashOptions, StashApplyOptions (in src/commands/stash.rs)
6060
- **Utility functions**: git(args, working_dir) -> Result<String>, git_raw(args, working_dir) -> Result<Output>
6161
- **Remote management**: Full remote operations with network support
6262
- Repository::add_remote(name, url) -> Result<()> - add remote repository
@@ -99,8 +99,32 @@
9999
- DiffOptions: context_lines, whitespace handling, path filtering, output formats (name-only, stat, numstat)
100100
- DiffStats: files_changed, insertions, deletions with aggregate statistics
101101
- Complete filtering: files_with_status(), iter(), is_empty(), len() for result analysis
102-
- **Command modules**: status.rs, add.rs, commit.rs, branch.rs, log.rs, config.rs, remote.rs, files.rs, diff.rs (in src/commands/)
103-
- **Testing**: 144+ tests covering all functionality with comprehensive edge cases
102+
- **Tag operations**: Complete tag management with type-safe API
103+
- Repository::tags() -> Result<TagList> - list all tags with comprehensive filtering
104+
- Repository::create_tag(name, target) -> Result<Tag> - create lightweight tag
105+
- Repository::create_tag_with_options(name, target, options) -> Result<Tag> - create tag with options
106+
- Repository::delete_tag(name) -> Result<()> - delete tag
107+
- Repository::show_tag(name) -> Result<Tag> - detailed tag information
108+
- Tag struct: name, hash, tag_type, message, tagger, timestamp
109+
- TagType enum: Lightweight, Annotated
110+
- TagList: Box<[Tag]> with iterator methods (iter, lightweight, annotated), search (find, find_containing, for_commit), counting (len, lightweight_count, annotated_count)
111+
- TagOptions builder: annotated, force, message, sign with builder pattern (with_annotated, with_force, with_message, with_sign)
112+
- Author struct: name, email, timestamp for annotated tag metadata
113+
- **Stash operations**: Complete stash management with type-safe API
114+
- Repository::stash_list() -> Result<StashList> - list all stashes with comprehensive filtering
115+
- Repository::stash_save(message) -> Result<Stash> - create simple stash
116+
- Repository::stash_push(message, options) -> Result<Stash> - create stash with options
117+
- Repository::stash_apply(index, options) -> Result<()> - apply stash without removing it
118+
- Repository::stash_pop(index, options) -> Result<()> - apply and remove stash
119+
- Repository::stash_show(index) -> Result<String> - show stash contents
120+
- Repository::stash_drop(index) -> Result<()> - remove specific stash
121+
- Repository::stash_clear() -> Result<()> - remove all stashes
122+
- Stash struct: index, message, hash, branch, timestamp
123+
- StashList: Box<[Stash]> with iterator methods (iter), search (find_containing, for_branch), access (latest, get), counting (len, is_empty)
124+
- StashOptions builder: untracked, keep_index, patch, staged_only, paths with builder pattern (with_untracked, with_keep_index, with_patch, with_staged_only, with_paths)
125+
- StashApplyOptions builder: restore_index, quiet with builder pattern (with_index, with_quiet)
126+
- **Command modules**: status.rs, add.rs, commit.rs, branch.rs, log.rs, config.rs, remote.rs, files.rs, diff.rs, tag.rs, stash.rs (in src/commands/)
127+
- **Testing**: 161+ tests covering all functionality with comprehensive edge cases
104128
- Run `cargo fmt && cargo build && cargo test && cargo clippy --all-targets --all-features -- -D warnings` after code changes
105129
- Make sure all examples are running
106130

@@ -118,6 +142,8 @@ The `examples/` directory contains comprehensive demonstrations of library funct
118142
- **remote_operations.rs**: Complete remote management - add/remove/rename remotes, fetch/push operations with options, network operations, error handling
119143
- **file_lifecycle_operations.rs**: Comprehensive file management - restore/reset/remove/move operations, .gitignore management, advanced file lifecycle workflows, staging area manipulation
120144
- **diff_operations.rs**: Comprehensive diff operations showcase - unstaged/staged diffs, commit comparisons, advanced options (whitespace handling, path filtering), output formats (name-only, stat, numstat), and change analysis
145+
- **tag_operations.rs**: Complete tag management - create/delete/list tags, lightweight vs annotated tags, TagOptions builder, tag filtering and search, comprehensive tag workflows
146+
- **stash_operations.rs**: Complete stash management - save/apply/pop/list stashes, advanced options (untracked files, keep index, specific paths), stash filtering and search, comprehensive stash workflows
121147
- **error_handling.rs**: Comprehensive error handling patterns - GitError variants, recovery strategies
122148

123149
Run examples with: `cargo run --example <example_name>`

PLAN.md

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
- **Remote management with full CRUD operations**
1616
- **Network operations (fetch, push, clone) with advanced options**
1717
- **File lifecycle operations (restore, reset, remove, move, .gitignore management)**
18+
- **Diff operations with multi-level API and comprehensive options**
19+
- **Tag management with comprehensive operations and filtering**
20+
- **Stash operations with comprehensive management and filtering**
1821

1922
## ✅ Phase 1: Essential Remote Operations (COMPLETED)
2023

@@ -61,29 +64,41 @@
6164
- [ ] Pull operations (fetch + merge)
6265

6366

64-
## Phase 3: Release Management (Medium Priority)
67+
## Phase 3: Tag Operations (COMPLETED)
6568

66-
### Tag Operations
67-
- [ ] `repo.create_tag(name, message)` - Create annotated tag
68-
- [ ] `repo.create_lightweight_tag(name)` - Create lightweight tag
69-
- [ ] `repo.list_tags()` - List tags with filtering options
70-
- [ ] `repo.delete_tag(name)` - Delete tag
71-
- [ ] `repo.tag_info(name)` - Get tag details
72-
- [ ] `repo.push_tags()` - Push tags to remote
69+
### ✅ Tag Management
70+
- [x] `repo.tags()` - List all tags with comprehensive filtering
71+
- [x] `repo.create_tag(name, target)` - Create lightweight tag
72+
- [x] `repo.create_tag_with_options(name, target, options)` - Create tag with options
73+
- [x] `repo.delete_tag(name)` - Delete tag
74+
- [x] `repo.show_tag(name)` - Get detailed tag information
75+
- [x] TagList with filtering (lightweight, annotated, find_containing, for_commit)
76+
- [x] TagOptions builder with force, message, sign, annotated options
77+
- [x] Type-safe TagType enum (Lightweight, Annotated)
78+
- [x] Complete tag metadata support (message, tagger, timestamp)
79+
80+
## Phase 5: Release Management (Medium Priority)
7381

7482
### Archive & Export
7583
- [ ] `repo.archive(format, output_path)` - Create repository archive
7684
- [ ] `repo.export_commit(hash, path)` - Export specific commit
7785

78-
## Phase 4: Development Workflow (Medium Priority)
86+
## ✅ Phase 4: Stash Operations (COMPLETED)
87+
88+
### ✅ Stash Management
89+
- [x] `repo.stash_save(message)` - Save current changes
90+
- [x] `repo.stash_push(message, options)` - Stash with advanced options
91+
- [x] `repo.stash_list()` - List all stashes with comprehensive filtering
92+
- [x] `repo.stash_apply(index, options)` - Apply stash without removing it
93+
- [x] `repo.stash_pop(index, options)` - Apply and remove stash
94+
- [x] `repo.stash_drop(index)` / `repo.stash_clear()` - Remove stashes
95+
- [x] `repo.stash_show(index)` - Show stash contents
96+
- [x] StashList with filtering (find_containing, for_branch, latest, get)
97+
- [x] StashOptions builder with untracked, keep_index, patch, staged_only, paths
98+
- [x] StashApplyOptions builder with restore_index, quiet options
99+
- [x] Complete stash metadata support (index, message, hash, branch, timestamp)
79100

80-
### Stash Management
81-
- [ ] `repo.stash_save(message)` - Save current changes
82-
- [ ] `repo.stash_push(files, message)` - Stash specific files
83-
- [ ] `repo.stash_list()` - List all stashes
84-
- [ ] `repo.stash_pop()` / `repo.stash_apply(index)` - Apply stashes
85-
- [ ] `repo.stash_drop(index)` / `repo.stash_clear()` - Remove stashes
86-
- [ ] `repo.stash_show(index)` - Show stash contents
101+
## Phase 6: Development Workflow (Medium Priority)
87102

88103
### Merge & Rebase
89104
- [ ] `repo.merge(branch)` / `repo.merge_commit(hash)` - Merge operations
@@ -92,7 +107,7 @@
92107
- [ ] Conflict resolution helpers and status
93108
- [ ] `repo.abort_merge()` / `repo.abort_rebase()` - Abort operations
94109

95-
## Phase 5: Advanced Configuration (Medium Priority)
110+
## Phase 7: Advanced Configuration (Medium Priority)
96111

97112
### Enhanced Configuration
98113
- [ ] `Config::global()` - Global git configuration
@@ -107,7 +122,7 @@
107122
- [ ] `repo.hooks().remove(hook_type)` - Remove hooks
108123
- [ ] Pre-built common hooks (pre-commit, pre-push, etc.)
109124

110-
## Phase 6: Repository Analysis (Low Priority)
125+
## Phase 8: Repository Analysis (Low Priority)
111126

112127
### History & Inspection
113128
- [ ] `repo.show(hash)` - Show commit with full diff
@@ -121,7 +136,7 @@
121136
- [ ] `repo.size_analysis()` - Large files, repository size analysis
122137
- [ ] `repo.gc()` / `repo.fsck()` - Maintenance operations
123138

124-
## Phase 7: Advanced Features (Low Priority)
139+
## Phase 9: Advanced Features (Low Priority)
125140

126141
### Worktree Support
127142
- [ ] `repo.worktree_add(path, branch)` - Add worktree

0 commit comments

Comments
 (0)