Skip to content

Commit be1f6a8

Browse files
committed
fix: use root cause for gix errors
Signed-off-by: 35V LG84 <35vlg84-x4e6b92@e257.fi>
1 parent da86fbc commit be1f6a8

File tree

3 files changed

+34
-19
lines changed

3 files changed

+34
-19
lines changed

CHANGELOG.adoc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ New features:
1515

1616
Changed functionality:
1717

18-
* git-subsystem: some error messages are different
19-
** link:https://github.com/GitoxideLabs/gitoxide/issues/2351[gitoxide #2351]
2018
* ...
2119
** ...
2220

tackler-core/src/parser/tackler_txns.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55
use itertools::Itertools;
66
use std::collections::HashSet;
7+
use std::error::Error;
78
use std::path::{Path, PathBuf};
89
use std::str;
910
//use std::time::{SystemTime, UNIX_EPOCH};
@@ -84,7 +85,18 @@ pub fn git_to_txns(
8485
(repo.find_object(object_id)?.try_into_commit()?, None)
8586
}
8687
GitInputSelector::Reference(ref_str) => {
87-
let id = repo.rev_parse_single(ref_str.as_bytes())?;
88+
let id_res = repo.rev_parse_single(ref_str.as_bytes());
89+
let id = match id_res {
90+
Ok(id) => id,
91+
Err(err) => {
92+
let msg = if let Some(source) = err.source() {
93+
format!("{source}")
94+
} else {
95+
format!("{err}")
96+
};
97+
return Err(msg.into());
98+
}
99+
};
88100
let reference = if id.to_string().starts_with(ref_str.as_str()) {
89101
// This is tackler specific logic: don't show ref if it's plain commit id
90102
None

tests/sh/core-git-errors.sh

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,29 @@ echo "check: ok"
6161

6262
#####################################################################
6363
#
64-
# todo: GitoxideLabs/gitoxide#2351
65-
# 2>&1 | grep 'Tackler error: Txn Data: .* object .* ef8845.* could not be found'
66-
#
6764
# test: c233295d-08b9-49b5-b384-634fc8432e64
68-
# desc: commit not found
69-
test_name=git-unknown-commit
65+
# desc: commit not found (by ref)
66+
test_name=git-unknown-commit-by-ref
7067
echo "test: $module/$test_name: $mode"
7168

7269
$TACKLER_SH \
7370
--config $SUITE_PATH/$module/git-ok.toml \
7471
--input.git.ref ef88456ffae9eb546d115833f2ad66d48a8e268b \
75-
2>&1 | grep 'Tackler error: Txn Data: .* ef8845.*'
72+
2>&1 | grep 'Tackler error: Txn Data: .* object .* ef8845.* could not be found'
73+
74+
echo "check: ok"
75+
76+
#####################################################################
77+
#
78+
# test: beed0077-33b6-441f-b7be-deca8080362d
79+
# desc: commit not found (by commit)
80+
test_name=git-unknown-commit-by-commit
81+
echo "test: $module/$test_name: $mode"
82+
83+
$TACKLER_SH \
84+
--config $SUITE_PATH/$module/git-ok.toml \
85+
--input.git.commit ef88456ffae9eb546d115833f2ad66d48a8e268b \
86+
2>&1 | grep "Tackler error: Txn Data: Unknown commit id 'ef88456ffae9eb546d115833f2ad66d48a8e268b'"
7687

7788
echo "check: ok"
7889

@@ -86,15 +97,15 @@ echo "test: $module/$test_name: $mode"
8697
$TACKLER_SH \
8798
--config $SUITE_PATH/$module/git-ok.toml \
8899
--input.git.ref "//" \
89-
2>&1 | grep "couldn't parse revision: //"
100+
2>&1 | grep 'An error occurred while trying to find a reference'
90101

91102
echo "check: ok"
92103

93104
#####################################################################
94105
#
95106
# test: 7cb6af2e-3061-4867-96e3-ee175b87a114
96107
# desc: can not resolve ref
97-
test_name=git-ref-dosnt-resolve
108+
test_name=git-ref-doesnt-resolve
98109
echo "test: $module/$test_name: $mode"
99110

100111
$TACKLER_SH \
@@ -106,9 +117,6 @@ echo "check: ok"
106117

107118
#####################################################################
108119
#
109-
# todo: GitoxideLabs/gitoxide#2351
110-
# 2>&1 | grep 'Tackler error: Txn Data: The ref .* "not-found-ref" .* not be found'
111-
#
112120
# test: 4b507e08-b90e-4a6f-9c6b-4fef7c58d9fe
113121
# desc: ref which is not found
114122
test_name=git-ref-not-found
@@ -117,15 +125,12 @@ echo "test: $module/$test_name: $mode"
117125
$TACKLER_SH \
118126
--config $SUITE_PATH/$module/git-ok.toml \
119127
--input.git.ref "not-found-ref" \
120-
2>&1 | grep 'Tackler error: Txn Data: .*not-found-ref'
128+
2>&1 | grep 'Tackler error: Txn Data: The ref .* "not-found-ref" .* not be found'
121129

122130
echo "check: ok"
123131

124132
#####################################################################
125133
#
126-
# todo: GitoxideLabs/gitoxide#2351
127-
# 2>&1 | grep 'Tackler error: Txn Data: Tried to navigate .* anchor first'
128-
#
129134
# test: 14b7e8eb-d168-48b2-86e7-8d922f306ad0
130135
# desc: ref format is invalid
131136
test_name=invalid-ref-format
@@ -136,7 +141,7 @@ $TACKLER_SH \
136141
--output.prefix $test_name \
137142
--config $SUITE_PATH/$module/git-ok.toml \
138143
--input.git.ref "^^^" \
139-
2>&1 | grep 'Tackler error: .*\^'
144+
2>&1 | grep 'Tackler error: Txn Data: Tried to navigate .* anchor first'
140145

141146
echo "check: ok"
142147

0 commit comments

Comments
 (0)