Skip to content

Commit 4ea011f

Browse files
committed
test: force pull
1 parent 001b9c1 commit 4ea011f

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

src/sync.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,12 @@ export async function fetchRemote(dir: string, remoteName: string, branch?: stri
222222
});
223223

224224
logDebug(`Fetching from ${remoteName}${branch ? ` branch ${branch}` : ' all branches'}`);
225+
225226
if (branch === undefined) {
226227
await exec(['fetch', remoteName], dir);
227228
} else {
228229
await exec(['fetch', remoteName, branch], dir);
229230
}
231+
230232
logDebug(`Fetch completed from ${remoteName}`);
231233
}

test/forcePull.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,24 @@ describe('forcePull', () => {
5050
const finalSyncState = await getSyncState(dir, defaultGitInfo.branch, defaultGitInfo.remote);
5151
expect(finalSyncState).toBe<SyncState>('equal');
5252
});
53+
54+
test('forcePull uses correct remote and branch names (issue #515)', async () => {
55+
// This test verifies the fix for issue #515:
56+
// forcePull should use the actual remoteName and defaultBranchName
57+
// instead of defaultGitInfo.remote and defaultGitInfo.branch
58+
59+
// repo2 has pushed changes, so we should be behind after fetch
60+
await fetchRemote(dir, defaultGitInfo.remote, defaultGitInfo.branch);
61+
const syncStateBeforePull = await getSyncState(dir, defaultGitInfo.branch, defaultGitInfo.remote);
62+
63+
// Should not be equal if repo2 pushed changes
64+
expect(syncStateBeforePull).not.toBe<SyncState>('equal');
65+
66+
// forcePull should correctly fetch and reset
67+
await forcePull(getForcePullOptions());
68+
69+
// After forcePull, should definitely be equal
70+
const syncStateAfterPull = await getSyncState(dir, defaultGitInfo.branch, defaultGitInfo.remote);
71+
expect(syncStateAfterPull).toBe<SyncState>('equal');
72+
});
5373
});

0 commit comments

Comments
 (0)