Repository navigation
Description
Summary
refreshesRemoteWatchedHeadCheckout fails on a Git installation configured with init.defaultBranch=main. Its fixture relies on plain git init but constructs a watch for master. The branch choice should belong to the fixture, not the developer's global Git settings.
Code evidence at 5d4987b:
Tests/CoreTests/CoreTestSupport.swift:13invokesgit initwithout a branch argument.Tests/CoreTests/WatchServiceBehaviorTests.swift:206uses that helper;:219recordsmaster, and:236refreshes it.Tests/CoreTests/SourceAndDiscoveryWorkflowTests.swift:48explicitly renames its own fixture tomaster, demonstrating a controlled branch in another test.
Reproduction
Executed at 5d4987b. Both configurations were executed. The wrapper tracks and cleans newly created fixture roots; on the tested macOS runtime, Foundation chooses the OS temporary directory independently of TMPDIR. Run this reproduction without concurrent test processes.
Run in Bash after cd "<checkout>" && swift build, replacing <checkout> with the absolute path of the checkout at this revision. Use a fresh reproduction directory. The commands isolate HOME, agent configuration, and XDG_*, and remove their fixture root on exit.
set -eu
checkout="<checkout>"
skill_bin="$checkout/.build/debug/skill"
repro_root="$checkout/.build/issue-repro-git-default-branch"
mkdir -p "$repro_root/home" "$repro_root/tmp" "$repro_root/project"
trap 'rm -rf "$repro_root"' EXIT
isolated() {
env -i PATH="$PATH" HOME="$repro_root/home" \
CODEX_HOME="$repro_root/home/.codex" \
CLAUDE_CONFIG_DIR="$repro_root/home/.claude" \
XDG_CONFIG_HOME="$repro_root/home/.config" \
XDG_STATE_HOME="$repro_root/home/.local/state" \
XDG_CACHE_HOME="$repro_root/home/.cache" TMPDIR="$repro_root/tmp" \
GIT_CONFIG_NOSYSTEM=1 GIT_CONFIG_GLOBAL=/dev/null \
GIT_AUTHOR_NAME=Fixture [email protected] \
GIT_COMMITTER_NAME=Fixture [email protected] \
"$@"
}
skill() { isolated "$skill_bin" "$@"; }
cd "$repro_root/project"
cd "$checkout"
# Foundation may choose the OS temporary directory independently of TMPDIR.
fixture_base="$(isolated swift -module-cache-path "$repro_root/module-cache" -e 'import Foundation; print(FileManager.default.temporaryDirectory.path)')"
# Run without other test processes; track only the fixture roots created here.
isolated python3 - "$fixture_base" "$repro_root" <<'CODE'
import json, os, shutil, subprocess, sys
from pathlib import Path
base=Path(sys.argv[1])
root=Path(sys.argv[2])
prefixes=['skill-cli-tests','skill-cli-cli-tests']
before={p for name in prefixes for p in (base/name).glob('*')}
try:
for branch in ['main', 'master']:
child=dict(os.environ, GIT_CONFIG_COUNT='1', GIT_CONFIG_KEY_0='init.defaultBranch', GIT_CONFIG_VALUE_0=branch)
result=subprocess.run(['swift','test','--filter','refreshesRemoteWatchedHeadCheckout'], env=child)
print(branch, 'default exit:', result.returncode)
finally:
after={p for name in prefixes for p in (base/name).glob('*')}
for p in after-before:
shutil.rmtree(p)
CODEObserved output (relevant lines; temporary paths shortened to <temp>):
refreshesRemoteWatchedHeadCheckout() recorded an issue at WatchServiceBehaviorTests.swift:194:4:
Caught error: Command failed: /usr/bin/env git -C <temp>/.agent/cache/sources/remote-source checkout master
main default exit: 1
master default exit: 0
Expected Behavior
Create fixture repositories with an explicit initial branch and use that branch consistently in watch state. Keep the policy in the shared Git fixture helper or pass the intended branch to it.
Completion checks:
- The named test and
swift testpass with parent Git defaultsmainandmaster. - Fixture commits do not depend on global identity/signing settings.
- Do not modify the developer's Git configuration. No product branch-policy change is needed.
Actual Behavior
The same test fails under main because checkout master cannot resolve the branch, then passes under master. The test process receives the setting through temporary environment entries; no global Git config is changed.
Duplicate check: no matching issue or PR. PR #12 adds other tests but does not address Git fixture branch selection.
Environment
- Source revision:
5d4987b(5d4987b9e1f94e8b9f85124299f05d5aa4f45f07). - CLI version:
0.2.1; built successfully withswift build. - Swift: Apple Swift 6.4 (
swiftlang-6.4.0.34.1,clang-2100.3.34.1). - OS: macOS 27.0.1 (26A434).
- Architecture: arm64.
- Git: 2.42.0. Validation date: 2026-10-17.
Activity