mirror of
https://github.com/codecov/codecov-action.git
synced 2026-02-08 03:57:26 +00:00
fix: address feedback
This commit is contained in:
parent
d7991a51f0
commit
ad787cf9d8
4 changed files with 26 additions and 34 deletions
27
dist/index.js
vendored
27
dist/index.js
vendored
|
|
@ -32350,19 +32350,8 @@ const isPullRequestFromFork = () => {
|
|||
core.info(`baseRef: ${baseLabel} | headRef: ${headLabel}`);
|
||||
return (baseLabel.split(':')[0] !== headLabel.split(':')[0]);
|
||||
};
|
||||
/**
|
||||
* Returning null in getToken means that we're using tokenless.
|
||||
* Returning an empty string from getToken means that the token was not set
|
||||
and we don't seem to be uploading from a fork so we are not using tokenless
|
||||
*/
|
||||
const getToken = () => buildExec_awaiter(void 0, void 0, void 0, function* () {
|
||||
let token = core.getInput('token');
|
||||
if (!token && isPullRequestFromFork()) {
|
||||
core.info('==> Fork detected, tokenless uploading used');
|
||||
// backwards compatibility with certain versions of the CLI that expect this
|
||||
process.env['TOKENLESS'] = context.payload.pull_request.head.label;
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
let url = core.getInput('url');
|
||||
const useOIDC = isTrue(core.getInput('use_oidc'));
|
||||
if (useOIDC) {
|
||||
|
|
@ -32379,18 +32368,24 @@ const getToken = () => buildExec_awaiter(void 0, void 0, void 0, function* () {
|
|||
}
|
||||
return token;
|
||||
});
|
||||
const getOverrideBranch = (token) => {
|
||||
let overrideBranch = core.getInput('override_branch');
|
||||
if (!overrideBranch && !token && isPullRequestFromFork()) {
|
||||
core.info('==> Fork detected, tokenless uploading used');
|
||||
// backwards compatibility with certain versions of the CLI that expect this
|
||||
process.env['TOKENLESS'] = context.payload.pull_request.head.label;
|
||||
overrideBranch = context.payload.pull_request.head.label;
|
||||
}
|
||||
return overrideBranch;
|
||||
};
|
||||
const buildCommitExec = () => buildExec_awaiter(void 0, void 0, void 0, function* () {
|
||||
var _a;
|
||||
const commitParent = core.getInput('commit_parent');
|
||||
const gitService = getGitService();
|
||||
let overrideBranch = core.getInput('override_branch');
|
||||
const overrideCommit = core.getInput('override_commit');
|
||||
const overridePr = core.getInput('override_pr');
|
||||
const slug = core.getInput('slug');
|
||||
const token = yield getToken();
|
||||
if (!overrideBranch && token == null) {
|
||||
overrideBranch = (_a = context.payload.pull_request) === null || _a === void 0 ? void 0 : _a.head.label;
|
||||
}
|
||||
const overrideBranch = getOverrideBranch(token);
|
||||
const failCi = isTrue(core.getInput('fail_ci_if_error'));
|
||||
const workingDir = core.getInput('working-directory');
|
||||
const commitCommand = 'create-commit';
|
||||
|
|
|
|||
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
|
|
@ -364,5 +364,5 @@ test('get token when token arg is unset and from fork', async () => {
|
|||
|
||||
const token = await getToken();
|
||||
|
||||
expect(token).toEqual(null);
|
||||
expect(token).toEqual('');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -45,19 +45,8 @@ const isPullRequestFromFork = (): boolean => {
|
|||
return (baseLabel.split(':')[0] !== headLabel.split(':')[0]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returning null in getToken means that we're using tokenless.
|
||||
* Returning an empty string from getToken means that the token was not set
|
||||
and we don't seem to be uploading from a fork so we are not using tokenless
|
||||
*/
|
||||
const getToken = async (): Promise<string | null> => {
|
||||
const getToken = async (): Promise<string> => {
|
||||
let token = core.getInput('token');
|
||||
if (!token && isPullRequestFromFork()) {
|
||||
core.info('==> Fork detected, tokenless uploading used');
|
||||
// backwards compatibility with certain versions of the CLI that expect this
|
||||
process.env['TOKENLESS'] = context.payload.pull_request.head.label;
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
let url = core.getInput('url');
|
||||
const useOIDC = isTrue(core.getInput('use_oidc'));
|
||||
if (useOIDC) {
|
||||
|
|
@ -77,6 +66,17 @@ const getToken = async (): Promise<string | null> => {
|
|||
return token;
|
||||
};
|
||||
|
||||
const getOverrideBranch = (token: string): string => {
|
||||
let overrideBranch = core.getInput('override_branch');
|
||||
if (!overrideBranch && !token && isPullRequestFromFork()) {
|
||||
core.info('==> Fork detected, tokenless uploading used');
|
||||
// backwards compatibility with certain versions of the CLI that expect this
|
||||
process.env['TOKENLESS'] = context.payload.pull_request.head.label;
|
||||
overrideBranch =context.payload.pull_request.head.label;
|
||||
}
|
||||
return overrideBranch;
|
||||
};
|
||||
|
||||
const buildCommitExec = async (): Promise<{
|
||||
commitExecArgs: any[];
|
||||
commitOptions: any;
|
||||
|
|
@ -84,14 +84,11 @@ const buildCommitExec = async (): Promise<{
|
|||
}> => {
|
||||
const commitParent = core.getInput('commit_parent');
|
||||
const gitService = getGitService();
|
||||
let overrideBranch = core.getInput('override_branch');
|
||||
const overrideCommit = core.getInput('override_commit');
|
||||
const overridePr = core.getInput('override_pr');
|
||||
const slug = core.getInput('slug');
|
||||
const token = await getToken();
|
||||
if (!overrideBranch && token == null) {
|
||||
overrideBranch = context.payload.pull_request?.head.label;
|
||||
}
|
||||
const overrideBranch = getOverrideBranch(token);
|
||||
const failCi = isTrue(core.getInput('fail_ci_if_error'));
|
||||
const workingDir = core.getInput('working-directory');
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue