Skip to content

Commit

Permalink
Updated silent setting.
Browse files Browse the repository at this point in the history
  • Loading branch information
jackton1 committed Jun 23, 2023
1 parent 71c896b commit d2a6112
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 26 deletions.
28 changes: 21 additions & 7 deletions src/changedFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ export const getChangedFilesFromGithubAPI = async ({

core.info('Getting changed files from GitHub API...')
for await (const response of octokit.paginate.iterator<
RestEndpointMethodTypes['pulls']['listFiles']['response']['data']
RestEndpointMethodTypes['pulls']['listFiles']['response']['data'][0]
>(
octokit.pulls.listFiles.endpoint.merge({
owner: env.GITHUB_REPOSITORY_OWNER,
Expand All @@ -287,12 +287,26 @@ export const getChangedFilesFromGithubAPI = async ({
per_page: 100
})
)) {
for (const paginatedItems of response.data) {
for (const item of paginatedItems) {
const changeType: ChangeTypeEnum =
item.status === 'removed'
? ChangeTypeEnum.Deleted
: (item.status as ChangeTypeEnum)
if (response.status !== 200) {
throw new Error(
`Failed to get changed files from GitHub API. Status: ${response.status}`
)
}
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)
}
}
Expand Down
38 changes: 19 additions & 19 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export const verifyMinimumGitVersion = async (): Promise<void> => {
const {exitCode, stdout, stderr} = await exec.getExecOutput(
'git',
['--version'],
{silent: process.env.RUNNER_DEBUG !== '1'}
{silent: !core.isDebug()}
)

if (exitCode !== 0) {
Expand Down Expand Up @@ -181,7 +181,7 @@ export const updateGitGlobalConfig = async ({
['config', '--global', name, value],
{
ignoreReturnCode: true,
silent: process.env.RUNNER_DEBUG !== '1'
silent: !core.isDebug()
}
)

Expand All @@ -197,7 +197,7 @@ export const isRepoShallow = async ({cwd}: {cwd: string}): Promise<boolean> => {
['rev-parse', '--is-shallow-repository'],
{
cwd,
silent: process.env.RUNNER_DEBUG !== '1'
silent: !core.isDebug()
}
)

Expand All @@ -215,7 +215,7 @@ export const submoduleExists = async ({
{
cwd,
ignoreReturnCode: true,
silent: process.env.RUNNER_DEBUG !== '1'
silent: !core.isDebug()
}
)

Expand All @@ -236,7 +236,7 @@ export const gitFetch = async ({
const {exitCode} = await exec.getExecOutput('git', ['fetch', '-q', ...args], {
cwd,
ignoreReturnCode: true,
silent: process.env.RUNNER_DEBUG !== '1'
silent: !core.isDebug()
})

return exitCode
Expand All @@ -255,7 +255,7 @@ export const gitFetchSubmodules = async ({
{
cwd,
ignoreReturnCode: true,
silent: process.env.RUNNER_DEBUG !== '1'
silent: !core.isDebug()
}
)

Expand All @@ -280,7 +280,7 @@ export const getSubmodulePath = async ({
{
cwd,
ignoreReturnCode: true,
silent: process.env.RUNNER_DEBUG !== '1'
silent: !core.isDebug()
}
)

Expand Down Expand Up @@ -313,7 +313,7 @@ export const gitSubmoduleDiffSHA = async ({
['diff', parentSha1, parentSha2, '--', submodulePath],
{
cwd,
silent: process.env.RUNNER_DEBUG !== '1'
silent: !core.isDebug()
}
)

Expand Down Expand Up @@ -366,7 +366,7 @@ export const gitRenamedFiles = async ({
{
cwd,
ignoreReturnCode: true,
silent: process.env.RUNNER_DEBUG !== '1'
silent: !core.isDebug()
}
)

Expand Down Expand Up @@ -436,7 +436,7 @@ export const getAllChangedFiles = async ({
{
cwd,
ignoreReturnCode: true,
silent: process.env.RUNNER_DEBUG !== '1'
silent: !core.isDebug()
}
)
const changedFiles: ChangedFiles = {
Expand Down Expand Up @@ -537,7 +537,7 @@ export const gitLog = async ({
}): Promise<string> => {
const {stdout} = await exec.getExecOutput('git', ['log', ...args], {
cwd,
silent: process.env.RUNNER_DEBUG !== '1'
silent: !core.isDebug()
})

return stdout.trim()
Expand All @@ -546,7 +546,7 @@ export const gitLog = async ({
export const getHeadSha = async ({cwd}: {cwd: string}): Promise<string> => {
const {stdout} = await exec.getExecOutput('git', ['rev-parse', 'HEAD'], {
cwd,
silent: process.env.RUNNER_DEBUG !== '1'
silent: !core.isDebug()
})

return stdout.trim()
Expand All @@ -564,7 +564,7 @@ export const getRemoteBranchHeadSha = async ({
['rev-parse', `origin/${branch}`],
{
cwd,
silent: process.env.RUNNER_DEBUG !== '1'
silent: !core.isDebug()
}
)

Expand All @@ -578,7 +578,7 @@ export const getParentSha = async ({cwd}: {cwd: string}): Promise<string> => {
{
cwd,
ignoreReturnCode: true,
silent: process.env.RUNNER_DEBUG !== '1'
silent: !core.isDebug()
}
)

Expand All @@ -604,7 +604,7 @@ export const verifyCommitSha = async ({
{
cwd,
ignoreReturnCode: true,
silent: process.env.RUNNER_DEBUG !== '1'
silent: !core.isDebug()
}
)

Expand Down Expand Up @@ -634,7 +634,7 @@ export const getPreviousGitTag = async ({
['tag', '--sort=-version:refname'],
{
cwd,
silent: process.env.RUNNER_DEBUG !== '1'
silent: !core.isDebug()
}
)

Expand All @@ -652,7 +652,7 @@ export const getPreviousGitTag = async ({
['rev-parse', previousTag],
{
cwd,
silent: process.env.RUNNER_DEBUG !== '1'
silent: !core.isDebug()
}
)

Expand All @@ -678,7 +678,7 @@ export const canDiffCommits = async ({
{
cwd,
ignoreReturnCode: true,
silent: process.env.RUNNER_DEBUG !== '1'
silent: !core.isDebug()
}
)

Expand Down Expand Up @@ -1047,7 +1047,7 @@ const getDeletedFileContents = async ({
['show', `${sha}:${filePath}`],
{
cwd,
silent: process.env.RUNNER_DEBUG !== '1',
silent: !core.isDebug(),
ignoreReturnCode: true
}
)
Expand Down

0 comments on commit d2a6112

Please sign in to comment.