Skip to content
Open
75 changes: 72 additions & 3 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ base64 = "0.22.1"
chrono = "0.4.40"
clap = { version = "4.5.36", features = ["derive"] }
console = "0.15.11"
directories = "6.0.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't you also need to remove the xdg crate from the manifest?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, seems correct

fuzzy-matcher = "0.3.7"
fxhash = "0.2.1"
image = "0.25.6"
Expand Down
14 changes: 9 additions & 5 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub fn load() -> Result<(UiConfig, GraphConfig, Option<KeyBind>)> {
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 {
Expand All @@ -38,10 +38,14 @@ fn config_file_path_from_env() -> Option<PathBuf> {
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) -> Result<Config> {
Expand Down
3 changes: 2 additions & 1 deletion tests/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,8 @@ impl GitRepository<'_> {
.env("GIT_COMMITTER_EMAIL", "[email protected]")
.env("GIT_COMMITTER_DATE", datetime_str)
.env("GIT_CONFIG_NOSYSTEM", "true")
.env("HOME", "/dev/null")
.env("GIT_CONFIG_GLOBAL", "/dev/null")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems unrelated to the actual PR, no?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I remember correctly, the tests doesn't pass until you change that line. I suppose is because windows doesn't have a /dev/null dir
It was a discovery of JereKaplas, as you can read above 😊 cheers to him!

// .env("HOME", "/dev/null")
.output()
.unwrap_or_else(|_| panic!("failed to execute git {}", args.join(" ")));
println!("git {}: returned {}", args.join(" "), out.status,);
Expand Down