Skip to content

Commit 07c64e5

Browse files
feat: add support for specifying the max number for retries to fetch missing history (#2052)
Co-authored-by: GitHub Action <[email protected]>
1 parent 5bd3332 commit 07c64e5

File tree

8 files changed

+36
-6
lines changed

8 files changed

+36
-6
lines changed

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,10 @@ inputs:
227227
description: "Exclude changes to submodules."
228228
required: false
229229
default: "false"
230+
fetch_missing_history_max_retries:
231+
description: "Maximum number of retries to fetch missing history."
232+
required: false
233+
default: "10"
230234

231235
outputs:
232236
added_files:

dist/index.js

Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/__tests__/__snapshots__/inputs.test.ts.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ exports[`getInputs should correctly parse boolean inputs 1`] = `
1515
"failOnInitialDiffError": "false",
1616
"failOnSubmoduleDiffError": "false",
1717
"fetchAdditionalSubmoduleHistory": "false",
18+
"fetchMissingHistoryMaxRetries": 10,
1819
"files": "",
1920
"filesFromSourceFile": "",
2021
"filesFromSourceFileSeparator": "",
@@ -308,6 +309,7 @@ exports[`getInputs should return default values when no inputs are provided 1`]
308309
"failOnInitialDiffError": false,
309310
"failOnSubmoduleDiffError": false,
310311
"fetchAdditionalSubmoduleHistory": false,
312+
"fetchMissingHistoryMaxRetries": 10,
311313
"files": "",
312314
"filesFromSourceFile": "",
313315
"filesFromSourceFileSeparator": "",

src/__tests__/utils.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,8 @@ describe('utils test', () => {
636636
failOnSubmoduleDiffError: false,
637637
negationPatternsFirst: false,
638638
useRestApi: false,
639-
excludeSubmodules: false
639+
excludeSubmodules: false,
640+
fetchMissingHistoryMaxRetries: 10
640641
}
641642

642643
const coreWarningSpy = jest.spyOn(core, 'warning')

src/commitSha.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,11 @@ export const getSHAForPullRequestEvent = async ({
528528
'Merge base is not in the local history, fetching remote target branch...'
529529
)
530530

531-
for (let i = 1; i <= 10; i++) {
531+
for (
532+
let i = 1;
533+
i <= (inputs.fetchMissingHistoryMaxRetries || 10);
534+
i++
535+
) {
532536
await gitFetch({
533537
cwd: workingDirectory,
534538
args: [

src/constant.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@ export const DEFAULT_VALUES_OF_UNSUPPORTED_API_INPUTS: Partial<Inputs> = {
2121
skipInitialFetch: false,
2222
fetchAdditionalSubmoduleHistory: false,
2323
dirNamesDeletedFilesIncludeOnlyDeletedDirs: false,
24-
excludeSubmodules: false
24+
excludeSubmodules: false,
25+
fetchMissingHistoryMaxRetries: 10
2526
}

src/inputs.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export type Inputs = {
5555
negationPatternsFirst: boolean
5656
useRestApi: boolean
5757
excludeSubmodules: boolean
58+
fetchMissingHistoryMaxRetries?: number
5859
}
5960

6061
export const getInputs = (): Inputs => {
@@ -245,6 +246,11 @@ export const getInputs = (): Inputs => {
245246
required: false
246247
})
247248

249+
const fetchMissingHistoryMaxRetries = core.getInput(
250+
'fetch_missing_history_max_retries',
251+
{required: false}
252+
)
253+
248254
const inputs: Inputs = {
249255
files,
250256
filesSeparator,
@@ -311,5 +317,12 @@ export const getInputs = (): Inputs => {
311317
inputs.dirNamesMaxDepth = parseInt(dirNamesMaxDepth, 10)
312318
}
313319

320+
if (fetchMissingHistoryMaxRetries) {
321+
inputs.fetchMissingHistoryMaxRetries = parseInt(
322+
fetchMissingHistoryMaxRetries,
323+
10
324+
)
325+
}
326+
314327
return inputs
315328
}

0 commit comments

Comments
 (0)