Skip to content

Commit 905e229

Browse files
committed
Merge branch 'master' of github.com:eugener/rustic-git
2 parents 41fabac + 9060f7b commit 905e229

File tree

9 files changed

+1663
-108
lines changed

9 files changed

+1663
-108
lines changed

CLAUDE.md

Lines changed: 23 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), Tag, TagList, TagType, TagOptions (in src/commands/tag.rs), Stash, StashList, StashOptions, StashApplyOptions (in src/commands/stash.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), ResetMode (in src/commands/reset.rs), MergeStatus, MergeOptions, FastForwardMode, MergeStrategy (in src/commands/merge.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
@@ -123,8 +123,26 @@
123123
- StashList: Box<[Stash]> with iterator methods (iter), search (find_containing, for_branch), access (latest, get), counting (len, is_empty)
124124
- StashOptions builder: untracked, keep_index, patch, staged_only, paths with builder pattern (with_untracked, with_keep_index, with_patch, with_staged_only, with_paths)
125125
- 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
126+
- **Reset operations**: Complete reset functionality with type-safe API
127+
- Repository::reset_soft(commit) -> Result<()> - move HEAD, keep index and working tree
128+
- Repository::reset_mixed(commit) -> Result<()> - move HEAD, reset index, keep working tree (default)
129+
- Repository::reset_hard(commit) -> Result<()> - reset HEAD, index, and working tree to commit state
130+
- Repository::reset_with_mode(commit, mode) -> Result<()> - flexible reset with explicit ResetMode
131+
- Repository::reset_file(path) -> Result<()> - unstage specific file (already exists in files.rs)
132+
- ResetMode enum: Soft, Mixed, Hard with const as_str() methods
133+
- Complete error handling for invalid commits and references
134+
- **Merge operations**: Complete merge functionality with comprehensive conflict handling
135+
- Repository::merge(branch) -> Result<MergeStatus> - merge branch into current branch
136+
- Repository::merge_with_options(branch, options) -> Result<MergeStatus> - merge with advanced options
137+
- Repository::merge_in_progress() -> Result<bool> - check if merge is currently in progress
138+
- Repository::abort_merge() -> Result<()> - cancel ongoing merge operation
139+
- MergeStatus enum: Success(Hash), FastForward(Hash), UpToDate, Conflicts(Vec<PathBuf>) with comprehensive status tracking
140+
- MergeOptions builder: fast_forward, strategy, commit_message, no_commit with builder pattern (with_fast_forward, with_strategy, with_message, with_no_commit)
141+
- FastForwardMode enum: Auto, Only, Never with const as_str() methods
142+
- MergeStrategy enum: Recursive, Ours, Theirs with const as_str() methods
143+
- Complete conflict detection with file-level granularity
144+
- **Command modules**: status.rs, add.rs, commit.rs, branch.rs, log.rs, config.rs, remote.rs, files.rs, diff.rs, tag.rs, stash.rs, reset.rs, merge.rs (in src/commands/)
145+
- **Testing**: 187+ tests covering all functionality with comprehensive edge cases
128146
- Run `cargo fmt && cargo build && cargo test && cargo clippy --all-targets --all-features -- -D warnings` after code changes
129147
- Make sure all examples are running
130148

@@ -144,6 +162,8 @@ The `examples/` directory contains comprehensive demonstrations of library funct
144162
- **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
145163
- **tag_operations.rs**: Complete tag management - create/delete/list tags, lightweight vs annotated tags, TagOptions builder, tag filtering and search, comprehensive tag workflows
146164
- **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
165+
- **reset_operations.rs**: Complete reset management - soft/mixed/hard resets, commit targeting, file-specific resets, error handling for invalid commits, comprehensive reset workflows
166+
- **merge_operations.rs**: Complete merge management - fast-forward/no-fast-forward merges, conflict detection and handling, merge status checking, abort operations, comprehensive merge workflows
147167
- **error_handling.rs**: Comprehensive error handling patterns - GitError variants, recovery strategies
148168

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

PLAN.md

Lines changed: 105 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Current Status
44

5-
**Completed Core Features**
5+
**Completed Core Features**
66
- Repository initialization and opening
77
- Enhanced file status checking with staged/unstaged tracking
88
- Staging operations (add, add_all, add_update)
@@ -18,96 +18,122 @@
1818
- **Diff operations with multi-level API and comprehensive options**
1919
- **Tag management with comprehensive operations and filtering**
2020
- **Stash operations with comprehensive management and filtering**
21-
22-
## ✅ Phase 1: Essential Remote Operations (COMPLETED)
23-
24-
### ✅ Remote Management
25-
- [x] `repo.add_remote(name, url)` - Add remote repository
26-
- [x] `repo.remove_remote(name)` - Remove remote
27-
- [x] `repo.list_remotes()` - List all remotes with URLs
28-
- [x] `repo.rename_remote(old_name, new_name)` - Rename remote
29-
- [x] `repo.get_remote_url(name)` - Get remote URL
30-
31-
### ✅ Network Operations
32-
- [x] `repo.fetch(remote)` / `repo.fetch_with_options()` - Fetch from remotes
33-
- [x] `repo.push(remote, branch)` / `repo.push_with_options()` - Push changes
34-
- [x] `repo.clone(url, path)` - Clone repository (static method)
35-
- [x] Advanced options with FetchOptions and PushOptions
36-
- [x] Type-safe builder patterns for network operations
37-
38-
## ✅ Phase 2: File Lifecycle Operations (COMPLETED)
39-
40-
### ✅ File Management
41-
- [x] `repo.checkout_file(path)` - Restore file from HEAD
42-
- [x] `repo.reset_file(path)` - Unstage specific file
43-
- [x] `repo.rm(paths)` - Remove files from repository
44-
- [x] `repo.rm_with_options(paths, options)` - Remove with advanced options
45-
- [x] `repo.mv(from, to)` - Move/rename files in repository
46-
- [x] `repo.mv_with_options(source, dest, options)` - Move with advanced options
47-
- [x] `repo.restore(paths, options)` - Restore files from specific commit with advanced options
48-
49-
### ✅ Ignore Management
50-
- [x] `repo.ignore_add(patterns)` - Add patterns to .gitignore
51-
- [x] `repo.ignore_check(file)` - Check if file is ignored
52-
- [x] `repo.ignore_list()` - List current ignore patterns
53-
54-
### ✅ Advanced File Operations
55-
- [x] RestoreOptions with source, staged, and worktree control
56-
- [x] RemoveOptions with force, recursive, cached, and ignore-unmatch
57-
- [x] MoveOptions with force, verbose, and dry-run modes
58-
- [x] Type-safe builder patterns for all file operations
59-
60-
### 🔄 Remote Branch Tracking (Future Enhancement)
21+
- **Reset operations with comprehensive reset modes and error handling**
22+
23+
##Phase 1: Essential Remote Operations (COMPLETED)
24+
25+
###Remote Management
26+
- [x]`repo.add_remote(name, url)` - Add remote repository
27+
- [x]`repo.remove_remote(name)` - Remove remote
28+
- [x]`repo.list_remotes()` - List all remotes with URLs
29+
- [x]`repo.rename_remote(old_name, new_name)` - Rename remote
30+
- [x]`repo.get_remote_url(name)` - Get remote URL
31+
32+
###Network Operations
33+
- [x]`repo.fetch(remote)` / `repo.fetch_with_options()` - Fetch from remotes
34+
- [x]`repo.push(remote, branch)` / `repo.push_with_options()` - Push changes
35+
- [x]`repo.clone(url, path)` - Clone repository (static method)
36+
- [x]Advanced options with FetchOptions and PushOptions
37+
- [x]Type-safe builder patterns for network operations
38+
39+
##Phase 2: File Lifecycle Operations (COMPLETED)
40+
41+
###File Management
42+
- [x]`repo.checkout_file(path)` - Restore file from HEAD
43+
- [x]`repo.reset_file(path)` - Unstage specific file
44+
- [x]`repo.rm(paths)` - Remove files from repository
45+
- [x]`repo.rm_with_options(paths, options)` - Remove with advanced options
46+
- [x]`repo.mv(from, to)` - Move/rename files in repository
47+
- [x]`repo.mv_with_options(source, dest, options)` - Move with advanced options
48+
- [x]`repo.restore(paths, options)` - Restore files from specific commit with advanced options
49+
50+
###Ignore Management
51+
- [x]`repo.ignore_add(patterns)` - Add patterns to .gitignore
52+
- [x]`repo.ignore_check(file)` - Check if file is ignored
53+
- [x]`repo.ignore_list()` - List current ignore patterns
54+
55+
###Advanced File Operations
56+
- [x]RestoreOptions with source, staged, and worktree control
57+
- [x]RemoveOptions with force, recursive, cached, and ignore-unmatch
58+
- [x]MoveOptions with force, verbose, and dry-run modes
59+
- [x]Type-safe builder patterns for all file operations
60+
61+
### Remote Branch Tracking (Future Enhancement)
6162
- [ ] `repo.branch_set_upstream(branch, remote_branch)` - Set tracking
6263
- [ ] `repo.branch_track(local, remote)` - Track remote branch
6364
- [ ] Remote branch listing and status
6465
- [ ] Pull operations (fetch + merge)
6566

6667

67-
## ✅ Phase 3: Tag Operations (COMPLETED)
68-
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)
68+
##Phase 3: Tag Operations (COMPLETED)
69+
70+
###Tag Management
71+
- [x]`repo.tags()` - List all tags with comprehensive filtering
72+
- [x]`repo.create_tag(name, target)` - Create lightweight tag
73+
- [x]`repo.create_tag_with_options(name, target, options)` - Create tag with options
74+
- [x]`repo.delete_tag(name)` - Delete tag
75+
- [x]`repo.show_tag(name)` - Get detailed tag information
76+
- [x]TagList with filtering (lightweight, annotated, find_containing, for_commit)
77+
- [x]TagOptions builder with force, message, sign, annotated options
78+
- [x]Type-safe TagType enum (Lightweight, Annotated)
79+
- [x]Complete tag metadata support (message, tagger, timestamp)
80+
81+
##Phase 4: Stash Operations (COMPLETED)
82+
83+
###Stash Management
84+
- [x]`repo.stash_save(message)` - Save current changes
85+
- [x]`repo.stash_push(message, options)` - Stash with advanced options
86+
- [x]`repo.stash_list()` - List all stashes with comprehensive filtering
87+
- [x]`repo.stash_apply(index, options)` - Apply stash without removing it
88+
- [x]`repo.stash_pop(index, options)` - Apply and remove stash
89+
- [x]`repo.stash_drop(index)` / `repo.stash_clear()` - Remove stashes
90+
- [x]`repo.stash_show(index)` - Show stash contents
91+
- [x]StashList with filtering (find_containing, for_branch, latest, get)
92+
- [x]StashOptions builder with untracked, keep_index, patch, staged_only, paths
93+
- [x]StashApplyOptions builder with restore_index, quiet options
94+
- [x]Complete stash metadata support (index, message, hash, branch, timestamp)
95+
96+
##Phase 5: Reset Operations (COMPLETED)
97+
98+
###Reset Management
99+
- [x]`repo.reset_soft(commit)` - Move HEAD, keep index and working tree
100+
- [x]`repo.reset_mixed(commit)` - Move HEAD, reset index, keep working tree (default)
101+
- [x]`repo.reset_hard(commit)` - Reset HEAD, index, and working tree to commit state
102+
- [x]`repo.reset_with_mode(commit, mode)` - Flexible reset with explicit ResetMode
103+
- [x]`repo.reset_file(path)` - Unstage specific file (already exists in files.rs)
104+
- [x]ResetMode enum with type-safe mode selection (Soft, Mixed, Hard)
105+
- [x]Complete error handling for invalid commits and references
106+
- [x]Comprehensive reset workflows with file-specific operations
107+
- [x]Cross-platform temporary directory handling for tests
108+
109+
##Phase 6: Merge Operations (COMPLETED)
110+
111+
###Merge Management
112+
- [x]`repo.merge(branch)` - Merge branch into current branch
113+
- [x]`repo.merge_with_options(branch, options)` - Merge with advanced options
114+
- [x]`repo.merge_in_progress()` - Check if merge is currently in progress
115+
- [x]`repo.abort_merge()` - Cancel ongoing merge operation
116+
- [x]MergeStatus enum with Success, FastForward, UpToDate, Conflicts variants
117+
- [x]MergeOptions builder with fast_forward, strategy, commit_message, no_commit options
118+
- [x]FastForwardMode enum: Auto, Only, Never with const as_str() methods
119+
- [x]MergeStrategy enum: Recursive, Ours, Theirs with const as_str() methods
120+
- [x]Complete conflict detection with file-level granularity
121+
- [x]Comprehensive merge workflows with error handling
122+
123+
## Phase 7: Release Management (Medium Priority)
81124

