Skip to content

fix: isolate diff tests from local dotfiles repo state#22

Open
jerryjrxie wants to merge 3 commits intoopenbootdotdev:mainfrom
jerryjrxie:fix/diff-test-isolation
Open

fix: isolate diff tests from local dotfiles repo state#22
jerryjrxie wants to merge 3 commits intoopenbootdotdev:mainfrom
jerryjrxie:fix/diff-test-isolation

Conversation

@jerryjrxie
Copy link
Copy Markdown

Summary

Fixes test isolation issue where diff tests failed depending on the user's local ~/.dotfiles git state.

Problem

diffDotfiles() always checked the actual ~/.dotfiles git repository for uncommitted changes, even when comparing snapshots with empty dotfiles URLs. This caused tests to fail unpredictably when the user's dotfiles repo had local changes.

Solution

Only check the local dotfiles repo state if at least one dotfiles URL is configured. If both system and reference have empty dotfiles URLs, skip the git state check entirely.

Changes

// Only check local dotfiles repo state if dotfiles are actually configured
if sysNorm == "" && refNorm == "" {
    return dd
}

Impact

  • Tests are now deterministic and don't depend on user's local dotfiles state
  • No functional change to actual diff behavior (dotfiles still checked when configured)
  • Fixes TestCompareSnapshots_Identical and TestCompareSnapshots_EmptySnapshots

Testing

  • All tests pass: make test-unit
  • Verified with dirty dotfiles repo: tests now pass

Jerry Xie and others added 3 commits March 28, 2026 22:31
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
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
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.
@github-actions
Copy link
Copy Markdown

👋 Thanks for opening this pull request!

🎉 This is your first PR to OpenBoot — welcome!

Before merging:

  • Code follows existing patterns in the codebase
  • go build ./... and go vet ./... pass
  • Commit message is clear and descriptive

@fullstackjam will review this soon. Thanks for contributing! 🚀

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.

1 participant