Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix path for downloaded cheats #493

Merged
merged 1 commit into from
Apr 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "navi"
version = "2.15.0"
version = "2.15.1"
authors = ["Denis Isidoro <[email protected]>"]
edition = "2018"
description = "An interactive cheatsheet tool for the command-line"
Expand Down
9 changes: 5 additions & 4 deletions src/cmds/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ pub fn add(uri: String, finder: &FinderChoice) -> Result<(), Error> {
};

let to_folder = {
let mut p = cheat_pathbuf.clone();
let mut p = cheat_pathbuf;
p.push(format!("{}__{}", user, repo));
p
};
Expand All @@ -127,7 +127,9 @@ pub fn add(uri: String, finder: &FinderChoice) -> Result<(), Error> {
p.push(file);
p
};
let filename = file.replace("/", "__");
let filename = file
.replace(&format!("{}/", &tmp_path_str), "")
.replace("/", "__");
let to = {
let mut p = to_folder.clone();
p.push(filename);
Expand All @@ -146,9 +148,8 @@ pub fn add(uri: String, finder: &FinderChoice) -> Result<(), Error> {
filesystem::remove_dir(&tmp_pathbuf)?;

eprintln!(
"The following .cheat files were imported successfully:\n{}\n\nThey are now located at {}/{}",
"The following .cheat files were imported successfully:\n{}\n\nThey are now located at {}",
files,
pathbuf_to_string(&cheat_pathbuf)?,
pathbuf_to_string(&to_folder)?
);

Expand Down
20 changes: 11 additions & 9 deletions tests/run
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,10 @@ _integration() {
sleep 1
tmux send-key -t ci "Enter"

echoerr "Checking paths..."
sleep 2
cat "$log_file" | tail -n10 | grep -q "/navi"
local -r downloaded_path="$(cat "$log_file" | grep 'They are now located at' | sed 's/They are now located at //')"
ls "$downloaded_path" | grep -q '^pkg_mgr__brew.cheat$'
}

if ! command_exists fzf; then
Expand Down Expand Up @@ -140,19 +142,19 @@ for i in $(_get_tests "$filter"); do
test::run "$query" _navi_cases_test "$query" "$expected"
done

test::set_suite "3rd party"
test::run "tldr" _navi_tldr
test::run "cheatsh" _navi_cheatsh
test::set_suite "info"
test::run "cheats_path" _navi_cheatspath

test::set_suite "integration"
test::run "welcome->pwd" _integration

test::set_suite "widget"
test::run "bash" _navi_widget "bash"
test::run "zsh" _navi_widget "zsh"
test::run "zsh" _navi_widget "fish"

test::set_suite "info"
test::run "cheats_path" _navi_cheatspath

test::set_suite "integration"
test::run "welcome->pwd" _integration
test::set_suite "3rd party"
test::run "tldr" _navi_tldr
test::run "cheatsh" _navi_cheatsh

test::finish