82125
### Archive & Export
83126
- [ ] `repo.archive(format, output_path)` - Create repository archive
84127
- [ ] `repo.export_commit(hash, path)` - Export specific commit
85128

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)
100-
101-
## Phase 6: Development Workflow (Medium Priority)
102-
103-
### Merge & Rebase
104-
- [ ] `repo.merge(branch)` / `repo.merge_commit(hash)` - Merge operations
129+
## Phase 8: Development Workflow (Medium Priority)
130+
131+
### Rebase & Cherry-pick
105132
- [ ] `repo.rebase(onto_branch)` - Rebase current branch
106133
- [ ] `repo.cherry_pick(hash)` - Cherry-pick commit
107-
- [ ] Conflict resolution helpers and status
108-
- [ ] `repo.abort_merge()` / `repo.abort_rebase()` - Abort operations
134+
- [ ] `repo.abort_rebase()` - Abort rebase operations
109135

110-
## Phase 7: Advanced Configuration (Medium Priority)
136+
## Phase 9: Advanced Configuration (Medium Priority)
111137

112138
### Enhanced Configuration
113139
- [ ] `Config::global()` - Global git configuration
@@ -122,7 +148,7 @@
122148
- [ ] `repo.hooks().remove(hook_type)` - Remove hooks
123149
- [ ] Pre-built common hooks (pre-commit, pre-push, etc.)
124150

