From e2f6953546425a069d17ab0eda0726bc9c1b42bf Mon Sep 17 00:00:00 2001 From: Auca Coyan Date: Fri, 27 Dec 2024 19:24:00 -0300 Subject: [PATCH 1/7] :sparkles: it compiles in Windows! --- Cargo.lock | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 1 + src/config.rs | 14 +++++++++----- 3 files changed, 59 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b55c330..ac0ecb6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -630,6 +630,27 @@ dependencies = [ "walkdir", ] +[[package]] +name = "directories" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a49173b84e034382284f27f1af4dcbbd231ffa358c0fe316541a7337f376a35" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys 0.48.0", +] + [[package]] name = "either" version = "1.13.0" @@ -1154,6 +1175,16 @@ dependencies = [ "once_cell", ] +[[package]] +name = "libredox" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +dependencies = [ + "bitflags 2.6.0", + "libc", +] + [[package]] name = "linux-raw-sys" version = "0.4.14" @@ -1440,6 +1471,12 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + [[package]] name = "owo-colors" version = "3.5.0" @@ -1715,6 +1752,17 @@ dependencies = [ "bitflags 2.6.0", ] +[[package]] +name = "redox_users" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" +dependencies = [ + "getrandom", + "libredox", + "thiserror", +] + [[package]] name = "regex" version = "1.10.6" @@ -1951,6 +1999,7 @@ dependencies = [ "color-eyre", "console", "dircpy", + "directories", "fxhash", "image", "ratatui", diff --git a/Cargo.toml b/Cargo.toml index 3fd977c..6c6c49a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,6 +21,7 @@ chrono = "0.4.38" clap = { version = "4.5.17", features = ["derive"] } color-eyre = "0.6.3" console = "0.15.8" +directories = "5.0.1" fxhash = "0.2.1" image = "0.25.2" ratatui = "0.28.1" diff --git a/src/config.rs b/src/config.rs index 9cd5a68..ececb4d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -36,7 +36,7 @@ pub fn load() -> (UiConfig, GraphConfig, Option) { read_config_from_path(&user_path) } None => { - let default_path = xdg_config_file_path(); + let default_path = config_file_path(); if default_path.exists() { read_config_from_path(&default_path) } else { @@ -51,10 +51,14 @@ fn config_file_path_from_env() -> Option { env::var(CONFIG_FILE_ENV_NAME).ok().map(PathBuf::from) } -fn xdg_config_file_path() -> PathBuf { - xdg::BaseDirectories::with_prefix(APP_DIR_NAME) - .unwrap() - .get_config_file(CONFIG_FILE_NAME) +fn config_file_path() -> PathBuf { + use directories::BaseDirs; + + BaseDirs::new() + .expect("Couldn't get the base user directories!") + .config_dir() + .join(APP_DIR_NAME) + .join(CONFIG_FILE_NAME) } fn read_config_from_path(path: &Path) -> Config { From 8465a5fbbbb4d34ba5b370f797b4f4c0a40805aa Mon Sep 17 00:00:00 2001 From: Auca Coyan Date: Fri, 27 Dec 2024 19:54:30 -0300 Subject: [PATCH 2/7] :fire: remove `xdg` crate --- Cargo.lock | 7 ------- Cargo.toml | 1 - 2 files changed, 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ac0ecb6..746d0bc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2013,7 +2013,6 @@ dependencies = [ "toml", "tui-input", "tui-tree-widget", - "xdg", ] [[package]] @@ -2797,12 +2796,6 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec107c4503ea0b4a98ef47356329af139c0a4f7750e621cf2973cd3385ebcb3d" -[[package]] -name = "xdg" -version = "2.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "213b7324336b53d2414b2db8537e56544d981803139155afa84f76eeebb7a546" - [[package]] name = "xml-rs" version = "0.8.20" diff --git a/Cargo.toml b/Cargo.toml index 6c6c49a..83cf3b3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,6 @@ serde_json = "1.0.128" toml = "0.8.19" tui-input = "0.10.1" tui-tree-widget = "0.22.0" -xdg = "2.5.2" [dev-dependencies] dircpy = "0.3.19" From 0e9d42d8eabc22bfde56d9528e389e951f453f76 Mon Sep 17 00:00:00 2001 From: Auca Coyan Date: Mon, 13 Jan 2025 14:47:55 -0300 Subject: [PATCH 3/7] :rotating_light: fix a lint --- src/widget/commit_list.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/widget/commit_list.rs b/src/widget/commit_list.rs index 021ab3c..71c59c4 100644 --- a/src/widget/commit_list.rs +++ b/src/widget/commit_list.rs @@ -737,9 +737,9 @@ impl CommitList<'_> { } fn rendering_commit_info_iter<'a>( - &'a self, - state: &'a CommitListState, - ) -> impl Iterator { + &self, + state: &'a CommitListState<'a>, + ) -> impl Iterator)> { state .commits .iter() From c69e12acf27307e0361b773a27cd37ca2726ade4 Mon Sep 17 00:00:00 2001 From: Auca Coyan Date: Mon, 13 Jan 2025 15:03:34 -0300 Subject: [PATCH 4/7] :mute: silence a clippy warning --- src/widget/commit_list.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/widget/commit_list.rs b/src/widget/commit_list.rs index 021ab3c..3ac7ea7 100644 --- a/src/widget/commit_list.rs +++ b/src/widget/commit_list.rs @@ -736,6 +736,7 @@ impl CommitList<'_> { Widget::render(List::new(items), area, buf); } + #[allow(elided_named_lifetimes)] fn rendering_commit_info_iter<'a>( &'a self, state: &'a CommitListState, From 6bf55bab46bfae3d19f7e6e551280ba8917a3fa3 Mon Sep 17 00:00:00 2001 From: Auca Coyan Date: Mon, 13 Jan 2025 15:12:45 -0300 Subject: [PATCH 5/7] :twisted_rightwards_arrows: fix merge conflict --- Cargo.lock | 75 ++++++++++++++++++++++++++++++++++++++++++++++++--- Cargo.toml | 1 + src/config.rs | 15 ++++++----- 3 files changed, 82 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 72db6fe..6fb5957 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -630,6 +630,27 @@ dependencies = [ "walkdir", ] +[[package]] +name = "directories" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16f5094c54661b38d03bd7e50df373292118db60b585c08a411c6d840017fe7d" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys 0.59.0", +] + [[package]] name = "either" version = "1.13.0" @@ -1117,6 +1138,16 @@ dependencies = [ "once_cell", ] +[[package]] +name = "libredox" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +dependencies = [ + "bitflags 2.6.0", + "libc", +] + [[package]] name = "linux-raw-sys" version = "0.4.14" @@ -1403,6 +1434,12 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + [[package]] name = "owo-colors" version = "3.5.0" @@ -1623,7 +1660,7 @@ dependencies = [ "rand_chacha", "simd_helpers", "system-deps", - "thiserror", + "thiserror 1.0.62", "v_frame", "wasm-bindgen", ] @@ -1678,6 +1715,17 @@ dependencies = [ "bitflags 2.6.0", ] +[[package]] +name = "redox_users" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd6f9d3d47bdd2ad6945c5015a226ec6155d0bcdfd8f7cd29f86b71f8de99d2b" +dependencies = [ + "getrandom", + "libredox", + "thiserror 2.0.11", +] + [[package]] name = "regex" version = "1.10.6" @@ -1914,6 +1962,7 @@ dependencies = [ "color-eyre", "console", "dircpy", + "directories", "fxhash", "image", "laurier", @@ -2134,7 +2183,7 @@ dependencies = [ "png", "resvg", "siphasher", - "thiserror", + "thiserror 1.0.62", "tiny-skia", "usvg", "xml-rs", @@ -2146,7 +2195,16 @@ version = "1.0.62" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2675633b1499176c2dff06b0856a27976a8f9d436737b4cf4f312d4d91d8bbb" dependencies = [ - "thiserror-impl", + "thiserror-impl 1.0.62", +] + +[[package]] +name = "thiserror" +version = "2.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" +dependencies = [ + "thiserror-impl 2.0.11", ] [[package]] @@ -2160,6 +2218,17 @@ dependencies = [ "syn 2.0.93", ] +[[package]] +name = "thiserror-impl" +version = "2.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.93", +] + [[package]] name = "thread_local" version = "1.1.8" diff --git a/Cargo.toml b/Cargo.toml index aec89f8..359c2de 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,6 +21,7 @@ chrono = "0.4.39" clap = { version = "4.5.26", features = ["derive"] } color-eyre = "0.6.3" console = "0.15.10" +directories = "6.0.0" fxhash = "0.2.1" image = "0.25.5" laurier = "0.1.0" diff --git a/src/config.rs b/src/config.rs index 9cd5a68..9cf0fbc 100644 --- a/src/config.rs +++ b/src/config.rs @@ -36,7 +36,7 @@ pub fn load() -> (UiConfig, GraphConfig, Option) { read_config_from_path(&user_path) } None => { - let default_path = xdg_config_file_path(); + let default_path = config_file_path(); if default_path.exists() { read_config_from_path(&default_path) } else { @@ -51,11 +51,14 @@ fn config_file_path_from_env() -> Option { env::var(CONFIG_FILE_ENV_NAME).ok().map(PathBuf::from) } -fn xdg_config_file_path() -> PathBuf { - xdg::BaseDirectories::with_prefix(APP_DIR_NAME) - .unwrap() - .get_config_file(CONFIG_FILE_NAME) -} +fn config_file_path() -> PathBuf { + use directories::BaseDirs; + + BaseDirs::new() + .expect("Couldn't get the base user directories!") + .config_dir() + .join(APP_DIR_NAME) + .join(CONFIG_FILE_NAME) fn read_config_from_path(path: &Path) -> Config { let content = std::fs::read_to_string(path).unwrap(); From f5ad52c88c3a51e528c4ced2b66061863b5d2338 Mon Sep 17 00:00:00 2001 From: Auca Coyan Date: Mon, 13 Jan 2025 15:17:31 -0300 Subject: [PATCH 6/7] :adhesive_bandage: tiny fix --- Cargo.lock | 7 +++++++ src/config.rs | 1 + 2 files changed, 8 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 2efd05a..6fb5957 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1977,6 +1977,7 @@ dependencies = [ "toml", "tui-input", "tui-tree-widget", + "xdg", ] [[package]] @@ -2787,6 +2788,12 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec107c4503ea0b4a98ef47356329af139c0a4f7750e621cf2973cd3385ebcb3d" +[[package]] +name = "xdg" +version = "2.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "213b7324336b53d2414b2db8537e56544d981803139155afa84f76eeebb7a546" + [[package]] name = "xml-rs" version = "0.8.20" diff --git a/src/config.rs b/src/config.rs index 9cf0fbc..ececb4d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -59,6 +59,7 @@ fn config_file_path() -> PathBuf { .config_dir() .join(APP_DIR_NAME) .join(CONFIG_FILE_NAME) +} fn read_config_from_path(path: &Path) -> Config { let content = std::fs::read_to_string(path).unwrap(); From 06025eaa84656c5c463ec7b665e54765f600326d Mon Sep 17 00:00:00 2001 From: Auca Coyan Date: Mon, 13 Jan 2025 15:21:34 -0300 Subject: [PATCH 7/7] :rotating_light: remove the `allow(lint)` to make clippy check it --- src/widget/commit_list.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/widget/commit_list.rs b/src/widget/commit_list.rs index 010ec48..e71b91e 100644 --- a/src/widget/commit_list.rs +++ b/src/widget/commit_list.rs @@ -705,7 +705,6 @@ impl CommitList<'_> { Widget::render(List::new(items), area, buf); } - #[allow(elided_named_lifetimes)] fn rendering_commit_info_iter<'a>( &'a self, state: &'a CommitListState,