-
-
Notifications
You must be signed in to change notification settings - Fork 609
Feat/respect xdg spec on all os #2627
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Feat/respect xdg spec on all os #2627
Conversation
I am a bit hesitant about this change since I am unsure if any logic depends on a config folder needing to exist. But as far as I can tell nothing does and creating a empty config folder in someones dotfiles when they don't want any configuration for gitui seems like terrible UX.
I'm a little trepidatious about this particular change since I am not certain there is no logic relying on a config folder existing; though as far as I can tell there isn't. If it doesn't present any issues (or even if it does present minor issues) I am a strong advocate for not forcing an empty For an app as functional as |
Could also add a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your PR!
I'm not a regular Windows user, so I didn't test the new behavior. The following is just based on code review.
I'm a little trepidatious about this particular change since I am not certain there is no logic relying on a config folder existing; though as far as I can tell there isn't.
I agree with that. There was a feature that created a null theme file a while back, but that has been removed in #1652. No need to create an empty directory.
I have a few remarks regarding the implementation.
src/args.rs
Outdated
dirs::config_dir() | ||
// List of potential config directories in order of priority | ||
let config_dir_candidates = [ | ||
env::var_os("XDG_CONFIG_HOME").map(PathBuf::from), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least according to spec, XDG_CONFIG_HOME
should only be considered if it's absolute. (Same for _CACHE
...)
src/args.rs
Outdated
]; | ||
|
||
get_path_from_candidates(config_dir_candidates) | ||
.map_err(|_| anyhow!("failed to find os config dir.")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not really the "os config dir" we were looking for, right?
for potential_dir in | ||
candidates.into_iter().flatten().filter(|p| p.is_dir()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, one more remark: At least for XDG, Path::is_dir
isn't a precondition for considering that path. If it doesn't exist, create it (with permissions 0700)
Might remove this after further scrutinizing the XDG spec
Co-authored-by: Johannes Agricola <[email protected]>
This Pull Request fixes/closes #1498.
It changes the following:
XDG_CONFIG_HOME
as the first priority.XDG_CACHE_HOME
as the top prioritygitui
config folder by default.I followed the checklist:
make check
without errors