Commit da8b1b5
fix: isolate diff tests from local dotfiles repo state (#22)
* fix: check all git config scopes, not just --global
The previous implementation only checked --global git config, but users
may have their git identity configured in:
- Local repository config (.git/config)
- System config (/etc/gitconfig)
- Other scopes
This change first tries --global, then falls back to checking all scopes
if --global returns empty. This ensures we detect git configuration
regardless of where it's set.
Closes git config detection issue
* test: add test for git config scope fallback
Adds TestGetGitConfig_FallsBackToAnyScope to verify that GetGitConfig
checks all git config scopes (global, local, system) when looking for
user.name and user.email, not just --global.
Related to git config detection issue
* fix: don't check dotfiles repo state when URLs are empty
The diffDotfiles function was always checking the local ~/.dotfiles git
state, even when comparing snapshots with empty dotfiles URLs. This
caused test failures when the user's actual dotfiles repo had uncommitted
changes.
Fix: Only check dotfiles repo state if at least one URL is configured.
If both system and reference have empty dotfiles URLs, skip the git state
check entirely.
This makes the tests deterministic and not dependent on the user's local
dotfiles repo state.
* fix: isolate diff tests via HOME env instead of production code guards
Address PR #22 review feedback:
- Remove early return guard from diffDotfiles() that bypassed production
code paths when both URLs are empty
- Add isolateHome() test helper that sets HOME to a temp dir with a clean
.dotfiles git repo, giving full test isolation without modifying prod code
- Revert GetGitConfig() fallback change (belongs in separate PR #21)
- Remove TestGetGitConfig_FallsBackToAnyScope test (paired with reverted change)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Jerry Xie <jerryxie@Jerrys-MacBook-Air.local>
Co-authored-by: Jerry Xie <>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 8173b04 commit da8b1b5
1 file changed
+22
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
4 | 6 | | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
| 11 | + | |
9 | 12 | | |
10 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
11 | 25 | | |
| 26 | + | |
12 | 27 | | |
13 | 28 | | |
14 | 29 | | |
| |||
33 | 48 | | |
34 | 49 | | |
35 | 50 | | |
| 51 | + | |
36 | 52 | | |
37 | 53 | | |
38 | 54 | | |
| |||
58 | 74 | | |
59 | 75 | | |
60 | 76 | | |
| 77 | + | |
61 | 78 | | |
62 | 79 | | |
63 | 80 | | |
| |||
83 | 100 | | |
84 | 101 | | |
85 | 102 | | |
| 103 | + | |
86 | 104 | | |
87 | 105 | | |
88 | 106 | | |
| |||
111 | 129 | | |
112 | 130 | | |
113 | 131 | | |
| 132 | + | |
114 | 133 | | |
115 | 134 | | |
116 | 135 | | |
| |||
141 | 160 | | |
142 | 161 | | |
143 | 162 | | |
| 163 | + | |
144 | 164 | | |
145 | 165 | | |
146 | 166 | | |
| |||
155 | 175 | | |
156 | 176 | | |
157 | 177 | | |
| 178 | + | |
158 | 179 | | |
159 | 180 | | |
160 | 181 | | |
| |||
177 | 198 | | |
178 | 199 | | |
179 | 200 | | |
| 201 | + | |
180 | 202 | | |
181 | 203 | | |
182 | 204 | | |
| |||
0 commit comments