Fix history list --cwd errors (#278)

This commit is contained in:
Lucas Burns 2022-03-13 14:53:49 -05:00 committed by GitHub
parent e117b622fe
commit 7f587418da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 29 additions and 80 deletions

45
Cargo.lock generated
View file

@ -83,7 +83,6 @@ dependencies = [
"crossbeam-channel", "crossbeam-channel",
"directories", "directories",
"eyre", "eyre",
"fork",
"humantime 2.1.0", "humantime 2.1.0",
"indicatif", "indicatif",
"itertools", "itertools",
@ -112,9 +111,6 @@ dependencies = [
"config", "config",
"directories", "directories",
"eyre", "eyre",
"fern",
"humantime 2.1.0",
"indicatif",
"itertools", "itertools",
"log", "log",
"minspan", "minspan",
@ -140,8 +136,6 @@ name = "atuin-common"
version = "0.8.0" version = "0.8.0"
dependencies = [ dependencies = [
"chrono", "chrono",
"eyre",
"rmp-serde",
"rust-crypto", "rust-crypto",
"serde 1.0.132", "serde 1.0.132",
"serde_derive", "serde_derive",
@ -159,17 +153,10 @@ dependencies = [
"atuin-common", "atuin-common",
"base64", "base64",
"chrono", "chrono",
"chrono-english",
"config", "config",
"directories",
"eyre", "eyre",
"fern",
"fork",
"indicatif",
"log", "log",
"parse_duration",
"rand 0.8.4", "rand 0.8.4",
"rmp-serde",
"rust-crypto", "rust-crypto",
"serde 1.0.132", "serde 1.0.132",
"serde_derive", "serde_derive",
@ -177,8 +164,6 @@ dependencies = [
"sodiumoxide", "sodiumoxide",
"sqlx", "sqlx",
"tokio", "tokio",
"unicode-width",
"urlencoding",
"uuid", "uuid",
"warp", "warp",
"whoami", "whoami",
@ -331,17 +316,6 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "colored"
version = "1.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4ffc801dacf156c5854b9df4f425a626539c3a6ef7893cc0c5084a23f0b6c59"
dependencies = [
"atty",
"lazy_static",
"winapi",
]
[[package]] [[package]]
name = "config" name = "config"
version = "0.11.0" version = "0.11.0"
@ -575,31 +549,12 @@ dependencies = [
"once_cell", "once_cell",
] ]
[[package]]
name = "fern"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c9a4820f0ccc8a7afd67c39a0f1a0f4b07ca1725164271a64939d7aeb9af065"
dependencies = [
"colored",
"log",
]
[[package]] [[package]]
name = "fnv" name = "fnv"
version = "1.0.7" version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]]
name = "fork"
version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4c5b9b0bce249a456f83ac4404e8baad0d2ba81cf651949719a4f74eb7323bb"
dependencies = [
"libc",
]
[[package]] [[package]]
name = "form_urlencoded" name = "form_urlencoded"
version = "1.0.1" version = "1.0.1"

View file

@ -47,7 +47,6 @@ tui = "0.16"
termion = "1.5" termion = "1.5"
unicode-width = "0.1" unicode-width = "0.1"
itertools = "0.10.3" itertools = "0.10.3"
fork = "0.1.18"
tokio = { version = "1", features = ["full"] } tokio = { version = "1", features = ["full"] }
async-trait = "0.1.49" async-trait = "0.1.49"
chrono-english = "0.1.4" chrono-english = "0.1.4"

View file

@ -14,12 +14,10 @@ repository = "https://github.com/ellie/atuin"
atuin-common = { path = "../atuin-common", version = "0.8.0" } atuin-common = { path = "../atuin-common", version = "0.8.0" }
log = "0.4" log = "0.4"
fern = {version = "0.6.0", features = ["colored"] }
chrono = { version = "0.4", features = ["serde"] } chrono = { version = "0.4", features = ["serde"] }
eyre = "0.6" eyre = "0.6"
directories = "3" directories = "3"
uuid = { version = "0.8", features = ["v4"] } uuid = { version = "0.8", features = ["v4"] }
indicatif = "0.16.2"
whoami = "1.1.2" whoami = "1.1.2"
chrono-english = "0.1.4" chrono-english = "0.1.4"
config = "0.11" config = "0.11"
@ -28,7 +26,11 @@ serde = "1.0.126"
serde_json = "1.0.75" serde_json = "1.0.75"
rmp-serde = "0.15.5" rmp-serde = "0.15.5"
sodiumoxide = "0.2.6" sodiumoxide = "0.2.6"
reqwest = { version = "0.11", features = ["blocking", "json", "rustls-tls"], default-features = false } reqwest = { version = "0.11", features = [
"blocking",
"json",
"rustls-tls",
], default-features = false }
base64 = "0.13.0" base64 = "0.13.0"
parse_duration = "2.1.1" parse_duration = "2.1.1"
rand = "0.8.4" rand = "0.8.4"
@ -36,8 +38,12 @@ rust-crypto = "^0.2"
tokio = { version = "1", features = ["full"] } tokio = { version = "1", features = ["full"] }
async-trait = "0.1.49" async-trait = "0.1.49"
urlencoding = "1.3.3" urlencoding = "1.3.3"
humantime = "2.1.0"
itertools = "0.10.3" itertools = "0.10.3"
shellexpand = "2" shellexpand = "2"
sqlx = { version = "0.5", features = [ "runtime-tokio-rustls", "uuid", "chrono", "sqlite" ] } sqlx = { version = "0.5", features = [
"runtime-tokio-rustls",
"uuid",
"chrono",
"sqlite",
] }
minspan = "0.1.1" minspan = "0.1.1"

View file

@ -283,7 +283,7 @@ impl Database for Sqlite {
query: &str, query: &str,
) -> Result<Vec<History>> { ) -> Result<Vec<History>> {
let orig_query = query; let orig_query = query;
let query = query.to_string().replace("*", "%"); // allow wildcard char let query = query.to_string().replace('*', "%"); // allow wildcard char
let limit = limit.map_or("".to_owned(), |l| format!("limit {}", l)); let limit = limit.map_or("".to_owned(), |l| format!("limit {}", l));
let query = match search_mode { let query = match search_mode {

View file

@ -14,10 +14,8 @@ repository = "https://github.com/ellie/atuin"
rust-crypto = "^0.2" rust-crypto = "^0.2"
sodiumoxide = "0.2.6" sodiumoxide = "0.2.6"
chrono = { version = "0.4", features = ["serde"] } chrono = { version = "0.4", features = ["serde"] }
eyre = "0.6"
serde_derive = "1.0.125" serde_derive = "1.0.125"
serde = "1.0.126" serde = "1.0.126"
serde_json = "1.0.75" serde_json = "1.0.75"
rmp-serde = "0.15.5"
warp = "0.3" warp = "0.3"
uuid = { version = "0.8", features = ["v4"] } uuid = { version = "0.8", features = ["v4"] }

View file

@ -12,28 +12,19 @@ repository = "https://github.com/ellie/atuin"
atuin-common = { path = "../atuin-common", version = "0.8.0" } atuin-common = { path = "../atuin-common", version = "0.8.0" }
log = "0.4" log = "0.4"
fern = {version = "0.6.0", features = ["colored"] }
chrono = { version = "0.4", features = ["serde"] } chrono = { version = "0.4", features = ["serde"] }
eyre = "0.6" eyre = "0.6"
directories = "3"
uuid = { version = "0.8", features = ["v4"] } uuid = { version = "0.8", features = ["v4"] }
indicatif = "0.16.2"
whoami = "1.1.2" whoami = "1.1.2"
chrono-english = "0.1.4"
config = "0.11" config = "0.11"
serde_derive = "1.0.125" serde_derive = "1.0.125"
serde = "1.0.126" serde = "1.0.126"
serde_json = "1.0.75" serde_json = "1.0.75"
rmp-serde = "0.15.5"
unicode-width = "0.1"
sodiumoxide = "0.2.6" sodiumoxide = "0.2.6"
base64 = "0.13.0" base64 = "0.13.0"
fork = "0.1.18"
parse_duration = "2.1.1"
rand = "0.8.4" rand = "0.8.4"
rust-crypto = "^0.2" rust-crypto = "^0.2"
tokio = { version = "1", features = ["full"] } tokio = { version = "1", features = ["full"] }
warp = "0.3" warp = "0.3"
sqlx = { version = "0.5", features = [ "runtime-tokio-rustls", "uuid", "chrono", "postgres" ] } sqlx = { version = "0.5", features = [ "runtime-tokio-rustls", "uuid", "chrono", "postgres" ] }
async-trait = "0.1.49" async-trait = "0.1.49"
urlencoding = "1.3.3"

View file

@ -5,10 +5,11 @@ use warp::{hyper::StatusCode, Filter};
use atuin_common::api::SyncHistoryRequest; use atuin_common::api::SyncHistoryRequest;
use super::handlers; use super::{
use super::{database::Database, database::Postgres}; database::{Database, Postgres},
use crate::models::User; handlers,
use crate::settings::Settings; };
use crate::{models::User, settings::Settings};
fn with_settings( fn with_settings(
settings: Settings, settings: Settings,
@ -32,17 +33,15 @@ fn with_user(
async move { async move {
let header: Vec<&str> = header.split(' ').collect(); let header: Vec<&str> = header.split(' ').collect();
let token; let token = if header.len() == 2 {
if header.len() == 2 {
if header[0] != "Token" { if header[0] != "Token" {
return Err(warp::reject()); return Err(warp::reject());
} }
token = header[1]; header[1]
} else { } else {
return Err(warp::reject()); return Err(warp::reject());
} };
let user = postgres let user = postgres
.get_session_user(token) .get_session_user(token)

View file

@ -174,7 +174,7 @@ impl Cmd {
let history = match (session, cwd) { let history = match (session, cwd) {
(None, None) => db.list(None, false).await?, (None, None) => db.list(None, false).await?,
(None, Some(cwd)) => { (None, Some(cwd)) => {
let query = format!("select * from history where cwd = {};", cwd); let query = format!("select * from history where cwd = '{}';", cwd);
db.query_history(&query).await? db.query_history(&query).await?
} }
(Some(session), None) => { (Some(session), None) => {
@ -183,7 +183,7 @@ impl Cmd {
} }
(Some(session), Some(cwd)) => { (Some(session), Some(cwd)) => {
let query = format!( let query = format!(
"select * from history where cwd = {} and session = {};", "select * from history where cwd = '{}' and session = {};",
cwd, session cwd, session
); );
db.query_history(&query).await? db.query_history(&query).await?

View file

@ -1,7 +1,6 @@
use chrono::Utc; use chrono::Utc;
use eyre::Result; use eyre::Result;
use std::time::Duration; use std::{io::stdout, ops::Sub, time::Duration};
use std::{io::stdout, ops::Sub};
use termion::{event::Key, input::MouseTerminal, raw::IntoRawMode, screen::AlternateScreen}; use termion::{event::Key, input::MouseTerminal, raw::IntoRawMode, screen::AlternateScreen};
use tui::{ use tui::{
@ -14,9 +13,11 @@ use tui::{
}; };
use unicode_width::UnicodeWidthStr; use unicode_width::UnicodeWidthStr;
use atuin_client::database::Database; use atuin_client::{
use atuin_client::history::History; database::Database,
use atuin_client::settings::{SearchMode, Settings}; history::History,
settings::{SearchMode, Settings},
};
use crate::command::event::{Event, Events}; use crate::command::event::{Event, Events};
@ -96,7 +97,7 @@ impl State {
.iter() .iter()
.enumerate() .enumerate()
.map(|(i, m)| { .map(|(i, m)| {
let command = m.command.to_string().replace("\n", " ").replace("\t", " "); let command = m.command.to_string().replace('\n', " ").replace('\t', " ");
let mut command = Span::raw(command); let mut command = Span::raw(command);