Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 9, 2026

Removes thiserror from gix-revision and converts to gix-error, following the pattern established in gix-date. Additionally updates the gix crate's API to return gix::Error from revision parsing functions.

Changes

  • spec::parse::Error: Now uses gix_error::ParseError instead of custom enum with 15+ variants
  • describe::Error and merge_base::Error: Converted to simple error types wrapping string messages
  • Error creation sites: All 50+ error construction sites updated to use Error::new() and Error::new_with_input()
  • Test assertions: 112 tests updated to check error messages/input instead of enum variant matching
  • gix API changes:
    • Spec::from_bstr() now returns gix::Error instead of revision::spec::parse::Error
    • Repository::rev_parse() now returns gix::Error
    • Parse errors are wrapped with gix_error::Message::new(format!(...)) for inline error messages

Before/After

// Before (gix-revision)
#[derive(Debug, thiserror::Error)]
pub enum Error {
    #[error("'~' needs to follow an anchor, like '@~'.")]
    MissingTildeAnchor,
    #[error("Could not parse time {:?} for revlog lookup.", .input)]
    Time { input: BString, source: Option<Box<gix_date::Error>> },
    // ... 13 more variants
}

// After (gix-revision)
pub use gix_error::ParseError as Error;

// Usage
Err(Error::new("tilde needs to follow an anchor, like @~"))
Err(Error::new_with_input("could not parse time for reflog lookup", nav))

// Before (gix)
pub fn from_bstr(...) -> Result<Self, Error> // where Error is revision::spec::parse::Error

// After (gix)
pub fn from_bstr(...) -> Result<Self, crate::Error> // where Error is gix::Error

All tests passing.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI mentioned this pull request Jan 9, 2026
6 tasks
Copilot AI changed the title [WIP] Fix gix error punch-through issue Convert gix-revision to use gix-error Jan 9, 2026
Copilot AI requested a review from Byron January 9, 2026 21:25
@Byron Byron requested a review from Copilot January 10, 2026 09:24
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR converts gix-revision from using thiserror to gix-error, following the pattern established in gix-date. The conversion simplifies error handling by replacing structured error enums with string-based error messages.

Changes:

  • Replaced spec::parse::Error enum (15+ variants) with gix_error::ParseError type alias
  • Converted describe::Error and merge_base::Error to simple wrapper types with string messages
  • Updated all 50+ error construction sites to use Error::new() and Error::new_with_input()
  • Modified 112 test assertions to check error messages/input using substring matching instead of enum variant matching

Reviewed changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
gix-revision/Cargo.toml Removed thiserror dependency
Cargo.lock Updated to reflect removal of thiserror from gix-revision
gix-revision/src/spec/parse/mod.rs Replaced Error enum with gix_error::ParseError type alias
gix-revision/src/spec/parse/function.rs Updated all error construction sites to use Error::new() and Error::new_with_input()
gix-revision/src/merge_base/mod.rs Introduced Simple(&'static str) error wrapper for static error messages
gix-revision/src/merge_base/function.rs Updated error construction to use Simple wrapper with static strings
gix-revision/src/describe.rs Introduced Simple(String) error wrapper for dynamic error messages (e.g., with commit hashes)
gix-revision/tests/revision/spec/parse/navigate/tilde_symbol.rs Updated test assertions to check error message content
gix-revision/tests/revision/spec/parse/navigate/caret_symbol.rs Updated test assertions to check error message content and input
gix-revision/tests/revision/spec/parse/kind.rs Updated test assertions to check error message content
gix-revision/tests/revision/spec/parse/anchor/refnames.rs Updated test assertions to check error message content and input
gix-revision/tests/revision/spec/parse/anchor/colon_symbol.rs Updated test assertions to check error message content and input
gix-revision/tests/revision/spec/parse/anchor/at_symbol.rs Updated test assertions to check error message content and input

@Byron Byron force-pushed the copilot/sub-pr-2352-again branch 3 times, most recently from b55cf08 to 6d13b1c Compare January 11, 2026 10:29
@Byron
Copy link
Member

Byron commented Jan 11, 2026

@copilot let Spec::from_bstr() return gix::Error instead,
and copy the formatted error message from the previous error type inline via gix_error::Message::new(format!(…)).

Copy link
Contributor Author

Copilot AI commented Jan 11, 2026

@copilot let Spec::from_bstr() return gix::Error instead,
and cop...

I've updated Spec::from_bstr() to return gix::Error and wrapped parse errors with gix_error::Message::new(format!(...)) to create inline error messages. Also updated Repository::rev_parse() to use the new error type.

Commit: daed5d3

Copilot AI changed the title Convert gix-revision to use gix-error Convert gix-revision to use gix-error and update gix API Jan 11, 2026
@Byron Byron force-pushed the copilot/sub-pr-2352-again branch from daed5d3 to 5438e06 Compare January 11, 2026 15:29
- Add a `Message` error to `gix-error` for general use.
@Byron Byron force-pushed the copilot/sub-pr-2352-again branch from 5438e06 to 2eb7f60 Compare January 11, 2026 16:46
@Byron Byron marked this pull request as ready for review January 11, 2026 16:46
@Byron Byron merged commit 5d0bb8c into gix-error Jan 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants