(t *testing.T)
| 1278 | } |
| 1279 | |
| 1280 | func TestClientPullRejectsNonFastForwardUpdate(t *testing.T) { |
| 1281 | // Given local and remote trunk branches that have diverged |
| 1282 | source := newTestRepo(t) |
| 1283 | remote := newBareTestRepo(t) |
| 1284 | source.commit(t, "initial commit") |
| 1285 | source.run(t, "remote", "add", "origin", remote.fileURL()) |
| 1286 | source.run(t, "push", "--quiet", "origin", "trunk") |
| 1287 | destination := newTestRepo(t) |
| 1288 | destination.run(t, "remote", "add", "origin", remote.fileURL()) |
| 1289 | destination.run(t, "fetch", "--quiet", "origin", "trunk") |
| 1290 | destination.run(t, "reset", "--quiet", "--hard", "origin/trunk") |
| 1291 | localHead := destination.commit(t, "local update") |
| 1292 | source.commit(t, "remote update") |
| 1293 | source.run(t, "push", "--quiet", "origin", "trunk") |
| 1294 | destination.run(t, "config", "pull.rebase", "false") |
| 1295 | |
| 1296 | // When the remote branch is pulled |
| 1297 | err := destination.client.Pull(t.Context(), "origin", "trunk") |
| 1298 | |
| 1299 | // Then the fast-forward-only pull fails without merging either branch |
| 1300 | require.Error(t, err) |
| 1301 | var gitErr *GitError |
| 1302 | require.ErrorAs(t, err, &gitErr) |
| 1303 | assert.NotZero(t, gitErr.ExitCode) |
| 1304 | assert.Equal(t, localHead, destination.run(t, "rev-parse", "HEAD")) |
| 1305 | assert.Equal(t, "2", destination.run(t, "rev-list", "--count", "HEAD")) |
| 1306 | } |
| 1307 | |
| 1308 | func TestClientPullUsesAuthenticatedFastForwardOnlyCommand(t *testing.T) { |
| 1309 | // Given a client that records the Git command |
nothing calls this directly
no test coverage detected