build branch commits when there is a diff with the base

This commit is contained in:
Peter Evans 2024-08-17 21:17:22 +00:00
parent 2ba41ede85
commit 32e97fc746
3 changed files with 12 additions and 11 deletions

View file

@ -144,8 +144,7 @@ export async function createOrUpdateBranch(
branch: string,
branchRemoteName: string,
signoff: boolean,
addPaths: string[],
signCommits: boolean = false
addPaths: string[]
): Promise<CreateOrUpdateBranchResult> {
// Get the working base.
// When a ref, it may or may not be the actual base.
@ -316,8 +315,7 @@ export async function createOrUpdateBranch(
result.baseSha = await git.revParse(base)
result.headSha = await git.revParse(branch)
// NOTE: This could always be built and returned. Maybe remove when there is confidence in buildBranchCommits.
if (signCommits) {
if (result.hasDiffWithBase) {
// Build the branch commits
result.branchCommits = await buildBranchCommits(git, base, branch)
}

View file

@ -192,8 +192,7 @@ export async function createPullRequest(inputs: Inputs): Promise<void> {
inputs.branch,
branchRemoteName,
inputs.signoff,
inputs.addPaths,
inputs.signCommits
inputs.addPaths
)
outputs.set('pull-request-head-sha', result.headSha)
// Set the base. It would have been '' if not specified as an input
@ -235,6 +234,9 @@ export async function createPullRequest(inputs: Inputs): Promise<void> {
core.endGroup()
}
// If the verified output is not set yet, and there are commits (from result), and the head commit is signed, then:
// Get the commit and check verification status
if (result.hasDiffWithBase) {
core.startGroup('Create or update the pull request')
const pull = await ghPull.createOrUpdatePullRequest(