-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Add support for XDG_CONFIG_HOME and AppData on Windows #3671
Conversation
c000bf6
to
6461354
Compare
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.
This is heading in a great direction. Thanks for working on this!
Left some comments about tightening up the migration logic and ensuring that it's entirely exercised in tests.
Note that if we advertise support for XDG spec, then we have to adhere to it as much as we can. That means avoiding storing non-config files under XDG_CONFIG_HOME. Currently, our only non-config file is state.yml
, so that one should be migrated to XDG_STATE_HOME
accordingly. #554 (comment)
@mislav thanks for the thorough review. I addressed your comments. Regarding, |
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.
I'm fired up about this!
f34727f
to
99a31ff
Compare
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.
I'm fired up about this!
return false | ||
} | ||
|
||
var migrateConfigDir = func(oldPath, newPath string) { |
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.
I wish that this wouldn't be an overridable function anymore, but I understand that other pieces of our codebase are coupled to ConfigDir in tests and that they could inadvertently cause changes to the user's home directory.
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.
Yeah, unfortunately that is the case now. Hopefully in the future we can clean that up. I did add tests for this directly though so it isn't stubbed out in all tests.
} | ||
|
||
_ = os.MkdirAll(filepath.Dir(newPath), 0755) | ||
_ = os.Rename(oldPath, newPath) |
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.
Should we also remove the orphaned ~/.config
directory after the migration of ~/.config/gh
to the new location?
We could simply try to os.Remove
the parent. If it errors out, we ignore it.
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.
I don't think this is a good idea since it could remove files users want to keep. I actually have git
, kitty
, and nvim
configuration files in ~/.config
.
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.
os.Remove
, like the rm
command, is only able to remove empty directories. It would error out otherwise.
b002d4c
to
6d8c6c0
Compare
🎉 thanks @samcoe !! |
This PR adds support for storing
gh
config files inXDG_CONFIG_HOME
as well asAppData
on Windows.cc #2470
closes #1944
closes #554
supersedes #2080