diff --git a/__test__/create-or-update-branch.int.test.ts b/__test__/create-or-update-branch.int.test.ts index 5976eb5..a8fa489 100644 --- a/__test__/create-or-update-branch.int.test.ts +++ b/__test__/create-or-update-branch.int.test.ts @@ -230,6 +230,13 @@ describe('create-or-update-branch tests', () => { expect(workingBaseType).toEqual('commit') }) + it('tests buildBranchFileChanges with no diff', async () => { + await git.checkout(BRANCH, BASE) + const branchFileChanges = await buildBranchFileChanges(git, BASE, BRANCH) + expect(branchFileChanges.additions.length).toEqual(0) + expect(branchFileChanges.deletions.length).toEqual(0) + }) + it('tests buildBranchFileChanges with addition and modification', async () => { await git.checkout(BRANCH, BASE) const changes = await createChanges() diff --git a/dist/index.js b/dist/index.js index fa37b56..b213f40 100644 --- a/dist/index.js +++ b/dist/index.js @@ -290,9 +290,8 @@ function createOrUpdateBranch(git, commitMessage, base, branch, branchRemoteName // Check if the pull request branch is ahead of the base result.hasDiffWithBase = yield isAhead(git, base, branch); } - if (result.hasDiffWithBase) { - result.branchFileChanges = yield buildBranchFileChanges(git, base, branch); - } + // Build the branch file changes + result.branchFileChanges = yield buildBranchFileChanges(git, base, branch); // Get the pull request branch SHA result.headSha = yield git.revParse('HEAD'); // Delete the temporary branch diff --git a/src/create-or-update-branch.ts b/src/create-or-update-branch.ts index 72112bd..4d354b2 100644 --- a/src/create-or-update-branch.ts +++ b/src/create-or-update-branch.ts @@ -333,9 +333,8 @@ export async function createOrUpdateBranch( result.hasDiffWithBase = await isAhead(git, base, branch) } - if (result.hasDiffWithBase) { - result.branchFileChanges = await buildBranchFileChanges(git, base, branch) - } + // Build the branch file changes + result.branchFileChanges = await buildBranchFileChanges(git, base, branch) // Get the pull request branch SHA result.headSha = await git.revParse('HEAD')