Updated silent setting.

This commit is contained in:
Tonye Jack 2023-06-22 21:41:47 -06:00
parent 71c896b78e
commit d2a611248f
2 changed files with 40 additions and 26 deletions

View File

@ -278,7 +278,7 @@ export const getChangedFilesFromGithubAPI = async ({
core.info('Getting changed files from GitHub API...') core.info('Getting changed files from GitHub API...')
for await (const response of octokit.paginate.iterator< for await (const response of octokit.paginate.iterator<
RestEndpointMethodTypes['pulls']['listFiles']['response']['data'] RestEndpointMethodTypes['pulls']['listFiles']['response']['data'][0]
>( >(
octokit.pulls.listFiles.endpoint.merge({ octokit.pulls.listFiles.endpoint.merge({
owner: env.GITHUB_REPOSITORY_OWNER, owner: env.GITHUB_REPOSITORY_OWNER,
@ -287,12 +287,26 @@ export const getChangedFilesFromGithubAPI = async ({
per_page: 100 per_page: 100
}) })
)) { )) {
for (const paginatedItems of response.data) { if (response.status !== 200) {
for (const item of paginatedItems) { throw new Error(
const changeType: ChangeTypeEnum = `Failed to get changed files from GitHub API. Status: ${response.status}`
item.status === 'removed' )
? ChangeTypeEnum.Deleted }
: (item.status as ChangeTypeEnum) core.info(`Got ${response.data.length} changed files from GitHub API`)
for (const item of response.data) {
const changeType: ChangeTypeEnum =
item.status === 'removed'
? ChangeTypeEnum.Deleted
: (item.status as ChangeTypeEnum)
if (changeType === ChangeTypeEnum.Renamed) {
if (inputs.outputRenamedFilesAsDeletedAndAdded) {
changedFiles[ChangeTypeEnum.Deleted].push(item.filename)
changedFiles[ChangeTypeEnum.Added].push(item.filename)
} else {
changedFiles[ChangeTypeEnum.Renamed].push(item.filename)
}
} else {
changedFiles[changeType].push(item.filename) changedFiles[changeType].push(item.filename)
} }
} }

View File

@ -97,7 +97,7 @@ export const verifyMinimumGitVersion = async (): Promise<void> => {
const {exitCode, stdout, stderr} = await exec.getExecOutput( const {exitCode, stdout, stderr} = await exec.getExecOutput(
'git', 'git',
['--version'], ['--version'],
{silent: process.env.RUNNER_DEBUG !== '1'} {silent: !core.isDebug()}
) )
if (exitCode !== 0) { if (exitCode !== 0) {
@ -181,7 +181,7 @@ export const updateGitGlobalConfig = async ({
['config', '--global', name, value], ['config', '--global', name, value],
{ {
ignoreReturnCode: true, ignoreReturnCode: true,
silent: process.env.RUNNER_DEBUG !== '1' silent: !core.isDebug()
} }
) )
@ -197,7 +197,7 @@ export const isRepoShallow = async ({cwd}: {cwd: string}): Promise<boolean> => {
['rev-parse', '--is-shallow-repository'], ['rev-parse', '--is-shallow-repository'],
{ {
cwd, cwd,
silent: process.env.RUNNER_DEBUG !== '1' silent: !core.isDebug()
} }
) )
@ -215,7 +215,7 @@ export const submoduleExists = async ({
{ {
cwd, cwd,
ignoreReturnCode: true, ignoreReturnCode: true,
silent: process.env.RUNNER_DEBUG !== '1' silent: !core.isDebug()
} }
) )
@ -236,7 +236,7 @@ export const gitFetch = async ({
const {exitCode} = await exec.getExecOutput('git', ['fetch', '-q', ...args], { const {exitCode} = await exec.getExecOutput('git', ['fetch', '-q', ...args], {
cwd, cwd,
ignoreReturnCode: true, ignoreReturnCode: true,
silent: process.env.RUNNER_DEBUG !== '1' silent: !core.isDebug()
}) })
return exitCode return exitCode
@ -255,7 +255,7 @@ export const gitFetchSubmodules = async ({
{ {
cwd, cwd,
ignoreReturnCode: true, ignoreReturnCode: true,
silent: process.env.RUNNER_DEBUG !== '1' silent: !core.isDebug()
} }
) )
@ -280,7 +280,7 @@ export const getSubmodulePath = async ({
{ {
cwd, cwd,
ignoreReturnCode: true, ignoreReturnCode: true,
silent: process.env.RUNNER_DEBUG !== '1' silent: !core.isDebug()
} }
) )
@ -313,7 +313,7 @@ export const gitSubmoduleDiffSHA = async ({
['diff', parentSha1, parentSha2, '--', submodulePath], ['diff', parentSha1, parentSha2, '--', submodulePath],
{ {
cwd, cwd,
silent: process.env.RUNNER_DEBUG !== '1' silent: !core.isDebug()
} }
) )
@ -366,7 +366,7 @@ export const gitRenamedFiles = async ({
{ {
cwd, cwd,
ignoreReturnCode: true, ignoreReturnCode: true,
silent: process.env.RUNNER_DEBUG !== '1' silent: !core.isDebug()
} }
) )
@ -436,7 +436,7 @@ export const getAllChangedFiles = async ({
{ {
cwd, cwd,
ignoreReturnCode: true, ignoreReturnCode: true,
silent: process.env.RUNNER_DEBUG !== '1' silent: !core.isDebug()
} }
) )
const changedFiles: ChangedFiles = { const changedFiles: ChangedFiles = {
@ -537,7 +537,7 @@ export const gitLog = async ({
}): Promise<string> => { }): Promise<string> => {
const {stdout} = await exec.getExecOutput('git', ['log', ...args], { const {stdout} = await exec.getExecOutput('git', ['log', ...args], {
cwd, cwd,
silent: process.env.RUNNER_DEBUG !== '1' silent: !core.isDebug()
}) })
return stdout.trim() return stdout.trim()
@ -546,7 +546,7 @@ export const gitLog = async ({
export const getHeadSha = async ({cwd}: {cwd: string}): Promise<string> => { export const getHeadSha = async ({cwd}: {cwd: string}): Promise<string> => {
const {stdout} = await exec.getExecOutput('git', ['rev-parse', 'HEAD'], { const {stdout} = await exec.getExecOutput('git', ['rev-parse', 'HEAD'], {
cwd, cwd,
silent: process.env.RUNNER_DEBUG !== '1' silent: !core.isDebug()
}) })
return stdout.trim() return stdout.trim()
@ -564,7 +564,7 @@ export const getRemoteBranchHeadSha = async ({
['rev-parse', `origin/${branch}`], ['rev-parse', `origin/${branch}`],
{ {
cwd, cwd,
silent: process.env.RUNNER_DEBUG !== '1' silent: !core.isDebug()
} }
) )
@ -578,7 +578,7 @@ export const getParentSha = async ({cwd}: {cwd: string}): Promise<string> => {
{ {
cwd, cwd,
ignoreReturnCode: true, ignoreReturnCode: true,
silent: process.env.RUNNER_DEBUG !== '1' silent: !core.isDebug()
} }
) )
@ -604,7 +604,7 @@ export const verifyCommitSha = async ({
{ {
cwd, cwd,
ignoreReturnCode: true, ignoreReturnCode: true,
silent: process.env.RUNNER_DEBUG !== '1' silent: !core.isDebug()
} }
) )
@ -634,7 +634,7 @@ export const getPreviousGitTag = async ({
['tag', '--sort=-version:refname'], ['tag', '--sort=-version:refname'],
{ {
cwd, cwd,
silent: process.env.RUNNER_DEBUG !== '1' silent: !core.isDebug()
} }
) )
@ -652,7 +652,7 @@ export const getPreviousGitTag = async ({
['rev-parse', previousTag], ['rev-parse', previousTag],
{ {
cwd, cwd,
silent: process.env.RUNNER_DEBUG !== '1' silent: !core.isDebug()
} }
) )
@ -678,7 +678,7 @@ export const canDiffCommits = async ({
{ {
cwd, cwd,
ignoreReturnCode: true, ignoreReturnCode: true,
silent: process.env.RUNNER_DEBUG !== '1' silent: !core.isDebug()
} }
) )
@ -1047,7 +1047,7 @@ const getDeletedFileContents = async ({
['show', `${sha}:${filePath}`], ['show', `${sha}:${filePath}`],
{ {
cwd, cwd,
silent: process.env.RUNNER_DEBUG !== '1', silent: !core.isDebug(),
ignoreReturnCode: true ignoreReturnCode: true
} }
) )