mirror of
https://github.com/martinvonz/jj.git
synced 2024-11-13 06:06:56 +03:00
git: remove ": {source}" from FailedRefExportReason, walk chain by caller
The error output gets more verbose because all gix error sources are printed. Maybe we'll need a better formatting, but changing to multi-line output doesn't look nice either.
This commit is contained in:
parent
a0cefb8b7b
commit
1efadd96c8
@ -19,6 +19,7 @@ use std::path::{Path, PathBuf};
|
||||
use std::process::Stdio;
|
||||
use std::sync::Mutex;
|
||||
use std::time::Instant;
|
||||
use std::{error, iter};
|
||||
|
||||
use jj_lib::git::{self, FailedRefExport, FailedRefExportReason, GitImportStats};
|
||||
use jj_lib::git_backend::GitBackend;
|
||||
@ -172,7 +173,10 @@ pub fn print_failed_git_export(
|
||||
for FailedRefExport { name, reason } in failed_branches {
|
||||
formatter.write_str(" ")?;
|
||||
write!(formatter.labeled("branch"), "{name}")?;
|
||||
writeln!(formatter, ": {reason}")?;
|
||||
for err in iter::successors(Some(reason as &dyn error::Error), |err| err.source()) {
|
||||
write!(formatter, ": {err}")?;
|
||||
}
|
||||
writeln!(formatter)?;
|
||||
}
|
||||
drop(formatter);
|
||||
if failed_branches
|
||||
|
@ -402,13 +402,15 @@ fn test_git_colocated_conflicting_git_refs() {
|
||||
test_env.jj_cmd_ok(&workspace_root, &["branch", "create", "main"]);
|
||||
let (stdout, stderr) = test_env.jj_cmd_ok(&workspace_root, &["branch", "create", "main/sub"]);
|
||||
insta::assert_snapshot!(stdout, @"");
|
||||
insta::assert_snapshot!(stderr, @r###"
|
||||
Failed to export some branches:
|
||||
main/sub: Failed to set: A lock could not be obtained for reference "refs/heads/main/sub"
|
||||
Hint: Git doesn't allow a branch name that looks like a parent directory of
|
||||
another (e.g. `foo` and `foo/bar`). Try to rename the branches that failed to
|
||||
export or their "parent" branches.
|
||||
"###);
|
||||
insta::with_settings!({filters => vec![(": The lock for resource.*", ": ...")]}, {
|
||||
insta::assert_snapshot!(stderr, @r###"
|
||||
Failed to export some branches:
|
||||
main/sub: Failed to set: A lock could not be obtained for reference "refs/heads/main/sub": ...
|
||||
Hint: Git doesn't allow a branch name that looks like a parent directory of
|
||||
another (e.g. `foo` and `foo/bar`). Try to rename the branches that failed to
|
||||
export or their "parent" branches.
|
||||
"###);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -67,13 +67,15 @@ fn test_git_export_conflicting_git_refs() {
|
||||
test_env.jj_cmd_ok(&repo_path, &["branch", "create", "main/sub"]);
|
||||
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["git", "export"]);
|
||||
insta::assert_snapshot!(stdout, @"");
|
||||
insta::assert_snapshot!(stderr, @r###"
|
||||
Failed to export some branches:
|
||||
main/sub: Failed to set: A lock could not be obtained for reference "refs/heads/main/sub"
|
||||
Hint: Git doesn't allow a branch name that looks like a parent directory of
|
||||
another (e.g. `foo` and `foo/bar`). Try to rename the branches that failed to
|
||||
export or their "parent" branches.
|
||||
"###);
|
||||
insta::with_settings!({filters => vec![(": The lock for resource.*", ": ...")]}, {
|
||||
insta::assert_snapshot!(stderr, @r###"
|
||||
Failed to export some branches:
|
||||
main/sub: Failed to set: A lock could not be obtained for reference "refs/heads/main/sub": ...
|
||||
Hint: Git doesn't allow a branch name that looks like a parent directory of
|
||||
another (e.g. `foo` and `foo/bar`). Try to rename the branches that failed to
|
||||
export or their "parent" branches.
|
||||
"###);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -592,10 +592,10 @@ pub enum FailedRefExportReason {
|
||||
#[error("Modified ref had been deleted in Git")]
|
||||
ModifiedInJjDeletedInGit,
|
||||
/// Failed to delete the ref from the Git repo
|
||||
#[error("Failed to delete: {0}")]
|
||||
#[error("Failed to delete")]
|
||||
FailedToDelete(#[source] Box<gix::reference::edit::Error>),
|
||||
/// Failed to set the ref in the Git repo
|
||||
#[error("Failed to set: {0}")]
|
||||
#[error("Failed to set")]
|
||||
FailedToSet(#[source] Box<gix::reference::edit::Error>),
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user