aboutsummaryrefslogtreecommitdiffstats
path: root/crates/turtle/src/atuin_common
diff options
context:
space:
mode:
Diffstat (limited to 'crates/turtle/src/atuin_common')
-rw-r--r--crates/turtle/src/atuin_common/api.rs17
-rw-r--r--crates/turtle/src/atuin_common/utils.rs90
2 files changed, 1 insertions, 106 deletions
diff --git a/crates/turtle/src/atuin_common/api.rs b/crates/turtle/src/atuin_common/api.rs
index 2f909676..56adbcc5 100644
--- a/crates/turtle/src/atuin_common/api.rs
+++ b/crates/turtle/src/atuin_common/api.rs
@@ -125,20 +125,3 @@ pub(crate) struct MessageResponse {
pub(crate) struct MeResponse {
pub(crate) username: String,
}
-
-// Hub CLI authentication types
-
-/// Response from POST /auth/cli/code - generates a code for CLI auth
-#[derive(Debug, Serialize, Deserialize)]
-pub(crate) struct CliCodeResponse {
- pub(crate) code: String,
-}
-
-/// Response from GET /auth/cli/verify?code=<code> - polls for authorization
-#[derive(Debug, Serialize, Deserialize)]
-pub(crate) struct CliVerifyResponse {
- /// Session token, present only when authorization is complete
- pub(crate) token: Option<String>,
- pub(crate) success: Option<bool>,
- pub(crate) error: Option<String>,
-}
diff --git a/crates/turtle/src/atuin_common/utils.rs b/crates/turtle/src/atuin_common/utils.rs
index 81eb1178..09718241 100644
--- a/crates/turtle/src/atuin_common/utils.rs
+++ b/crates/turtle/src/atuin_common/utils.rs
@@ -2,8 +2,6 @@ use std::borrow::Cow;
use std::env;
use std::path::{Path, PathBuf};
-use eyre::{Result, eyre};
-
use base64::prelude::{BASE64_URL_SAFE_NO_PAD, Engine};
use getrandom::getrandom;
use uuid::Uuid;
@@ -32,10 +30,6 @@ pub(crate) fn uuid_v7() -> Uuid {
Uuid::now_v7()
}
-pub(crate) fn uuid_v4() -> String {
- Uuid::new_v4().as_simple().to_string()
-}
-
pub(crate) fn has_git_dir(path: &str) -> bool {
let mut gitdir = PathBuf::from(path);
gitdir.push(".git");
@@ -128,14 +122,6 @@ pub(crate) fn logs_dir() -> PathBuf {
home_dir().join(".atuin").join("logs")
}
-pub(crate) fn dotfiles_cache_dir() -> PathBuf {
- // In most cases, this will be ~/.local/share/atuin/dotfiles/cache
- let data_dir = std::env::var("XDG_DATA_HOME")
- .map_or_else(|_| home_dir().join(".local").join("share"), PathBuf::from);
-
- data_dir.join("atuin").join("dotfiles").join("cache")
-}
-
pub(crate) fn get_current_dir() -> String {
// Prefer PWD environment variable over cwd if available to better support symbolic links
match env::var("PWD") {
@@ -182,33 +168,8 @@ pub(crate) trait Escapable: AsRef<str> {
}
}
-pub(crate) fn unquote(s: &str) -> Result<String> {
- if s.chars().count() < 2 {
- return Err(eyre!("not enough chars"));
- }
-
- let quote = s.chars().next().unwrap();
-
- // not quoted, do nothing
- if quote != '"' && quote != '\'' && quote != '`' {
- return Ok(s.to_string());
- }
-
- if s.chars().last().unwrap() != quote {
- return Err(eyre!("unexpected eof, quotes do not match"));
- }
-
- // removes quote characters
- // the sanity checks performed above ensure that the quotes will be ASCII and this will not
- // panic
- let s = &s[1..s.len() - 1];
-
- Ok(s.to_string())
-}
-
impl<T: AsRef<str>> Escapable for T {}
-#[expect(unsafe_code)]
#[cfg(test)]
mod tests {
use pretty_assertions::assert_ne;
@@ -227,58 +188,9 @@ mod tests {
test_data_dir();
}
- #[cfg(not(windows))]
- fn test_config_dir_xdg() {
- // TODO: Audit that the environment access only happens in single-threaded code.
- unsafe { env::remove_var("HOME") };
- // TODO: Audit that the environment access only happens in single-threaded code.
- unsafe { env::set_var("XDG_CONFIG_HOME", "/home/user/custom_config") };
- assert_eq!(
- config_dir(),
- PathBuf::from("/home/user/custom_config/atuin")
- );
- // TODO: Audit that the environment access only happens in single-threaded code.
- unsafe { env::remove_var("XDG_CONFIG_HOME") };
- }
-
- #[cfg(not(windows))]
- fn test_config_dir() {
- // TODO: Audit that the environment access only happens in single-threaded code.
- unsafe { env::set_var("HOME", "/home/user") };
- // TODO: Audit that the environment access only happens in single-threaded code.
- unsafe { env::remove_var("XDG_CONFIG_HOME") };
-
- assert_eq!(config_dir(), PathBuf::from("/home/user/.config/atuin"));
-
- // TODO: Audit that the environment access only happens in single-threaded code.
- unsafe { env::remove_var("HOME") };
- }
-
- #[cfg(not(windows))]
- fn test_data_dir_xdg() {
- // TODO: Audit that the environment access only happens in single-threaded code.
- unsafe { env::remove_var("HOME") };
- // TODO: Audit that the environment access only happens in single-threaded code.
- unsafe { env::set_var("XDG_DATA_HOME", "/home/user/custom_data") };
- assert_eq!(data_dir(), PathBuf::from("/home/user/custom_data/atuin"));
- // TODO: Audit that the environment access only happens in single-threaded code.
- unsafe { env::remove_var("XDG_DATA_HOME") };
- }
-
- #[cfg(not(windows))]
- fn test_data_dir() {
- // TODO: Audit that the environment access only happens in single-threaded code.
- unsafe { env::set_var("HOME", "/home/user") };
- // TODO: Audit that the environment access only happens in single-threaded code.
- unsafe { env::remove_var("XDG_DATA_HOME") };
- assert_eq!(data_dir(), PathBuf::from("/home/user/.local/share/atuin"));
- // TODO: Audit that the environment access only happens in single-threaded code.
- unsafe { env::remove_var("HOME") };
- }
-
#[test]
fn uuid_is_unique() {
- let how_many: usize = 1000000;
+ let how_many: usize = 1_000_000;
// for peace of mind
let mut uuids: HashSet<Uuid> = HashSet::with_capacity(how_many);