Default to XDG config dir with migration from ~/.sqlit#180
Merged
Conversation
Config now resolves to \$XDG_CONFIG_HOME/sqlit (falling back to ~/.config/sqlit); SQLIT_CONFIG_DIR still wins if set. Legacy ~/.sqlit is migrated on first run: - new path absent: atomic rename of the whole tree. - new path exists but holds no core config (only e.g. the cloud- discovery caches that already wrote straight into ~/.config/sqlit): merge entries in one-by-one, skipping collisions, then drop the now-empty legacy dir. - new path already holds core config (settings/connections/credentials): leave both sides alone so no user-edited files get clobbered. Also fixes three pre-existing cache paths (aws/azure/gcp discovery) that hardcoded ~/.config/sqlit and ignored SQLIT_CONFIG_DIR — now all paths route through the resolved CONFIG_DIR. User-visible mentions of ~/.sqlit in prompts, notifications and docstrings are updated to refer to the sqlit config directory generically, since the exact path varies by environment. README updated to describe the new default and the migration. Closes #129 for the documentation piece.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #174. Supersedes #129's docs change with an actual XDG default.
Before: config lived in
~/.sqlit/, withSQLIT_CONFIG_DIRas an undocumented escape hatch. #129's author and a commenter both spent time digging before finding it.After: default is
$XDG_CONFIG_HOME/sqlit(falling back to~/.config/sqlit).SQLIT_CONFIG_DIRstill wins if set.Migration on first run:
~/.sqlitabsent → nothing to do.Scope note on #174: the spec strictly splits config (
$XDG_CONFIG_HOME) from data ($XDG_DATA_HOME). This PR puts everything under$XDG_CONFIG_HOME/sqlitfor simplicity and to match how sqlit currently treats its data (one dir, one set of JSON files). If a stricter split is wanted later, it's a follow-up.Drive-by fix: three cloud-discovery cache files (
aws/azure/gcp/cache.py) previously hardcoded~/.config/sqlit/, ignoringSQLIT_CONFIG_DIR. They now route throughCONFIG_DIRlike everything else.Verified end-to-end: migrated my own
~/.sqlit(17 connections, query history, credentials, theme customizations) into~/.config/sqlitwith cache files preserved and legacy dir cleaned up. 8 new unit tests cover env-var precedence, XDG behavior, rename migration, merge migration, collision-skip, and no-op cases. Full unit suite (748 tests) still passes.Closes #129 for the documentation piece.