fix(walkthrough): use remote default branch

This commit is contained in:
RyderAsking
2026-08-04 16:48:24 +00:00
parent 746e0d4abd
commit b4ced01cc7
8 changed files with 121 additions and 10 deletions
@@ -10,6 +10,7 @@ import {
cherryPick,
createWorktree,
getWorktreeBootstrapStatus,
getBranches,
getStatus,
isGitRepository,
populateWorktreeWithLockRecovery,
@@ -988,3 +989,25 @@ describe('hash validation', () => {
).rejects.not.toThrow('Invalid commit hash');
});
});
describe.runIf(canRunGit())('getBranches', () => {
it('returns a remote default branch whose name is not a conventional fallback', async () => {
const remote = createTempDir();
const repository = createTempDir();
runGit(remote, ['init', '--bare', '--initial-branch=react']);
runGit(repository, ['init', '-b', 'next']);
runGit(repository, ['config', 'user.email', 'test@example.com']);
runGit(repository, ['config', 'user.name', 'Test']);
fs.writeFileSync(path.join(repository, 'README.md'), '# Test\n');
runGit(repository, ['add', 'README.md']);
runGit(repository, ['commit', '-m', 'init']);
runGit(repository, ['remote', 'add', 'origin', remote]);
runGit(repository, ['push', 'origin', 'HEAD:react']);
runGit(repository, ['fetch', 'origin']);
runGit(repository, ['remote', 'set-head', 'origin', '--auto']);
await expect(getBranches(repository)).resolves.toMatchObject({
defaultBranches: { origin: 'react' },
});
});
});