This commit is contained in:
sxyazi 2023-09-17 22:10:54 +08:00
parent db7f72e14a
commit fa6e57d0ce
No known key found for this signature in database
2 changed files with 6 additions and 15 deletions

View file

@ -109,13 +109,11 @@ impl Executor {
} }
} }
"link" => { "link" => {
let dest = cx.manager.cwd().to_owned();
let (cut, src) = cx.manager.yanked(); let (cut, src) = cx.manager.yanked();
!cut !cut
&& cx.tasks.file_link( && cx.tasks.file_link(
src, src,
dest, cx.manager.cwd().to_owned(),
exec.named.contains_key("relative"), exec.named.contains_key("relative"),
exec.named.contains_key("force"), exec.named.contains_key("force"),
) )

View file

@ -131,18 +131,11 @@ mod tests {
#[cfg(unix)] #[cfg(unix)]
#[test] #[test]
fn test_path_relative_to() { fn test_path_relative_to() {
let foo = "/foo"; assert_path_relate_to_root("/a/b", "/a/b/c", "../");
let bar = "/foo/bar"; assert_path_relate_to_root("/a/b/c", "/a/b", "c");
let baz = "/foo/bar/baz"; assert_path_relate_to_root("/a/b/c", "/a/b/d", "../c");
let qux = "/foo/bar/qux"; assert_path_relate_to_root("/a", "/a/b/c", "../../");
let aha = "/foo/aha/bar"; assert_path_relate_to_root("/a/a/b", "/a/b/b", "../../b/b");
assert_path_relate_to_root(bar, baz, "../"); // self reflection
assert_path_relate_to_root(baz, bar, "baz"); // child entry
assert_path_relate_to_root(qux, baz, "../qux"); // sibling entry
assert_path_relate_to_root(baz, qux, "../baz"); // sibling entry
assert_path_relate_to_root(foo, baz, "../../"); // ancestor entry
assert_path_relate_to_root(aha, baz, "../../aha/bar"); // ancestor's child entry
} }
fn assert_path_relate_to_root(path: &str, root: &str, res: &str) { fn assert_path_relate_to_root(path: &str, root: &str, res: &str) {