Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for specifying the max number for retries to fetch missing history #2052

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@ inputs:
description: "Exclude changes to submodules."
required: false
default: "false"
fetch_missing_history_max_retries:
description: "Maximum number of retries to fetch missing history."
required: false
default: "10"

outputs:
added_files:
Expand Down
9 changes: 7 additions & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/__tests__/__snapshots__/inputs.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ exports[`getInputs should correctly parse boolean inputs 1`] = `
"failOnInitialDiffError": "false",
"failOnSubmoduleDiffError": "false",
"fetchAdditionalSubmoduleHistory": "false",
"fetchMissingHistoryMaxRetries": 10,
"files": "",
"filesFromSourceFile": "",
"filesFromSourceFileSeparator": "",
Expand Down Expand Up @@ -308,6 +309,7 @@ exports[`getInputs should return default values when no inputs are provided 1`]
"failOnInitialDiffError": false,
"failOnSubmoduleDiffError": false,
"fetchAdditionalSubmoduleHistory": false,
"fetchMissingHistoryMaxRetries": 10,
"files": "",
"filesFromSourceFile": "",
"filesFromSourceFileSeparator": "",
Expand Down
3 changes: 2 additions & 1 deletion src/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,8 @@ describe('utils test', () => {
failOnSubmoduleDiffError: false,
negationPatternsFirst: false,
useRestApi: false,
excludeSubmodules: false
excludeSubmodules: false,
fetchMissingHistoryMaxRetries: 10
}

const coreWarningSpy = jest.spyOn(core, 'warning')
Expand Down
6 changes: 5 additions & 1 deletion src/commitSha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,11 @@ export const getSHAForPullRequestEvent = async ({
'Merge base is not in the local history, fetching remote target branch...'
)

for (let i = 1; i <= 10; i++) {
for (
let i = 1;
i <= (inputs.fetchMissingHistoryMaxRetries || 10);
i++
) {
await gitFetch({
cwd: workingDirectory,
args: [
Expand Down
3 changes: 2 additions & 1 deletion src/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ export const DEFAULT_VALUES_OF_UNSUPPORTED_API_INPUTS: Partial<Inputs> = {
skipInitialFetch: false,
fetchAdditionalSubmoduleHistory: false,
dirNamesDeletedFilesIncludeOnlyDeletedDirs: false,
excludeSubmodules: false
excludeSubmodules: false,
fetchMissingHistoryMaxRetries: 10
}
13 changes: 13 additions & 0 deletions src/inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export type Inputs = {
negationPatternsFirst: boolean
useRestApi: boolean
excludeSubmodules: boolean
fetchMissingHistoryMaxRetries?: number
}

export const getInputs = (): Inputs => {
Expand Down Expand Up @@ -245,6 +246,11 @@ export const getInputs = (): Inputs => {
required: false
})

const fetchMissingHistoryMaxRetries = core.getInput(
'fetch_missing_history_max_retries',
{required: false}
)

const inputs: Inputs = {
files,
filesSeparator,
Expand Down Expand Up @@ -311,5 +317,12 @@ export const getInputs = (): Inputs => {
inputs.dirNamesMaxDepth = parseInt(dirNamesMaxDepth, 10)
}

if (fetchMissingHistoryMaxRetries) {
inputs.fetchMissingHistoryMaxRetries = parseInt(
fetchMissingHistoryMaxRetries,
10
)
}

return inputs
}