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

View File

@ -47,7 +47,6 @@ tui = "0.16"
termion = "1.5"
unicode-width = "0.1"
itertools = "0.10.3"
fork = "0.1.18"
tokio = { version = "1", features = ["full"] }
async-trait = "0.1.49"
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" }
log = "0.4"
fern = {version = "0.6.0", features = ["colored"] }
chrono = { version = "0.4", features = ["serde"] }
eyre = "0.6"
directories = "3"
uuid = { version = "0.8", features = ["v4"] }
indicatif = "0.16.2"
whoami = "1.1.2"
chrono-english = "0.1.4"
config = "0.11"
@ -28,7 +26,11 @@ serde = "1.0.126"
serde_json = "1.0.75"
rmp-serde = "0.15.5"
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"
parse_duration = "2.1.1"
rand = "0.8.4"
@ -36,8 +38,12 @@ rust-crypto = "^0.2"
tokio = { version = "1", features = ["full"] }
async-trait = "0.1.49"
urlencoding = "1.3.3"
humantime = "2.1.0"
itertools = "0.10.3"
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"

View File

@ -283,7 +283,7 @@ impl Database for Sqlite {
query: &str,
) -> Result<Vec<History>> {
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 query = match search_mode {

View File

@ -14,10 +14,8 @@ repository = "https://github.com/ellie/atuin"
rust-crypto = "^0.2"
sodiumoxide = "0.2.6"
chrono = { version = "0.4", features = ["serde"] }
eyre = "0.6"
serde_derive = "1.0.125"
serde = "1.0.126"
serde_json = "1.0.75"
rmp-serde = "0.15.5"
warp = "0.3"
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" }
log = "0.4"
fern = {version = "0.6.0", features = ["colored"] }
chrono = { version = "0.4", features = ["serde"] }
eyre = "0.6"
directories = "3"
uuid = { version = "0.8", features = ["v4"] }
indicatif = "0.16.2"
whoami = "1.1.2"
chrono-english = "0.1.4"
config = "0.11"
serde_derive = "1.0.125"
serde = "1.0.126"
serde_json = "1.0.75"
rmp-serde = "0.15.5"
unicode-width = "0.1"
sodiumoxide = "0.2.6"
base64 = "0.13.0"
fork = "0.1.18"
parse_duration = "2.1.1"
rand = "0.8.4"
rust-crypto = "^0.2"
tokio = { version = "1", features = ["full"] }
warp = "0.3"
sqlx = { version = "0.5", features = [ "runtime-tokio-rustls", "uuid", "chrono", "postgres" ] }
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 super::handlers;
use super::{database::Database, database::Postgres};
use crate::models::User;
use crate::settings::Settings;
use super::{
database::{Database, Postgres},
handlers,
};
use crate::{models::User, settings::Settings};
fn with_settings(
settings: Settings,
@ -32,17 +33,15 @@ fn with_user(
async move {
let header: Vec<&str> = header.split(' ').collect();
let token;
if header.len() == 2 {
let token = if header.len() == 2 {
if header[0] != "Token" {
return Err(warp::reject());
}
token = header[1];
header[1]
} else {
return Err(warp::reject());
}
};
let user = postgres
.get_session_user(token)

View File

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

View File

@ -1,7 +1,6 @@
use chrono::Utc;
use eyre::Result;
use std::time::Duration;
use std::{io::stdout, ops::Sub};
use std::{io::stdout, ops::Sub, time::Duration};
use termion::{event::Key, input::MouseTerminal, raw::IntoRawMode, screen::AlternateScreen};
use tui::{
@ -14,9 +13,11 @@ use tui::{
};
use unicode_width::UnicodeWidthStr;
use atuin_client::database::Database;
use atuin_client::history::History;
use atuin_client::settings::{SearchMode, Settings};
use atuin_client::{
database::Database,
history::History,
settings::{SearchMode, Settings},
};
use crate::command::event::{Event, Events};
@ -96,7 +97,7 @@ impl State {
.iter()
.enumerate()
.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);