@@ -67,7 +67,7 @@ var WorkingBaseType;
6767})(WorkingBaseType || (exports.WorkingBaseType = WorkingBaseType = {}));
6868function getWorkingBaseAndType(git) {
6969 return __awaiter(this, void 0, void 0, function* () {
70- const symbolicRefResult = yield git.exec(['symbolic-ref', 'HEAD', '--short'], true);
70+ const symbolicRefResult = yield git.exec(['symbolic-ref', 'HEAD', '--short'], { allowAllExitCodes: true } );
7171 if (symbolicRefResult.exitCode == 0) {
7272 // A ref is checked out
7373 return [symbolicRefResult.stdout.trim(), WorkingBaseType.Branch];
@@ -194,7 +194,7 @@ function createOrUpdateBranch(git, commitMessage, base, branch, branchRemoteName
194194 else {
195195 aopts.push('-A');
196196 }
197- yield git.exec(aopts, true);
197+ yield git.exec(aopts, { allowAllExitCodes: true } );
198198 const popts = ['-m', commitMessage];
199199 if (signoff) {
200200 popts.push('--signoff');
@@ -517,7 +517,7 @@ function createPullRequest(inputs) {
517517 // Create signed commits via the GitHub API
518518 const stashed = yield git.stashPush(['--include-untracked']);
519519 yield git.checkout(inputs.branch);
520- const pushSignedCommitsResult = yield ghBranch.pushSignedCommits(result.branchCommits, result.baseCommit, repoPath, branchRepository, inputs.branch);
520+ const pushSignedCommitsResult = yield ghBranch.pushSignedCommits(git, result.branchCommits, result.baseCommit, repoPath, branchRepository, inputs.branch);
521521 outputs.set('pull-request-head-sha', pushSignedCommitsResult.sha);
522522 outputs.set('pull-request-commits-verified', pushSignedCommitsResult.verified.toString());
523523 yield git.checkout('-');
@@ -704,7 +704,7 @@ class GitCommandManager {
704704 if (options) {
705705 args.push(...options);
706706 }
707- return yield this.exec(args, allowAllExitCodes);
707+ return yield this.exec(args, { allowAllExitCodes: allowAllExitCodes } );
708708 });
709709 }
710710 commit(options_1) {
@@ -716,7 +716,7 @@ class GitCommandManager {
716716 if (options) {
717717 args.push(...options);
718718 }
719- return yield this.exec(args, allowAllExitCodes);
719+ return yield this.exec(args, { allowAllExitCodes: allowAllExitCodes } );
720720 });
721721 }
722722 config(configKey, configValue, globalConfig, add) {
@@ -738,7 +738,7 @@ class GitCommandManager {
738738 '--get-regexp',
739739 configKey,
740740 configValue
741- ], true);
741+ ], { allowAllExitCodes: true } );
742742 return output.exitCode === 0;
743743 });
744744 }
@@ -835,7 +835,7 @@ class GitCommandManager {
835835 if (options) {
836836 args.push(...options);
837837 }
838- const output = yield this.exec(args, true);
838+ const output = yield this.exec(args, { allowAllExitCodes: true } );
839839 return output.exitCode === 1;
840840 });
841841 }
@@ -892,6 +892,13 @@ class GitCommandManager {
892892 return output.stdout.trim();
893893 });
894894 }
895+ showFileAtRefBase64(ref, path) {
896+ return __awaiter(this, void 0, void 0, function* () {
897+ const args = ['show', `${ref}:${path}`];
898+ const output = yield this.exec(args, { encoding: 'base64' });
899+ return output.stdout.trim();
900+ });
901+ }
895902 stashPush(options) {
896903 return __awaiter(this, void 0, void 0, function* () {
897904 const args = ['stash', 'push'];
@@ -939,13 +946,13 @@ class GitCommandManager {
939946 '--unset',
940947 configKey,
941948 configValue
942- ], true);
949+ ], { allowAllExitCodes: true } );
943950 return output.exitCode === 0;
944951 });
945952 }
946953 tryGetRemoteUrl() {
947954 return __awaiter(this, void 0, void 0, function* () {
948- const output = yield this.exec(['config', '--local', '--get', 'remote.origin.url'], true);
955+ const output = yield this.exec(['config', '--local', '--get', 'remote.origin.url'], { allowAllExitCodes: true } );
949956 if (output.exitCode !== 0) {
950957 return '';
951958 }
@@ -957,30 +964,34 @@ class GitCommandManager {
957964 });
958965 }
959966 exec(args_1) {
960- return __awaiter(this, arguments, void 0, function* (args, allowAllExitCodes = false) {
967+ return __awaiter(this, arguments, void 0, function* (args, { encoding = 'utf8', allowAllExitCodes = false } = {} ) {
961968 const result = new GitOutput();
962969 const env = {};
963970 for (const key of Object.keys(process.env)) {
964971 env[key] = process.env[key];
965972 }
966973 const stdout = [];
974+ let stdoutLength = 0;
967975 const stderr = [];
976+ let stderrLength = 0;
968977 const options = {
969978 cwd: this.workingDirectory,
970979 env,
971980 ignoreReturnCode: allowAllExitCodes,
972981 listeners: {
973982 stdout: (data) => {
974- stdout.push(data.toString());
983+ stdout.push(data);
984+ stdoutLength += data.length;
975985 },
976986 stderr: (data) => {
977- stderr.push(data.toString());
987+ stderr.push(data);
988+ stderrLength += data.length;
978989 }
979990 }
980991 };
981992 result.exitCode = yield exec.exec(`"${this.gitPath}"`, args, options);
982- result.stdout = stdout.join('' );
983- result.stderr = stderr.join('' );
993+ result.stdout = Buffer.concat( stdout, stdoutLength).toString(encoding );
994+ result.stderr = Buffer.concat( stderr, stderrLength).toString(encoding );
984995 return result;
985996 });
986997 }
@@ -1400,21 +1411,21 @@ class GitHubHelper {
14001411 return pull;
14011412 });
14021413 }
1403- pushSignedCommits(branchCommits, baseCommit, repoPath, branchRepository, branch) {
1414+ pushSignedCommits(git, branchCommits, baseCommit, repoPath, branchRepository, branch) {
14041415 return __awaiter(this, void 0, void 0, function* () {
14051416 let headCommit = {
14061417 sha: baseCommit.sha,
14071418 tree: baseCommit.tree,
14081419 verified: false
14091420 };
14101421 for (const commit of branchCommits) {
1411- headCommit = yield this.createCommit(commit, headCommit, repoPath, branchRepository);
1422+ headCommit = yield this.createCommit(git, commit, headCommit, repoPath, branchRepository);
14121423 }
14131424 yield this.createOrUpdateRef(branchRepository, branch, headCommit.sha);
14141425 return headCommit;
14151426 });
14161427 }
1417- createCommit(commit, parentCommit, repoPath, branchRepository) {
1428+ createCommit(git, commit, parentCommit, repoPath, branchRepository) {
14181429 return __awaiter(this, void 0, void 0, function* () {
14191430 const repository = this.parseRepository(branchRepository);
14201431 // In the case of an empty commit, the tree references the parent's tree
@@ -1436,7 +1447,9 @@ class GitHubHelper {
14361447 let sha = null;
14371448 if (status === 'A' || status === 'M') {
14381449 try {
1439- const { data: blob } = yield blobCreationLimit(() => this.octokit.rest.git.createBlob(Object.assign(Object.assign({}, repository), { content: utils.readFileBase64([repoPath, path]), encoding: 'base64' })));
1450+ const { data: blob } = yield blobCreationLimit(() => __awaiter(this, void 0, void 0, function* () {
1451+ return this.octokit.rest.git.createBlob(Object.assign(Object.assign({}, repository), { content: yield git.showFileAtRefBase64(commit.sha, path), encoding: 'base64' }));
1452+ }));
14401453 sha = blob.sha;
14411454 }
14421455 catch (error) {
@@ -1763,7 +1776,6 @@ exports.randomString = randomString;
17631776exports.parseDisplayNameEmail = parseDisplayNameEmail;
17641777exports.fileExistsSync = fileExistsSync;
17651778exports.readFile = readFile;
1766- exports.readFileBase64 = readFileBase64;
17671779exports.getErrorMessage = getErrorMessage;
17681780const core = __importStar(__nccwpck_require__(7484));
17691781const fs = __importStar(__nccwpck_require__(9896));
@@ -1853,15 +1865,6 @@ function fileExistsSync(path) {
18531865function readFile(path) {
18541866 return fs.readFileSync(path, 'utf-8');
18551867}
1856- function readFileBase64(pathParts) {
1857- const resolvedPath = path.resolve(...pathParts);
1858- if (fs.lstatSync(resolvedPath).isSymbolicLink()) {
1859- return fs
1860- .readlinkSync(resolvedPath, { encoding: 'buffer' })
1861- .toString('base64');
1862- }
1863- return fs.readFileSync(resolvedPath).toString('base64');
1864- }
18651868/* eslint-disable @typescript-eslint/no-explicit-any */
18661869function hasErrorCode(error) {
18671870 return typeof (error && error.code) === 'string';
0 commit comments