use showFileAtRef instead of readFileBase64

This commit is contained in:
Graham Christensen 2025-02-20 15:08:16 -05:00
parent bf28f8270d
commit c2125cf018
2 changed files with 6 additions and 2 deletions

View File

@ -211,6 +211,7 @@ export async function createPullRequest(inputs: Inputs): Promise<void> {
const stashed = await git.stashPush(['--include-untracked']) const stashed = await git.stashPush(['--include-untracked'])
await git.checkout(inputs.branch) await git.checkout(inputs.branch)
const pushSignedCommitsResult = await ghBranch.pushSignedCommits( const pushSignedCommitsResult = await ghBranch.pushSignedCommits(
git,
result.branchCommits, result.branchCommits,
result.baseCommit, result.baseCommit,
repoPath, repoPath,

View File

@ -1,6 +1,6 @@
import * as core from '@actions/core' import * as core from '@actions/core'
import {Inputs} from './create-pull-request' import {Inputs} from './create-pull-request'
import {Commit} from './git-command-manager' import {Commit, GitCommandManager} from './git-command-manager'
import {Octokit, OctokitOptions, throttleOptions} from './octokit-client' import {Octokit, OctokitOptions, throttleOptions} from './octokit-client'
import pLimit from 'p-limit' import pLimit from 'p-limit'
import * as utils from './utils' import * as utils from './utils'
@ -220,6 +220,7 @@ export class GitHubHelper {
} }
async pushSignedCommits( async pushSignedCommits(
git: GitCommandManager,
branchCommits: Commit[], branchCommits: Commit[],
baseCommit: Commit, baseCommit: Commit,
repoPath: string, repoPath: string,
@ -233,6 +234,7 @@ export class GitHubHelper {
} }
for (const commit of branchCommits) { for (const commit of branchCommits) {
headCommit = await this.createCommit( headCommit = await this.createCommit(
git,
commit, commit,
headCommit, headCommit,
repoPath, repoPath,
@ -244,6 +246,7 @@ export class GitHubHelper {
} }
private async createCommit( private async createCommit(
git: GitCommandManager,
commit: Commit, commit: Commit,
parentCommit: CommitResponse, parentCommit: CommitResponse,
repoPath: string, repoPath: string,
@ -272,7 +275,7 @@ export class GitHubHelper {
const {data: blob} = await blobCreationLimit(() => const {data: blob} = await blobCreationLimit(() =>
this.octokit.rest.git.createBlob({ this.octokit.rest.git.createBlob({
...repository, ...repository,
content: utils.readFileBase64([repoPath, path]), content: git.showFileAtRef(commit.sha, path),
encoding: 'base64' encoding: 'base64'
}) })
) )