125-
## Phase 8: Repository Analysis (Low Priority)
151+
## Phase 10: Repository Analysis (Low Priority)
126152

127153
### History & Inspection
128154
- [ ] `repo.show(hash)` - Show commit with full diff
@@ -136,7 +162,7 @@
136162
- [ ] `repo.size_analysis()` - Large files, repository size analysis
137163
- [ ] `repo.gc()` / `repo.fsck()` - Maintenance operations
138164

139-
## Phase 9: Advanced Features (Low Priority)
165+
## Phase 11: Advanced Features (Low Priority)
140166

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

README.md

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,33 @@ Rustic Git provides a simple, ergonomic interface for common Git operations. It
1616

1717
## Features
1818

19-
- ✅ Repository initialization and opening
20-
-**Enhanced file status checking** with separate staged/unstaged tracking
21-
-**Precise Git state representation** using IndexStatus and WorktreeStatus enums
22-
- ✅ File staging (add files, add all, add updates)
23-
- ✅ Commit creation with hash return
24-
-**Complete branch operations** with type-safe Branch API
25-
-**Branch management** (create, delete, checkout, list)
26-
-**Commit history & log operations** with multi-level API
27-
-**Advanced commit querying** with filtering and analysis
28-
-**Repository configuration management** with type-safe API
29-
-**Remote management** with full CRUD operations and network support
30-
-**Network operations** (fetch, push, clone) with advanced options
31-
-**File lifecycle operations** (restore, reset, remove, move, .gitignore management)
32-
-**Diff operations** with multi-level API and comprehensive options
33-
-**Tag management** with comprehensive operations and filtering
34-
-**Lightweight and annotated tags** with type-safe API
35-
-**Stash operations** with comprehensive stash management and filtering
36-
-**Advanced stash options** (untracked files, keep index, specific paths)
37-
- ✅ Type-safe error handling with custom GitError enum
38-
- ✅ Universal `Hash` type for Git objects
39-
-**Immutable collections** (Box<[T]>) for memory efficiency
40-
-**Const enum conversions** with zero runtime cost
41-
- ✅ Comprehensive test coverage (161+ tests)
19+
-Repository initialization and opening
20+
-**Enhanced file status checking** with separate staged/unstaged tracking
21+
-**Precise Git state representation** using IndexStatus and WorktreeStatus enums
22+
-File staging (add files, add all, add updates)
23+
-Commit creation with hash return
24+
-**Complete branch operations** with type-safe Branch API
25+
-**Branch management** (create, delete, checkout, list)
26+
-**Commit history & log operations** with multi-level API
27+
-**Advanced commit querying** with filtering and analysis
28+
-**Repository configuration management** with type-safe API
29+
-**Remote management** with full CRUD operations and network support
30+
-**Network operations** (fetch, push, clone) with advanced options
31+
-**File lifecycle operations** (restore, reset, remove, move, .gitignore management)
32+
-**Diff operations** with multi-level API and comprehensive options
33+
-**Tag management** with comprehensive operations and filtering
34+
-**Lightweight and annotated tags** with type-safe API
35+
-**Stash operations** with comprehensive stash management and filtering
36+
-**Advanced stash options** (untracked files, keep index, specific paths)
37+
-**Reset operations** with comprehensive soft/mixed/hard reset support
38+
-**Repository history management** with type-safe ResetMode API
39+
-**Merge operations** with comprehensive branch merging and conflict handling
40+
-**Advanced merge options** (fast-forward control, merge strategies, conflict detection)
41+
-Type-safe error handling with custom GitError enum
42+
-Universal `Hash` type for Git objects
43+
-**Immutable collections** (Box<[T]>) for memory efficiency
44+
-**Const enum conversions** with zero runtime cost
45+
-Comprehensive test coverage (187+ tests)
4246

4347
## Installation
4448

0 commit comments

Comments
 (0)