Skip to content

v0.x: the config directory takes the tool

A tool can declare that its user directory is $XDG_CONFIG_HOME/<tool> (spec 0221). The functions that resolved the directory from a name could not see that choice, so they take the tool instead. A tool that declares nothing keeps ~/.<tool>.

What changes

  • setup.GetDefaultConfigDir(fs, name) is removed. setup.ConfigDir(tool) replaces it.
  • These take tool props.Tool where they took name string, in the same position:
    • TimeSinceLast, GetTimeSinceLast, SetTimeSinceLast, SetCheckedVersion, GetCheckedVersion
    • CanPin, SetPinnedVersion, GetPinnedVersion, SkipUpdateCheck
    • IsProjectConfigTrusted, TrustProjectConfig, UntrustProjectConfig, ListTrustedProjects
    • EnsureDefaultConfigDir, CheckRotationRecord
  • props.ConfigSpec gains Dir, and props.New refuses a value other than empty, props.ConfigDirHome or props.ConfigDirXDG.

What to do

  • Replace setup.GetDefaultConfigDir(p.FS, p.Tool.Name) with setup.ConfigDir(p.Tool).
  • Replace p.Tool.Name with p.Tool in a call to a function listed above.
  • A generated project with a config initialiser (with_initializer) fails to compile until its init.go makes the first change. gtb regenerate project writes it, except in an init.go you have edited and kept, which you change by hand. The break is deliberate: an initialiser still naming the old directory would write a config an XDG tool never reads.
  • A tool that sets Config.Dir after it has released moves its users' files itself. One left behind matters more than the rest: without rotation.json, a release key revoked before the change is trusted again until a release carries a rotation manifest.
  • doctor and update now warn where a key rotation cannot be kept (setup.CanKeepRotationRecord), which is wherever the config directory is inside a git checkout, or cannot be resolved.