forked from mirrors/jj
cli: use .
in output for current directory instead of empty string
This commit is contained in:
parent
724e2af529
commit
8745ee7030
3 changed files with 12 additions and 4 deletions
|
@ -62,6 +62,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
* You now get a proper error message instead of a crash when `$EDITOR` doesn't
|
||||
exist or exits with an error.
|
||||
|
||||
* Fixed relative path to the current directory in output to be `.` instead of
|
||||
empty string.
|
||||
|
||||
## [0.4.0] - 2022-04-02
|
||||
|
||||
### Breaking changes
|
||||
|
|
10
src/ui.rs
10
src/ui.rs
|
@ -190,13 +190,19 @@ pub fn relative_path(mut from: &Path, to: &Path) -> PathBuf {
|
|||
let mut result = PathBuf::from("");
|
||||
loop {
|
||||
if let Ok(suffix) = to.strip_prefix(from) {
|
||||
return result.join(suffix);
|
||||
result = result.join(suffix);
|
||||
break;
|
||||
}
|
||||
if let Some(parent) = from.parent() {
|
||||
result = result.join("..");
|
||||
from = parent;
|
||||
} else {
|
||||
return to.to_owned();
|
||||
result = to.to_path_buf();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if result.as_os_str().is_empty() {
|
||||
result = PathBuf::from(".");
|
||||
}
|
||||
result
|
||||
}
|
||||
|
|
|
@ -117,8 +117,7 @@ fn test_init_git_colocated() {
|
|||
let workspace_root = test_env.env_root().join("repo");
|
||||
init_git_repo(&workspace_root);
|
||||
let stdout = test_env.jj_cmd_success(&workspace_root, &["init", "--git-repo", "."]);
|
||||
// TODO: We should say "." instead of "" here
|
||||
insta::assert_snapshot!(stdout, @r###"Initialized repo in ""
|
||||
insta::assert_snapshot!(stdout, @r###"Initialized repo in "."
|
||||
"###);
|
||||
|
||||
let jj_path = workspace_root.join(".jj");
|
||||
|
|
Loading…
Reference in a new issue