test updates to handle shallow fetch of base

This commit is contained in:
Peter Evans 2024-03-12 13:55:31 +00:00
parent 810fe9fda7
commit 03ef719859

View file

@ -140,10 +140,22 @@ describe('create-or-update-branch tests', () => {
}) })
async function beforeTest(): Promise<void> { async function beforeTest(): Promise<void> {
await git.fetch(
[`${DEFAULT_BRANCH}:${DEFAULT_BRANCH}`],
REMOTE_NAME,
['--force', '--update-head-ok'],
true
)
await git.checkout(DEFAULT_BRANCH) await git.checkout(DEFAULT_BRANCH)
} }
async function afterTest(deleteRemote = true): Promise<void> { async function afterTest(deleteRemote = true): Promise<void> {
await git.fetch(
[`${DEFAULT_BRANCH}:${DEFAULT_BRANCH}`],
REMOTE_NAME,
['--force', '--update-head-ok'],
true
)
await git.checkout(DEFAULT_BRANCH) await git.checkout(DEFAULT_BRANCH)
try { try {
// Get the upstream branch if it exists // Get the upstream branch if it exists
@ -1454,8 +1466,7 @@ describe('create-or-update-branch tests', () => {
expect( expect(
await gitLogMatches([ await gitLogMatches([
_commitMessage, _commitMessage,
...commits.commitMsgs, commits.commitMsgs[0] // fetch depth of base is 1
INIT_COMMIT_MESSAGE
]) ])
).toBeTruthy() ).toBeTruthy()
}) })
@ -1590,7 +1601,9 @@ describe('create-or-update-branch tests', () => {
expect(await getFileContent(TRACKED_FILE)).toEqual(_changes.tracked) expect(await getFileContent(TRACKED_FILE)).toEqual(_changes.tracked)
expect(await getFileContent(UNTRACKED_FILE)).toEqual(_changes.untracked) expect(await getFileContent(UNTRACKED_FILE)).toEqual(_changes.untracked)
expect( expect(
await gitLogMatches([...commits.commitMsgs, INIT_COMMIT_MESSAGE]) await gitLogMatches([
commits.commitMsgs[0] // fetch depth of base is 1
])
).toBeTruthy() ).toBeTruthy()
}) })
@ -1668,7 +1681,9 @@ describe('create-or-update-branch tests', () => {
expect(await getFileContent(TRACKED_FILE)).toEqual(_changes.tracked) expect(await getFileContent(TRACKED_FILE)).toEqual(_changes.tracked)
expect(await getFileContent(UNTRACKED_FILE)).toEqual(_changes.untracked) expect(await getFileContent(UNTRACKED_FILE)).toEqual(_changes.untracked)
expect( expect(
await gitLogMatches([...commits.commitMsgs, INIT_COMMIT_MESSAGE]) await gitLogMatches([
commits.commitMsgs[0] // fetch depth of base is 1
])
).toBeTruthy() ).toBeTruthy()
}) })
@ -1951,8 +1966,7 @@ describe('create-or-update-branch tests', () => {
await gitLogMatches([ await gitLogMatches([
_commitMessage, _commitMessage,
..._commits.commitMsgs, ..._commits.commitMsgs,
...commitsOnBase.commitMsgs, commitsOnBase.commitMsgs[0] // fetch depth of base is 1
INIT_COMMIT_MESSAGE
]) ])
).toBeTruthy() ).toBeTruthy()
}) })
@ -2147,8 +2161,7 @@ describe('create-or-update-branch tests', () => {
expect( expect(
await gitLogMatches([ await gitLogMatches([
_commitMessage, _commitMessage,
...commitsOnBase.commitMsgs, commitsOnBase.commitMsgs[0] // fetch depth of base is 1
INIT_COMMIT_MESSAGE
]) ])
).toBeTruthy() ).toBeTruthy()
}) })