Improve error propagation, env/config handling, and lint hygiene#84
Merged
BjoernKarma merged 7 commits intomainfrom Apr 2, 2026
Merged
Improve error propagation, env/config handling, and lint hygiene#84BjoernKarma merged 7 commits intomainfrom
BjoernKarma merged 7 commits intomainfrom
Conversation
- Propagate git execution failures instead of swallowing them - Make config read/parsing errors fail command execution (except config-not-found) - Enable underscore env vars for dotted Viper keys - Update/add tests to lock behavior and prevent regressions - Run full test suite (+ race detector)
|
|
Coverage for gitctl Download the latest HTML coverage report for gitctl here. |
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.
Overview
This PR improves
gitctlreliability by fixing error propagation, tightening config/env handling, improving multi-repo failure reporting, updating tests for negative paths, and aligning docs with actual runtime behavior.It also includes a final lint/format cleanup commit so the branch is test- and lint-clean.
Why
The main goals are to:
Changes
1) Config + CLI error propagation
Refactored config helpers to return errors instead of calling
log.Fatalf:config/config.goGitctlWorkingDir() (string, error)GitctlConfigDir() (string, error)HomeDir() (string, error)Updated call sites to propagate/handle those errors:
app/cmd/root.go(InitConfig)config/env.go(GetBaseDirs)app/cmd/gitpull.goapp/cmd/gitstatus.go2) Config loading + env overrides
Hardened config initialization in
app/cmd/root.go:ConfigFileNotFoundErrorfromviper.ReadInConfig()now fails command execution,Added explicit env support for dotted keys:
viper.SetEnvPrefix("GITCTL")viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))verbosity.verbose->GITCTL_VERBOSITY_VERBOSErun_mode.local->GITCTL_RUN_MODE_LOCAL3) Multi-repo error aggregation
gitrepo/gitrepos.go:errors.Join(...),4) Tests improved (negative paths + behavior alignment)
Updated tests to cover new behavior and error paths:
app/cmd/root_test.goconfig/config_test.goconfig/env_test.goconfig/fork_test.gogitrepo/gitrepo_test.gogitrepo/gitrepos_test.goNotable additions/adjustments:
5) Documentation alignment
Updated
README.mdto reflect actual behavior:GITCTL_+ dotted key replacement),flags > env > config > defaults),6) Lint/format cleanup
Final cleanup to reach lint-clean state:
gofmt/goimports)unparamFiles touched in lint commit:
app/cmd/root_test.gocolor/colorPrinter_test.gogitrepo/gitrepos_test.gomain.gomain_test.go