Skip to content

feat(config): add global config file support#59

Open
Amolith wants to merge 4 commits intosatococoa:mainfrom
Amolith:global-config-with-local-merge
Open

feat(config): add global config file support#59
Amolith wants to merge 4 commits intosatococoa:mainfrom
Amolith:global-config-with-local-merge

Conversation

@Amolith
Copy link
Contributor

@Amolith Amolith commented Dec 4, 2025

I've got some workflows that rely on the same local files/dirs across multiple (even all) projects. I also really like using a common worktree structure across all the projects I create/contribute to, described in that base_dir: ".." example workflow I left in the ### Global Configuration comments (happy to remove before merge).

Copying mostly-the-same config files around to all the projects then making tiny additions would be quite tedious, so this loads a global config from $XDG_CONFIG_HOME/wtp/config.yml (or ~/.config/wtp/config.yml fallback) and merges with the project-local .wtp.yml.

  • defaults: project wins if set, otherwise global
  • hooks: concatenate (global first, then project)
  • version: project wins

Happy to modify any of this before merge, or even keep it in a soft fork if you'd prefer not to maintain the changes. Thank you for creating wtp 🙂

Assisted-by: Claude Opus 4.5 via Crush
Assisted-by: Claude Sonnet 4.5 via Crush

Summary by CodeRabbit

  • New Features

    • Global configuration support: reads $XDG_CONFIG_HOME/wtp/config.yml (fallback ~/.config/wtp/config.yml) and merges with project config; project values override base_dir and hooks are concatenated with global hooks first.
  • Documentation

    • README added Global Configuration section describing file location and merge/precedence behavior.
  • Tests

    • Tests expanded for global config loading, merging, validation; test harness isolates XDG_CONFIG_HOME/HOME for reliable test runs.

✏️ Tip: You can customize this high-level summary in your review settings.

Load config from $XDG_CONFIG_HOME/wtp/config.yml (or
~/.config/wtp/config.yml fallback) and merge with project-local
.wtp.yml.

Merge behavior:
- defaults: project wins if set, otherwise global
- hooks: concatenate (global first, then project)
- version: project wins

Assisted-by: Claude Opus 4.5 via Crush
Assisted-by: Claude Sonnet 4.5 via Crush
@coderabbitai
Copy link

coderabbitai bot commented Dec 4, 2025

Warning

Rate limit exceeded

@satococoa has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 12 minutes and 56 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 51a686f and 0b83ce7.

📒 Files selected for processing (1)
  • README.md (1 hunks)

Walkthrough

Adds global configuration loaded from $XDG_CONFIG_HOME/wtp/config.yml (fallback ~/.config/wtp/config.yml), merges it with project .wtp.yml (project values win for fields like base_dir; hooks concatenated with global first). Test setup updated to isolate XDG_CONFIG_HOME/HOME during tests.

Changes

Cohort / File(s) Summary
Documentation
AGENTS.md, README.md
Documented global config location and YAML example; described merge/precedence rules (project overrides base_dir; hooks concatenated with global first).
Config implementation
internal/config/config.go
Added GlobalConfigFileName, LoadGlobalConfig(), and MergeConfigs(); updated LoadConfig() to load/merge global + project configs and validate the merged result; changed missing-project handling to allow global defaults.
Config tests
internal/config/config_test.go
Added TestMain for XDG isolation and new tests covering global config loading (XDG and HOME fallback), missing-config behavior, merge semantics (including hook order), validation, and stat/YAML error cases.
Test harness / e2e
cmd/wtp/main_test.go, cmd/wtp/testhelpers_test.go, test/e2e/framework/framework.go
Renamed test func in main_test.go; added TestMain in testhelpers_test.go to set/clean XDG_CONFIG_HOME for tests; updated e2e framework to set HOME and XDG_CONFIG_HOME for subprocesses.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Focus review on merge logic in internal/config/config.go (nil handling, field precedence, hook concatenation).
  • Inspect new tests in internal/config/config_test.go for coverage and correctness of precedence/failure cases.
  • Verify TestMain and e2e harness changes (cmd/wtp/testhelpers_test.go, test/e2e/framework/framework.go) don't conflict with CI or other tests.

Poem

🐰 I hopped through configs, dark and bright,
XDG or HOME beneath the moonlight,
Global hums first, local sings along,
Hooks joined like carrots in a song,
Tests snug in a burrow — code feels right.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(config): add global config file support' accurately summarizes the main change—introducing global configuration file functionality that is merged with project-local config.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Amolith
Copy link
Contributor Author

Amolith commented Dec 4, 2025

I decided I was tired of git worktree this morning and wanted some kind of helper. After looking around at many, I liked that yours has hooks and supports customising the base_dir to facilitate this workflow:

wtp
├── disable-gpg-signing-in-tests
├── fix-fish-completions
├── global-config-with-local-merge
└── main

I haven't decided whether I prefer cd ../branch or wtp cd branch 🤔

@satococoa satococoa self-requested a review December 5, 2025 14:13
@ericlake
Copy link

ericlake commented Mar 9, 2026

I would like to see this feature as well. I dont want to have to add a .wtp.yml to every repo and then add that to the .gitignore too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants