fix format and cleanup

This commit is contained in:
Peter Evans 2024-08-09 13:04:15 +00:00
parent 93858f721d
commit 491f77f4d6
4 changed files with 11 additions and 23 deletions

View file

@ -321,13 +321,13 @@ export async function createOrUpdateBranch(
result.hasDiffWithBase = await isAhead(git, base, branch)
}
// Build the branch commits
result.branchCommits = await buildBranchCommits(git, base, branch)
// Get the base and head SHAs
result.baseSha = await git.revParse(base)
result.headSha = await git.revParse(branch)
// Build the branch commits
result.branchCommits = await buildBranchCommits(git, base, branch)
// Delete the temporary branch
await git.exec(['branch', '--delete', '--force', tempBranch])

View file

@ -196,7 +196,7 @@ export async function createPullRequest(inputs: Inputs): Promise<void> {
`Pushing pull request branch to '${branchRemoteName}/${inputs.branch}'`
)
if (inputs.signCommit) {
// Stash any uncommitted tracked and untracked changes
// Create signed commits via the GitHub API
const stashed = await git.stashPush(['--include-untracked'])
await git.checkout(inputs.branch)
await githubHelper.pushSignedCommits(

View file

@ -201,16 +201,7 @@ export class GitHubHelper {
branch: string
): Promise<void> {
let headSha = baseSha
// testing
if (branchCommits.length > 0 && branchCommits[0].parents[0] !== baseSha) {
throw new Error(
`The base commit ${baseSha} does not match the first commit's parent ${branchCommits[0].parents[0]}`
)
}
for (const commit of branchCommits) {
// TODO: The headSha of the previous commit should be passed and used as the parent.
headSha = await this.createCommit(
commit,
[headSha],
@ -270,7 +261,9 @@ export class GitHubHelper {
core.info(
`Created commit ${remoteCommit.sha} for local commit ${commit.sha}`
)
core.debug(`Commit verified: ${remoteCommit.verification.verified}; reason: ${remoteCommit.verification.reason}`)
core.info(
`Commit verified: ${remoteCommit.verification.verified}; reason: ${remoteCommit.verification.reason}`
)
return remoteCommit.sha
}