@@ -67,7 +67,7 @@ var WorkingBaseType;
67
67
})(WorkingBaseType || (exports.WorkingBaseType = WorkingBaseType = {}));
68
68
function getWorkingBaseAndType(git) {
69
69
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 } );
71
71
if (symbolicRefResult.exitCode == 0) {
72
72
// A ref is checked out
73
73
return [symbolicRefResult.stdout.trim(), WorkingBaseType.Branch];
@@ -194,7 +194,7 @@ function createOrUpdateBranch(git, commitMessage, base, branch, branchRemoteName
194
194
else {
195
195
aopts.push('-A');
196
196
}
197
- yield git.exec(aopts, true);
197
+ yield git.exec(aopts, { allowAllExitCodes: true } );
198
198
const popts = ['-m', commitMessage];
199
199
if (signoff) {
200
200
popts.push('--signoff');
@@ -517,7 +517,7 @@ function createPullRequest(inputs) {
517
517
// Create signed commits via the GitHub API
518
518
const stashed = yield git.stashPush(['--include-untracked']);
519
519
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);
521
521
outputs.set('pull-request-head-sha', pushSignedCommitsResult.sha);
522
522
outputs.set('pull-request-commits-verified', pushSignedCommitsResult.verified.toString());
523
523
yield git.checkout('-');
@@ -704,7 +704,7 @@ class GitCommandManager {
704
704
if (options) {
705
705
args.push(...options);
706
706
}
707
- return yield this.exec(args, allowAllExitCodes);
707
+ return yield this.exec(args, { allowAllExitCodes: allowAllExitCodes } );
708
708
});
709
709
}
710
710
commit(options_1) {
@@ -716,7 +716,7 @@ class GitCommandManager {
716
716
if (options) {
717
717
args.push(...options);
718
718
}
719
- return yield this.exec(args, allowAllExitCodes);
719
+ return yield this.exec(args, { allowAllExitCodes: allowAllExitCodes } );
720
720
});
721
721
}
722
722
config(configKey, configValue, globalConfig, add) {
@@ -738,7 +738,7 @@ class GitCommandManager {
738
738
'--get-regexp',
739
739
configKey,
740
740
configValue
741
- ], true);
741
+ ], { allowAllExitCodes: true } );
742
742
return output.exitCode === 0;
743
743
});
744
744
}
@@ -835,7 +835,7 @@ class GitCommandManager {
835
835
if (options) {
836
836
args.push(...options);
837
837
}
838
- const output = yield this.exec(args, true);
838
+ const output = yield this.exec(args, { allowAllExitCodes: true } );
839
839
return output.exitCode === 1;
840
840
});
841
841
}
@@ -892,6 +892,13 @@ class GitCommandManager {
892
892
return output.stdout.trim();
893
893
});
894
894
}
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
+ }
895
902
stashPush(options) {
896
903
return __awaiter(this, void 0, void 0, function* () {
897
904
const args = ['stash', 'push'];
@@ -939,13 +946,13 @@ class GitCommandManager {
939
946
'--unset',
940
947
configKey,
941
948
configValue
942
- ], true);
949
+ ], { allowAllExitCodes: true } );
943
950
return output.exitCode === 0;
944
951
});
945
952
}
946
953
tryGetRemoteUrl() {
947
954
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 } );
949
956
if (output.exitCode !== 0) {
950
957
return '';
951
958
}
@@ -957,30 +964,34 @@ class GitCommandManager {
957
964
});
958
965
}
959
966
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 } = {} ) {
961
968
const result = new GitOutput();
962
969
const env = {};
963
970
for (const key of Object.keys(process.env)) {
964
971
env[key] = process.env[key];
965
972
}
966
973
const stdout = [];
974
+ let stdoutLength = 0;
967
975
const stderr = [];
976
+ let stderrLength = 0;
968
977
const options = {
969
978
cwd: this.workingDirectory,
970
979
env,
971
980
ignoreReturnCode: allowAllExitCodes,
972
981
listeners: {
973
982
stdout: (data) => {
974
- stdout.push(data.toString());
983
+ stdout.push(data);
984
+ stdoutLength += data.length;
975
985
},
976
986
stderr: (data) => {
977
- stderr.push(data.toString());
987
+ stderr.push(data);
988
+ stderrLength += data.length;
978
989
}
979
990
}
980
991
};
981
992
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 );
984
995
return result;
985
996
});
986
997
}
@@ -1400,21 +1411,21 @@ class GitHubHelper {
1400
1411
return pull;
1401
1412
});
1402
1413
}
1403
- pushSignedCommits(branchCommits, baseCommit, repoPath, branchRepository, branch) {
1414
+ pushSignedCommits(git, branchCommits, baseCommit, repoPath, branchRepository, branch) {
1404
1415
return __awaiter(this, void 0, void 0, function* () {
1405
1416
let headCommit = {
1406
1417
sha: baseCommit.sha,
1407
1418
tree: baseCommit.tree,
1408
1419
verified: false
1409
1420
};
1410
1421
for (const commit of branchCommits) {
1411
- headCommit = yield this.createCommit(commit, headCommit, repoPath, branchRepository);
1422
+ headCommit = yield this.createCommit(git, commit, headCommit, repoPath, branchRepository);
1412
1423
}
1413
1424
yield this.createOrUpdateRef(branchRepository, branch, headCommit.sha);
1414
1425
return headCommit;
1415
1426
});
1416
1427
}
1417
- createCommit(commit, parentCommit, repoPath, branchRepository) {
1428
+ createCommit(git, commit, parentCommit, repoPath, branchRepository) {
1418
1429
return __awaiter(this, void 0, void 0, function* () {
1419
1430
const repository = this.parseRepository(branchRepository);
1420
1431
// In the case of an empty commit, the tree references the parent's tree
@@ -1436,7 +1447,9 @@ class GitHubHelper {
1436
1447
let sha = null;
1437
1448
if (status === 'A' || status === 'M') {
1438
1449
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
+ }));
1440
1453
sha = blob.sha;
1441
1454
}
1442
1455
catch (error) {
@@ -1763,7 +1776,6 @@ exports.randomString = randomString;
1763
1776
exports.parseDisplayNameEmail = parseDisplayNameEmail;
1764
1777
exports.fileExistsSync = fileExistsSync;
1765
1778
exports.readFile = readFile;
1766
- exports.readFileBase64 = readFileBase64;
1767
1779
exports.getErrorMessage = getErrorMessage;
1768
1780
const core = __importStar(__nccwpck_require__(7484));
1769
1781
const fs = __importStar(__nccwpck_require__(9896));
@@ -1853,15 +1865,6 @@ function fileExistsSync(path) {
1853
1865
function readFile(path) {
1854
1866
return fs.readFileSync(path, 'utf-8');
1855
1867
}
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
- }
1865
1868
/* eslint-disable @typescript-eslint/no-explicit-any */
1866
1869
function hasErrorCode(error) {
1867
1870
return typeof (error && error.code) === 'string';
0 commit comments