Enable silent mode

This commit is contained in:
Tonye Jack 2023-05-22 22:06:33 -06:00
parent fc9b15c757
commit 7f23de0848
3 changed files with 141 additions and 43 deletions

89
dist/index.js generated vendored
View File

@ -1110,9 +1110,7 @@ const versionToNumber = (version) => {
return major * 1000000 + minor * 1000 + patch;
};
const verifyMinimumGitVersion = () => __awaiter(void 0, void 0, void 0, function* () {
const { exitCode, stdout, stderr } = yield exec.getExecOutput('git', [
'--version'
]);
const { exitCode, stdout, stderr } = yield exec.getExecOutput('git', ['--version'], { silent: true });
if (exitCode !== 0) {
throw new Error(stderr || 'An unexpected error occurred');
}
@ -1245,7 +1243,8 @@ function getFilesFromSourceFile({ filePaths, excludedFiles = false }) {
exports.getFilesFromSourceFile = getFilesFromSourceFile;
const updateGitGlobalConfig = ({ name, value }) => __awaiter(void 0, void 0, void 0, function* () {
const { exitCode, stderr } = yield exec.getExecOutput('git', ['config', '--global', name, value], {
ignoreReturnCode: true
ignoreReturnCode: true,
silent: true
});
/* istanbul ignore if */
if (exitCode !== 0 || stderr) {
@ -1254,7 +1253,10 @@ const updateGitGlobalConfig = ({ name, value }) => __awaiter(void 0, void 0, voi
});
exports.updateGitGlobalConfig = updateGitGlobalConfig;
const isRepoShallow = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () {
const { exitCode, stdout, stderr } = yield exec.getExecOutput('git', ['rev-parse', '--is-shallow-repository'], { cwd });
const { exitCode, stdout, stderr } = yield exec.getExecOutput('git', ['rev-parse', '--is-shallow-repository'], {
cwd,
silent: true
});
if (exitCode !== 0) {
throw new Error(stderr || 'An unexpected error occurred');
}
@ -1262,7 +1264,10 @@ const isRepoShallow = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* (
});
exports.isRepoShallow = isRepoShallow;
const submoduleExists = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () {
const { exitCode, stdout, stderr } = yield exec.getExecOutput('git', ['submodule', 'status'], { cwd });
const { exitCode, stdout, stderr } = yield exec.getExecOutput('git', ['submodule', 'status'], {
cwd,
silent: true
});
if (exitCode !== 0) {
throw new Error(stderr || 'An unexpected error occurred');
}
@ -1270,7 +1275,10 @@ const submoduleExists = ({ cwd }) => __awaiter(void 0, void 0, void 0, function*
});
exports.submoduleExists = submoduleExists;
const gitFetch = ({ args, cwd }) => __awaiter(void 0, void 0, void 0, function* () {
const { exitCode, stderr } = yield exec.getExecOutput('git', ['fetch', ...args], { cwd });
const { exitCode, stderr } = yield exec.getExecOutput('git', ['fetch', ...args], {
cwd,
silent: true
});
/* istanbul ignore if */
if (exitCode !== 0 || stderr) {
core.warning(stderr || "Couldn't fetch repository");
@ -1279,7 +1287,10 @@ const gitFetch = ({ args, cwd }) => __awaiter(void 0, void 0, void 0, function*
});
exports.gitFetch = gitFetch;
const gitFetchSubmodules = ({ args, cwd }) => __awaiter(void 0, void 0, void 0, function* () {
const { exitCode, stderr } = yield exec.getExecOutput('git', ['submodule', 'foreach', 'git', 'fetch', ...args], { cwd });
const { exitCode, stderr } = yield exec.getExecOutput('git', ['submodule', 'foreach', 'git', 'fetch', ...args], {
cwd,
silent: true
});
/* istanbul ignore if */
if (exitCode !== 0 || stderr) {
core.warning(stderr || "Couldn't fetch submodules");
@ -1287,7 +1298,10 @@ const gitFetchSubmodules = ({ args, cwd }) => __awaiter(void 0, void 0, void 0,
});
exports.gitFetchSubmodules = gitFetchSubmodules;
const getSubmodulePath = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () {
const { exitCode, stdout, stderr } = yield exec.getExecOutput('git', ['submodule', 'status'], { cwd });
const { exitCode, stdout, stderr } = yield exec.getExecOutput('git', ['submodule', 'status'], {
cwd,
silent: true
});
if (exitCode !== 0) {
core.warning(stderr || "Couldn't get submodule names");
return [];
@ -1300,7 +1314,10 @@ const getSubmodulePath = ({ cwd }) => __awaiter(void 0, void 0, void 0, function
exports.getSubmodulePath = getSubmodulePath;
const gitSubmoduleDiffSHA = ({ cwd, parentSha1, parentSha2, submodulePath, diff }) => __awaiter(void 0, void 0, void 0, function* () {
var _a, _b, _c, _d;
const { exitCode, stdout, stderr } = yield exec.getExecOutput('git', ['diff', parentSha1, parentSha2, '--', submodulePath], { cwd });
const { exitCode, stdout, stderr } = yield exec.getExecOutput('git', ['diff', parentSha1, parentSha2, '--', submodulePath], {
cwd,
silent: true
});
if (exitCode !== 0) {
throw new Error(stderr || 'An unexpected error occurred');
}
@ -1312,7 +1329,7 @@ const gitSubmoduleDiffSHA = ({ cwd, parentSha1, parentSha2, submodulePath, diff
if (currentSha) {
return { previousSha, currentSha };
}
core.warning(`No submodule commit found for ${submodulePath} between ${parentSha1}${diff}${parentSha2}`);
core.debug(`No submodule commit found for ${submodulePath} between ${parentSha1}${diff}${parentSha2}`);
return {};
});
exports.gitSubmoduleDiffSHA = gitSubmoduleDiffSHA;
@ -1323,7 +1340,10 @@ const gitRenamedFiles = ({ cwd, sha1, sha2, diff, oldNewSeparator, isSubmodule =
'--ignore-submodules=all',
'--diff-filter=R',
`${sha1}${diff}${sha2}`
], { cwd });
], {
cwd,
silent: true
});
if (exitCode !== 0) {
if (isSubmodule) {
core.warning(stderr ||
@ -1352,7 +1372,10 @@ const gitDiff = ({ cwd, sha1, sha2, diff, diffFilter, filePatterns = [], isSubmo
'--ignore-submodules=all',
`--diff-filter=${diffFilter}`,
`${sha1}${diff}${sha2}`
], { cwd });
], {
cwd,
silent: true
});
if (exitCode !== 0) {
if (isSubmodule) {
core.warning(stderr ||
@ -1378,7 +1401,10 @@ const gitDiff = ({ cwd, sha1, sha2, diff, diffFilter, filePatterns = [], isSubmo
});
exports.gitDiff = gitDiff;
const gitLog = ({ args, cwd }) => __awaiter(void 0, void 0, void 0, function* () {
const { exitCode, stdout, stderr } = yield exec.getExecOutput('git', ['log', ...args], { cwd });
const { exitCode, stdout, stderr } = yield exec.getExecOutput('git', ['log', ...args], {
cwd,
silent: true
});
if (exitCode !== 0) {
throw new Error(stderr || 'An unexpected error occurred');
}
@ -1386,7 +1412,10 @@ const gitLog = ({ args, cwd }) => __awaiter(void 0, void 0, void 0, function* ()
});
exports.gitLog = gitLog;
const getHeadSha = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () {
const { exitCode, stdout, stderr } = yield exec.getExecOutput('git', ['rev-parse', 'HEAD'], { cwd });
const { exitCode, stdout, stderr } = yield exec.getExecOutput('git', ['rev-parse', 'HEAD'], {
cwd,
silent: true
});
if (exitCode !== 0) {
throw new Error(stderr || 'Unable to get HEAD sha');
}
@ -1394,7 +1423,10 @@ const getHeadSha = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () {
});
exports.getHeadSha = getHeadSha;
const getParentHeadSha = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () {
const { exitCode, stdout, stderr } = yield exec.getExecOutput('git', ['rev-parse', 'HEAD^'], { cwd });
const { exitCode, stdout, stderr } = yield exec.getExecOutput('git', ['rev-parse', 'HEAD^'], {
cwd,
silent: true
});
if (exitCode !== 0) {
throw new Error(stderr || 'Unable to get HEAD^ sha');
}
@ -1402,7 +1434,10 @@ const getParentHeadSha = ({ cwd }) => __awaiter(void 0, void 0, void 0, function
});
exports.getParentHeadSha = getParentHeadSha;
const getBranchHeadSha = ({ branch, cwd }) => __awaiter(void 0, void 0, void 0, function* () {
const { exitCode, stdout, stderr } = yield exec.getExecOutput('git', ['rev-parse', branch], { cwd });
const { exitCode, stdout, stderr } = yield exec.getExecOutput('git', ['rev-parse', branch], {
cwd,
silent: true
});
if (exitCode !== 0) {
throw new Error(stderr || `Unable to get ${branch} head sha`);
}
@ -1410,7 +1445,10 @@ const getBranchHeadSha = ({ branch, cwd }) => __awaiter(void 0, void 0, void 0,
});
exports.getBranchHeadSha = getBranchHeadSha;
const verifyCommitSha = ({ sha, cwd, showAsErrorMessage = true }) => __awaiter(void 0, void 0, void 0, function* () {
const { exitCode, stderr } = yield exec.getExecOutput('git', ['rev-parse', '--quiet', '--verify', `${sha}^{commit}`], { cwd });
const { exitCode, stderr } = yield exec.getExecOutput('git', ['rev-parse', '--quiet', '--verify', `${sha}^{commit}`], {
cwd,
silent: true
});
if (exitCode !== 0) {
if (showAsErrorMessage) {
core.error(`Unable to locate the commit sha: ${sha}`);
@ -1426,7 +1464,10 @@ const verifyCommitSha = ({ sha, cwd, showAsErrorMessage = true }) => __awaiter(v
});
exports.verifyCommitSha = verifyCommitSha;
const getPreviousGitTag = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () {
const { exitCode, stdout, stderr } = yield exec.getExecOutput('git', ['tag', '--sort=-version:refname'], { cwd });
const { exitCode, stdout, stderr } = yield exec.getExecOutput('git', ['tag', '--sort=-version:refname'], {
cwd,
silent: true
});
if (exitCode !== 0) {
throw new Error(stderr || 'Unable to get previous tag');
}
@ -1436,7 +1477,10 @@ const getPreviousGitTag = ({ cwd }) => __awaiter(void 0, void 0, void 0, functio
return { tag: '', sha: '' };
}
const previousTag = tags[1];
const { exitCode: exitCode2, stdout: stdout2, stderr: stderr2 } = yield exec.getExecOutput('git', ['rev-parse', previousTag], { cwd });
const { exitCode: exitCode2, stdout: stdout2, stderr: stderr2 } = yield exec.getExecOutput('git', ['rev-parse', previousTag], {
cwd,
silent: true
});
if (exitCode2 !== 0) {
throw new Error(stderr2 || 'Unable to get previous tag');
}
@ -1445,7 +1489,10 @@ const getPreviousGitTag = ({ cwd }) => __awaiter(void 0, void 0, void 0, functio
});
exports.getPreviousGitTag = getPreviousGitTag;
const canDiffCommits = ({ cwd, sha1, sha2, diff }) => __awaiter(void 0, void 0, void 0, function* () {
const { exitCode, stderr } = yield exec.getExecOutput('git', ['diff', '--name-only', '--ignore-submodules=all', `${sha1}${diff}${sha2}`], { cwd });
const { exitCode, stderr } = yield exec.getExecOutput('git', ['diff', '--name-only', '--ignore-submodules=all', `${sha1}${diff}${sha2}`], {
cwd,
silent: true
});
if (exitCode !== 0) {
core.warning(stderr || `Unable find merge base between ${sha1} and ${sha2}`);
return false;

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -19,9 +19,11 @@ const versionToNumber = (version: string): number => {
}
export const verifyMinimumGitVersion = async (): Promise<void> => {
const {exitCode, stdout, stderr} = await exec.getExecOutput('git', [
'--version'
])
const {exitCode, stdout, stderr} = await exec.getExecOutput(
'git',
['--version'],
{silent: true}
)
if (exitCode !== 0) {
throw new Error(stderr || 'An unexpected error occurred')
@ -143,7 +145,8 @@ export const updateGitGlobalConfig = async ({
'git',
['config', '--global', name, value],
{
ignoreReturnCode: true
ignoreReturnCode: true,
silent: true
}
)
@ -157,7 +160,10 @@ export const isRepoShallow = async ({cwd}: {cwd: string}): Promise<boolean> => {
const {exitCode, stdout, stderr} = await exec.getExecOutput(
'git',
['rev-parse', '--is-shallow-repository'],
{cwd}
{
cwd,
silent: true
}
)
if (exitCode !== 0) {
@ -175,7 +181,10 @@ export const submoduleExists = async ({
const {exitCode, stdout, stderr} = await exec.getExecOutput(
'git',
['submodule', 'status'],
{cwd}
{
cwd,
silent: true
}
)
if (exitCode !== 0) {
@ -195,7 +204,10 @@ export const gitFetch = async ({
const {exitCode, stderr} = await exec.getExecOutput(
'git',
['fetch', ...args],
{cwd}
{
cwd,
silent: true
}
)
/* istanbul ignore if */
@ -216,7 +228,10 @@ export const gitFetchSubmodules = async ({
const {exitCode, stderr} = await exec.getExecOutput(
'git',
['submodule', 'foreach', 'git', 'fetch', ...args],
{cwd}
{
cwd,
silent: true
}
)
/* istanbul ignore if */
@ -233,7 +248,10 @@ export const getSubmodulePath = async ({
const {exitCode, stdout, stderr} = await exec.getExecOutput(
'git',
['submodule', 'status'],
{cwd}
{
cwd,
silent: true
}
)
if (exitCode !== 0) {
@ -263,7 +281,10 @@ export const gitSubmoduleDiffSHA = async ({
const {exitCode, stdout, stderr} = await exec.getExecOutput(
'git',
['diff', parentSha1, parentSha2, '--', submodulePath],
{cwd}
{
cwd,
silent: true
}
)
if (exitCode !== 0) {
@ -284,7 +305,7 @@ export const gitSubmoduleDiffSHA = async ({
return {previousSha, currentSha}
}
core.warning(
core.debug(
`No submodule commit found for ${submodulePath} between ${parentSha1}${diff}${parentSha2}`
)
return {}
@ -314,7 +335,10 @@ export const gitRenamedFiles = async ({
'--diff-filter=R',
`${sha1}${diff}${sha2}`
],
{cwd}
{
cwd,
silent: true
}
)
if (exitCode !== 0) {
@ -373,7 +397,10 @@ export const gitDiff = async ({
`--diff-filter=${diffFilter}`,
`${sha1}${diff}${sha2}`
],
{cwd}
{
cwd,
silent: true
}
)
if (exitCode !== 0) {
@ -418,7 +445,10 @@ export const gitLog = async ({
const {exitCode, stdout, stderr} = await exec.getExecOutput(
'git',
['log', ...args],
{cwd}
{
cwd,
silent: true
}
)
if (exitCode !== 0) {
@ -432,7 +462,10 @@ export const getHeadSha = async ({cwd}: {cwd: string}): Promise<string> => {
const {exitCode, stdout, stderr} = await exec.getExecOutput(
'git',
['rev-parse', 'HEAD'],
{cwd}
{
cwd,
silent: true
}
)
if (exitCode !== 0) {
@ -450,7 +483,10 @@ export const getParentHeadSha = async ({
const {exitCode, stdout, stderr} = await exec.getExecOutput(
'git',
['rev-parse', 'HEAD^'],
{cwd}
{
cwd,
silent: true
}
)
if (exitCode !== 0) {
@ -470,7 +506,10 @@ export const getBranchHeadSha = async ({
const {exitCode, stdout, stderr} = await exec.getExecOutput(
'git',
['rev-parse', branch],
{cwd}
{
cwd,
silent: true
}
)
if (exitCode !== 0) {
@ -492,7 +531,10 @@ export const verifyCommitSha = async ({
const {exitCode, stderr} = await exec.getExecOutput(
'git',
['rev-parse', '--quiet', '--verify', `${sha}^{commit}`],
{cwd}
{
cwd,
silent: true
}
)
if (exitCode !== 0) {
@ -519,7 +561,10 @@ export const getPreviousGitTag = async ({
const {exitCode, stdout, stderr} = await exec.getExecOutput(
'git',
['tag', '--sort=-version:refname'],
{cwd}
{
cwd,
silent: true
}
)
if (exitCode !== 0) {
@ -539,7 +584,10 @@ export const getPreviousGitTag = async ({
exitCode: exitCode2,
stdout: stdout2,
stderr: stderr2
} = await exec.getExecOutput('git', ['rev-parse', previousTag], {cwd})
} = await exec.getExecOutput('git', ['rev-parse', previousTag], {
cwd,
silent: true
})
if (exitCode2 !== 0) {
throw new Error(stderr2 || 'Unable to get previous tag')
@ -564,7 +612,10 @@ export const canDiffCommits = async ({
const {exitCode, stderr} = await exec.getExecOutput(
'git',
['diff', '--name-only', '--ignore-submodules=all', `${sha1}${diff}${sha2}`],
{cwd}
{
cwd,
silent: true
}
)
if (exitCode !== 0) {