Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/wt-common
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ wt_read_context_config() {
# Returns: 0 if config was loaded, 1 if not (not in repo, not enabled,
# no keys, or incomplete config).
wt_read_git_config() {
# Allow tests to skip git config loading to avoid picking up the host repo's config.
# This follows the same pattern as _wt_is_interactive override in lib/wt-adopt.
[[ -n "${_WT_SKIP_GIT_CONFIG:-}" ]] && return 1

# Only proceed if we're inside a git repo or worktree
local repo_root
repo_root="$(git rev-parse --show-toplevel 2>/dev/null)" || return 1
Expand Down
1 change: 1 addition & 0 deletions test/test_helper/common.bash
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ setup_test_env() {
export PATH="$TEST_HOME/.wt/bin:$PATH"
export _WT_ROOT="$TEST_HOME/.wt"
export LIB_DIR="$TEST_HOME/.wt/lib"
export _WT_SKIP_GIT_CONFIG=1
}

# Teardown test environment
Expand Down
5 changes: 5 additions & 0 deletions test/unit/wt-common.bats
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ setup() {

# Source the library under test
source "$TEST_HOME/.wt/lib/wt-common"

# Re-enable wt_read_git_config for unit tests that exercise it directly.
# The guard was needed during source-time to prevent host repo config bleed,
# but unit tests cd into their own mock repos before calling the function.
unset _WT_SKIP_GIT_CONFIG
}

teardown() {
Expand Down