Skip to content

Commit f10d5b3

Browse files
committed
feat(git): export GitErrorCode from repo
So that we can call e.g. `Repo::create_branch` and ignore the error if the branch already exists.
1 parent 8d8c21a commit f10d5b3

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

git-branchless-lib/src/git/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ pub use reference::{
2323
};
2424
pub use repo::{
2525
message_prettify, AmendFastOptions, CherryPickFastOptions, CreateCommitFastError,
26-
Error as RepoError, GitVersion, PatchId, Repo, ResolvedReferenceInfo, Result as RepoResult,
27-
Time,
26+
Error as RepoError, GitErrorCode, GitVersion, PatchId, Repo, ResolvedReferenceInfo,
27+
Result as RepoResult, Time,
2828
};
2929
pub use run::{GitRunInfo, GitRunOpts, GitRunResult};
3030
pub use snapshot::{WorkingCopyChangesType, WorkingCopySnapshot};

git-branchless-lib/src/git/repo.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,8 @@ pub enum Error {
277277
/// Result type.
278278
pub type Result<T> = std::result::Result<T, Error>;
279279

280+
pub use git2::ErrorCode as GitErrorCode;
281+
280282
/// Convert a `git2::Error` into an `eyre::Error` with an auto-generated message.
281283
pub(super) fn wrap_git_error(error: git2::Error) -> eyre::Error {
282284
eyre::eyre!("Git error {:?}: {}", error.code(), error.message())

0 commit comments

Comments
 (0)