fix: ensure the fork remote doesn't exists before creating it (#2012)
Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
parent
c6557ed000
commit
4bbd49b998
27
dist/index.js
generated
vendored
27
dist/index.js
generated
vendored
@ -1748,8 +1748,7 @@ const getChangedFilesFromLocalGitHistory = (_a) => __awaiter(void 0, [_a], void
|
|||||||
gitFetchExtraArgs = ['--prune', '--no-recurse-submodules'];
|
gitFetchExtraArgs = ['--prune', '--no-recurse-submodules'];
|
||||||
}
|
}
|
||||||
if (isFork) {
|
if (isFork) {
|
||||||
yield (0, utils_1.setForkRemote)({ cwd: workingDirectory });
|
remoteName = yield (0, utils_1.setForkRemote)({ cwd: workingDirectory });
|
||||||
remoteName = 'fork';
|
|
||||||
}
|
}
|
||||||
let diffResult;
|
let diffResult;
|
||||||
if (!((_e = (_d = github.context.payload.pull_request) === null || _d === void 0 ? void 0 : _d.base) === null || _e === void 0 ? void 0 : _e.ref)) {
|
if (!((_e = (_d = github.context.payload.pull_request) === null || _d === void 0 ? void 0 : _d.base) === null || _e === void 0 ? void 0 : _e.ref)) {
|
||||||
@ -2523,12 +2522,30 @@ const getParentSha = (_3) => __awaiter(void 0, [_3], void 0, function* ({ cwd })
|
|||||||
return stdout.trim();
|
return stdout.trim();
|
||||||
});
|
});
|
||||||
exports.getParentSha = getParentSha;
|
exports.getParentSha = getParentSha;
|
||||||
const setForkRemote = (_4) => __awaiter(void 0, [_4], void 0, function* ({ cwd }) {
|
const remoteExists = (cwd, remoteName) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
var _5;
|
const { exitCode } = yield exec.getExecOutput('git', ['remote', 'get-url', remoteName], {
|
||||||
yield exec.getExecOutput('git', ['remote', 'add', 'fork', (_5 = github.context.payload.repository) === null || _5 === void 0 ? void 0 : _5.clone_url], {
|
|
||||||
cwd,
|
cwd,
|
||||||
|
ignoreReturnCode: true,
|
||||||
silent: !core.isDebug()
|
silent: !core.isDebug()
|
||||||
});
|
});
|
||||||
|
return exitCode === 0;
|
||||||
|
});
|
||||||
|
const setForkRemote = (_4) => __awaiter(void 0, [_4], void 0, function* ({ cwd }) {
|
||||||
|
var _5;
|
||||||
|
const remoteName = 'changed-files-fork';
|
||||||
|
const remoteFound = yield remoteExists(cwd, remoteName);
|
||||||
|
if (!remoteFound) {
|
||||||
|
yield exec.getExecOutput('git', [
|
||||||
|
'remote',
|
||||||
|
'add',
|
||||||
|
remoteName,
|
||||||
|
(_5 = github.context.payload.repository) === null || _5 === void 0 ? void 0 : _5.clone_url
|
||||||
|
], {
|
||||||
|
cwd,
|
||||||
|
silent: !core.isDebug()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return remoteName;
|
||||||
});
|
});
|
||||||
exports.setForkRemote = setForkRemote;
|
exports.setForkRemote = setForkRemote;
|
||||||
const verifyCommitSha = (_6) => __awaiter(void 0, [_6], void 0, function* ({ sha, cwd, showAsErrorMessage = true }) {
|
const verifyCommitSha = (_6) => __awaiter(void 0, [_6], void 0, function* ({ sha, cwd, showAsErrorMessage = true }) {
|
||||||
|
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
@ -88,8 +88,7 @@ const getChangedFilesFromLocalGitHistory = async ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isFork) {
|
if (isFork) {
|
||||||
await setForkRemote({cwd: workingDirectory})
|
remoteName = await setForkRemote({cwd: workingDirectory})
|
||||||
remoteName = 'fork'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let diffResult: DiffResult
|
let diffResult: DiffResult
|
||||||
|
36
src/utils.ts
36
src/utils.ts
@ -744,15 +744,45 @@ export const getParentSha = async ({cwd}: {cwd: string}): Promise<string> => {
|
|||||||
return stdout.trim()
|
return stdout.trim()
|
||||||
}
|
}
|
||||||
|
|
||||||
export const setForkRemote = async ({cwd}: {cwd: string}): Promise<void> => {
|
const remoteExists = async (
|
||||||
await exec.getExecOutput(
|
cwd: string,
|
||||||
|
remoteName: string
|
||||||
|
): Promise<boolean> => {
|
||||||
|
const {exitCode} = await exec.getExecOutput(
|
||||||
'git',
|
'git',
|
||||||
['remote', 'add', 'fork', github.context.payload.repository?.clone_url],
|
['remote', 'get-url', remoteName],
|
||||||
{
|
{
|
||||||
cwd,
|
cwd,
|
||||||
|
ignoreReturnCode: true,
|
||||||
silent: !core.isDebug()
|
silent: !core.isDebug()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
return exitCode === 0
|
||||||
|
}
|
||||||
|
|
||||||
|
export const setForkRemote = async ({cwd}: {cwd: string}): Promise<string> => {
|
||||||
|
const remoteName = 'changed-files-fork'
|
||||||
|
|
||||||
|
const remoteFound = await remoteExists(cwd, remoteName)
|
||||||
|
|
||||||
|
if (!remoteFound) {
|
||||||
|
await exec.getExecOutput(
|
||||||
|
'git',
|
||||||
|
[
|
||||||
|
'remote',
|
||||||
|
'add',
|
||||||
|
remoteName,
|
||||||
|
github.context.payload.repository?.clone_url
|
||||||
|
],
|
||||||
|
{
|
||||||
|
cwd,
|
||||||
|
silent: !core.isDebug()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return remoteName
|
||||||
}
|
}
|
||||||
|
|
||||||
export const verifyCommitSha = async ({
|
export const verifyCommitSha = async ({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user