Skip to content

Commit 36e04b7

Browse files
authored
Merge branch 'master' into config-err-msg
2 parents b607554 + fd46b9a commit 36e04b7

File tree

6 files changed

+223
-131
lines changed

6 files changed

+223
-131
lines changed

asyncgit/src/error.rs

Lines changed: 184 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,80 @@ use std::{
44
};
55
use thiserror::Error;
66

7+
///
8+
#[derive(Error, Debug)]
9+
pub enum GixError {
10+
///
11+
#[error("gix::discover error: {0}")]
12+
Discover(#[from] Box<gix::discover::Error>),
13+
14+
///
15+
#[error("gix::head::peel::to_commit error: {0}")]
16+
HeadPeelToCommit(#[from] gix::head::peel::to_commit::Error),
17+
18+
///
19+
#[error("gix::object::find::existing::with_conversion::Error error: {0}")]
20+
ObjectFindExistingWithConversion(
21+
#[from] gix::object::find::existing::with_conversion::Error,
22+
),
23+
24+
///
25+
#[error("gix::objs::decode::Error error: {0}")]
26+
ObjsDecode(#[from] gix::objs::decode::Error),
27+
28+
///
29+
#[error("gix::pathspec::init::Error error: {0}")]
30+
PathspecInit(#[from] Box<gix::pathspec::init::Error>),
31+
32+
///
33+
#[error("gix::reference::find::existing error: {0}")]
34+
ReferenceFindExisting(
35+
#[from] gix::reference::find::existing::Error,
36+
),
37+
38+
///
39+
#[error("gix::reference::head_tree_id::Error error: {0}")]
40+
ReferenceHeadTreeId(#[from] gix::reference::head_tree_id::Error),
41+
42+
///
43+
#[error("gix::reference::iter::Error error: {0}")]
44+
ReferenceIter(#[from] gix::reference::iter::Error),
45+
46+
///
47+
#[error("gix::reference::iter::init::Error error: {0}")]
48+
ReferenceIterInit(#[from] gix::reference::iter::init::Error),
49+
50+
///
51+
#[error("gix::revision::walk error: {0}")]
52+
RevisionWalk(#[from] gix::revision::walk::Error),
53+
54+
///
55+
#[error("gix::status::Error error: {0}")]
56+
Status(#[from] Box<gix::status::Error>),
57+
58+
///
59+
#[error("gix::status::index_worktree::Error error: {0}")]
60+
StatusIndexWorktree(
61+
#[from] Box<gix::status::index_worktree::Error>,
62+
),
63+
64+
///
65+
#[error("gix::status::into_iter::Error error: {0}")]
66+
StatusIntoIter(#[from] Box<gix::status::into_iter::Error>),
67+
68+
///
69+
#[error("gix::status::iter::Error error: {0}")]
70+
StatusIter(#[from] Box<gix::status::iter::Error>),
71+
72+
///
73+
#[error("gix::status::tree_index::Error error: {0}")]
74+
StatusTreeIndex(#[from] Box<gix::status::tree_index::Error>),
75+
76+
///
77+
#[error("gix::worktree::open_index::Error error: {0}")]
78+
WorktreeOpenIndex(#[from] Box<gix::worktree::open_index::Error>),
79+
}
80+
781
///
882
#[derive(Error, Debug)]
983
pub enum Error {
@@ -96,70 +170,8 @@ pub enum Error {
96170
Sign(#[from] crate::sync::sign::SignError),
97171

98172
///
99-
#[error("gix::discover error: {0}")]
100-
GixDiscover(#[from] Box<gix::discover::Error>),
101-
102-
///
103-
#[error("gix::reference::find::existing error: {0}")]
104-
GixReferenceFindExisting(
105-
#[from] gix::reference::find::existing::Error,
106-
),
107-
108-
///
109-
#[error("gix::head::peel::to_commit error: {0}")]
110-
GixHeadPeelToCommit(#[from] gix::head::peel::to_commit::Error),
111-
112-
///
113-
#[error("gix::revision::walk error: {0}")]
114-
GixRevisionWalk(#[from] gix::revision::walk::Error),
115-
116-
///
117-
#[error("gix::objs::decode::Error error: {0}")]
118-
GixObjsDecode(#[from] gix::objs::decode::Error),
119-
120-
///
121-
#[error("gix::object::find::existing::with_conversion::Error error: {0}")]
122-
GixObjectFindExistingWithConversionError(
123-
#[from] gix::object::find::existing::with_conversion::Error,
124-
),
125-
126-
///
127-
#[error("gix::pathspec::init::Error error: {0}")]
128-
GixPathspecInit(#[from] Box<gix::pathspec::init::Error>),
129-
130-
///
131-
#[error("gix::reference::head_tree_id::Error error: {0}")]
132-
GixReferenceHeadTreeId(
133-
#[from] gix::reference::head_tree_id::Error,
134-
),
135-
136-
///
137-
#[error("gix::status::Error error: {0}")]
138-
GixStatus(#[from] Box<gix::status::Error>),
139-
140-
///
141-
#[error("gix::status::iter::Error error: {0}")]
142-
GixStatusIter(#[from] Box<gix::status::iter::Error>),
143-
144-
///
145-
#[error("gix::status::into_iter::Error error: {0}")]
146-
GixStatusIntoIter(#[from] Box<gix::status::into_iter::Error>),
147-
148-
///
149-
#[error("gix::status::index_worktree::Error error: {0}")]
150-
GixStatusIndexWorktree(
151-
#[from] Box<gix::status::index_worktree::Error>,
152-
),
153-
154-
///
155-
#[error("gix::status::tree_index::Error error: {0}")]
156-
GixStatusTreeIndex(#[from] Box<gix::status::tree_index::Error>),
157-
158-
///
159-
#[error("gix::worktree::open_index::Error error: {0}")]
160-
GixWorktreeOpenIndex(
161-
#[from] Box<gix::worktree::open_index::Error>,
162-
),
173+
#[error("gix error:{0}")]
174+
Gix(#[from] GixError),
163175

164176
///
165177
#[error("amend error: config commit.gpgsign=true detected.\ngpg signing is not supported for amending non-last commits")]
@@ -189,50 +201,150 @@ impl<T> From<crossbeam_channel::SendError<T>> for Error {
189201
}
190202
}
191203

204+
impl From<gix::discover::Error> for GixError {
205+
fn from(error: gix::discover::Error) -> Self {
206+
Self::Discover(Box::new(error))
207+
}
208+
}
209+
192210
impl From<gix::discover::Error> for Error {
193211
fn from(error: gix::discover::Error) -> Self {
194-
Self::GixDiscover(Box::new(error))
212+
Self::Gix(GixError::from(error))
213+
}
214+
}
215+
216+
impl From<gix::head::peel::to_commit::Error> for Error {
217+
fn from(error: gix::head::peel::to_commit::Error) -> Self {
218+
Self::Gix(GixError::from(error))
219+
}
220+
}
221+
222+
impl From<gix::object::find::existing::with_conversion::Error>
223+
for Error
224+
{
225+
fn from(
226+
error: gix::object::find::existing::with_conversion::Error,
227+
) -> Self {
228+
Self::Gix(GixError::from(error))
229+
}
230+
}
231+
232+
impl From<gix::objs::decode::Error> for Error {
233+
fn from(error: gix::objs::decode::Error) -> Self {
234+
Self::Gix(GixError::from(error))
235+
}
236+
}
237+
238+
impl From<gix::pathspec::init::Error> for GixError {
239+
fn from(error: gix::pathspec::init::Error) -> Self {
240+
Self::PathspecInit(Box::new(error))
195241
}
196242
}
197243

198244
impl From<gix::pathspec::init::Error> for Error {
199245
fn from(error: gix::pathspec::init::Error) -> Self {
200-
Self::GixPathspecInit(Box::new(error))
246+
Self::Gix(GixError::from(error))
247+
}
248+
}
249+
250+
impl From<gix::reference::find::existing::Error> for Error {
251+
fn from(error: gix::reference::find::existing::Error) -> Self {
252+
Self::Gix(GixError::from(error))
253+
}
254+
}
255+
256+
impl From<gix::reference::head_tree_id::Error> for Error {
257+
fn from(error: gix::reference::head_tree_id::Error) -> Self {
258+
Self::Gix(GixError::from(error))
259+
}
260+
}
261+
262+
impl From<gix::reference::iter::Error> for Error {
263+
fn from(error: gix::reference::iter::Error) -> Self {
264+
Self::Gix(GixError::from(error))
265+
}
266+
}
267+
268+
impl From<gix::reference::iter::init::Error> for Error {
269+
fn from(error: gix::reference::iter::init::Error) -> Self {
270+
Self::Gix(GixError::from(error))
271+
}
272+
}
273+
274+
impl From<gix::revision::walk::Error> for Error {
275+
fn from(error: gix::revision::walk::Error) -> Self {
276+
Self::Gix(GixError::from(error))
277+
}
278+
}
279+
280+
impl From<gix::status::Error> for GixError {
281+
fn from(error: gix::status::Error) -> Self {
282+
Self::Status(Box::new(error))
201283
}
202284
}
203285

204286
impl From<gix::status::Error> for Error {
205287
fn from(error: gix::status::Error) -> Self {
206-
Self::GixStatus(Box::new(error))
288+
Self::Gix(GixError::from(error))
289+
}
290+
}
291+
292+
impl From<gix::status::iter::Error> for GixError {
293+
fn from(error: gix::status::iter::Error) -> Self {
294+
Self::StatusIter(Box::new(error))
207295
}
208296
}
209297

210298
impl From<gix::status::iter::Error> for Error {
211299
fn from(error: gix::status::iter::Error) -> Self {
212-
Self::GixStatusIter(Box::new(error))
300+
Self::Gix(GixError::from(error))
301+
}
302+
}
303+
304+
impl From<gix::status::into_iter::Error> for GixError {
305+
fn from(error: gix::status::into_iter::Error) -> Self {
306+
Self::StatusIntoIter(Box::new(error))
213307
}
214308
}
215309

216310
impl From<gix::status::into_iter::Error> for Error {
217311
fn from(error: gix::status::into_iter::Error) -> Self {
218-
Self::GixStatusIntoIter(Box::new(error))
312+
Self::Gix(GixError::from(error))
313+
}
314+
}
315+
316+
impl From<gix::status::index_worktree::Error> for GixError {
317+
fn from(error: gix::status::index_worktree::Error) -> Self {
318+
Self::StatusIndexWorktree(Box::new(error))
219319
}
220320
}
221321

222322
impl From<gix::status::index_worktree::Error> for Error {
223323
fn from(error: gix::status::index_worktree::Error) -> Self {
224-
Self::GixStatusIndexWorktree(Box::new(error))
324+
Self::Gix(GixError::from(error))
325+
}
326+
}
327+
328+
impl From<gix::status::tree_index::Error> for GixError {
329+
fn from(error: gix::status::tree_index::Error) -> Self {
330+
Self::StatusTreeIndex(Box::new(error))
225331
}
226332
}
227333

228334
impl From<gix::status::tree_index::Error> for Error {
229335
fn from(error: gix::status::tree_index::Error) -> Self {
230-
Self::GixStatusTreeIndex(Box::new(error))
336+
Self::Gix(GixError::from(error))
337+
}
338+
}
339+
340+
impl From<gix::worktree::open_index::Error> for GixError {
341+
fn from(error: gix::worktree::open_index::Error) -> Self {
342+
Self::WorktreeOpenIndex(Box::new(error))
231343
}
232344
}
233345

234346
impl From<gix::worktree::open_index::Error> for Error {
235347
fn from(error: gix::worktree::open_index::Error) -> Self {
236-
Self::GixWorktreeOpenIndex(Box::new(error))
348+
Self::Gix(GixError::from(error))
237349
}
238350
}

asyncgit/src/sync/commits_info.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,15 @@ impl From<gix::ObjectId> for CommitId {
9696
}
9797
}
9898

99+
impl From<gix::Commit<'_>> for CommitId {
100+
fn from(commit: gix::Commit<'_>) -> Self {
101+
#[allow(clippy::expect_used)]
102+
let oid = Oid::from_bytes(commit.id().as_bytes()).expect("`Oid::from_bytes(commit.id().as_bytes())` is expected to never fail");
103+
104+
Self::new(oid)
105+
}
106+
}
107+
99108
impl From<CommitId> for gix::ObjectId {
100109
fn from(id: CommitId) -> Self {
101110
Self::from_bytes_or_panic(id.0.as_bytes())

0 commit comments

Comments
 (0)