Release v0.5.1
Bug Fixes
Fixed Empty Repository Error (#11)
Fixed a critical bug where gcop commit and gcop stats would crash with UnbornBranch error when run in an empty repository (no commits yet).
Before:
bash
$ git init
$ gcop commit
✗ Error: Git error: reference 'refs/heads/master' not found
class=Reference (4); code=UnbornBranch (-9)After:
bash
$ git init
$ gcop commit
✗ No staged changes found. Use 'git add' first.
# With staged files, it works normally:
$ echo "test" > test.txt
$ git add test.txt
$ gcop commit
[1/4] Analyzed 1 file(s), 1 change(s)
[2/4] Generating commit message...
# ... continues normallyWhat was fixed:
get_staged_diff(): Now correctly handles empty repositories by comparing against an empty tree instead of failingget_current_branch(): ReturnsNonefor unborn branches instead of crashingget_commit_history(): Returns empty list for repositories with no commits- Added
is_empty()method: Detects unborn branch state by catchingUnbornBrancherror
Impact:
- First-time users can now use
gcop commitimmediately in new repositories gcop statsshows a friendly warning instead of crashing in empty repos- Supports creating the first commit in a new repository
Technical Details
The fix introduces a new is_empty() method to the GitOperations trait that detects unborn branch state (when a repository has no commits yet). This method is used by three core functions to handle empty repositories gracefully:
- Empty repositories now compare staged changes against an empty tree (None) instead of HEAD
- Branch detection returns None for unborn branches
- Commit history returns an empty vector for empty repositories
All existing tests pass, and the fix has been validated with manual testing in empty repositories.
Upgrade Notes
Upgrading from v0.5.0 requires no action. This is a pure bug fix release with no breaking changes.
Installation
bash
# Homebrew (macOS/Linux)
brew tap AptS-1547/gcop-rs
brew upgrade gcop-rs
# pipx (Python users, recommended)
pipx upgrade gcop-rs
# cargo-binstall (no compilation)
cargo binstall gcop-rs
# cargo install (compile from source)
cargo install gcop-rs --forceOr download pre-built binaries from Releases.
Feedback
If you have any issues or suggestions, please submit an Issue.