Skip to content

Commit

Permalink
Fix history list --cwd errors (#278)
Browse files Browse the repository at this point in the history
  • Loading branch information
lmburns authored Mar 13, 2022
1 parent e117b62 commit 7f58741
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 80 deletions.
45 changes: 0 additions & 45 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
16 changes: 11 additions & 5 deletions atuin-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -28,16 +26,24 @@ 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"
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"
2 changes: 1 addition & 1 deletion atuin-client/src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 0 additions & 2 deletions atuin-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
9 changes: 0 additions & 9 deletions atuin-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
17 changes: 8 additions & 9 deletions atuin-server/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/command/history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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?
Expand Down
13 changes: 7 additions & 6 deletions src/command/search.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand All @@ -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};

Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 7f58741

Please sign in to comment.