mirror of
https://github.com/tj-actions/changed-files
synced 2024-12-17 03:47:20 +00:00
feat: add support for fetching additional history for submodules (#1476)
Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
parent
785218258b
commit
569361586a
8 changed files with 131 additions and 86 deletions
1
.github/workflows/test.yml
vendored
1
.github/workflows/test.yml
vendored
|
@ -82,7 +82,6 @@ jobs:
|
|||
- name: Verify Changed files
|
||||
uses: tj-actions/verify-changed-files@v16
|
||||
id: changed_files
|
||||
if: github.event_name == 'pull_request'
|
||||
with:
|
||||
files: |
|
||||
src
|
||||
|
|
|
@ -136,6 +136,10 @@ inputs:
|
|||
description: "Skip the initial fetch to improve performance for shallow repositories. **NOTE**: This could lead to errors with missing history and the intended use is limited to when you've fetched the history necessary to perform the diff."
|
||||
required: false
|
||||
default: "false"
|
||||
fetch_additional_submodule_history:
|
||||
description: "Fetch additional history for submodules."
|
||||
required: false
|
||||
default: "false"
|
||||
since_last_remote_commit:
|
||||
description: "Use the last commit on the remote branch as the `base_sha`. Defaults to the last non-merge commit on the target branch for pull request events and the previous remote commit of the current branch for push events."
|
||||
required: false
|
||||
|
|
BIN
dist/index.js
generated
vendored
BIN
dist/index.js
generated
vendored
Binary file not shown.
BIN
dist/index.js.map
generated
vendored
BIN
dist/index.js.map
generated
vendored
Binary file not shown.
|
@ -65,6 +65,9 @@ export const getRenamedFiles = async ({
|
|||
diff
|
||||
}))
|
||||
) {
|
||||
core.warning(
|
||||
`Set 'fetch_additional_submodule_history: true' to fetch additional submodule history for: ${submodulePath}, Note you can control the fetch depth using 'fetch_depth' input`
|
||||
)
|
||||
diff = '..'
|
||||
}
|
||||
|
||||
|
@ -157,6 +160,9 @@ export const getAllDiffFiles = async ({
|
|||
diff
|
||||
}))
|
||||
) {
|
||||
core.warning(
|
||||
`Set 'fetch_additional_submodule_history: true' to fetch additional submodule history for: ${submodulePath}, Note you can control the fetch depth using 'fetch_depth' input`
|
||||
)
|
||||
diff = '..'
|
||||
}
|
||||
|
||||
|
|
|
@ -93,7 +93,8 @@ export const getSHAForNonPullRequestEvent = async (
|
|||
const currentBranch = targetBranch
|
||||
let initialCommit = false
|
||||
|
||||
if (isShallow && !inputs.skipInitialFetch) {
|
||||
if (!inputs.skipInitialFetch) {
|
||||
if (isShallow) {
|
||||
core.info('Repository is shallow, fetching more history...')
|
||||
|
||||
if (isTag) {
|
||||
|
@ -144,6 +145,19 @@ export const getSHAForNonPullRequestEvent = async (
|
|||
]
|
||||
})
|
||||
}
|
||||
} else {
|
||||
if (hasSubmodule && inputs.fetchSubmoduleHistory) {
|
||||
await gitFetchSubmodules({
|
||||
cwd: workingDirectory,
|
||||
args: [
|
||||
...gitFetchExtraArgs,
|
||||
'-u',
|
||||
'--progress',
|
||||
`--deepen=${inputs.fetchDepth}`
|
||||
]
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const currentSha = await getCurrentSHA({inputs, workingDirectory})
|
||||
|
@ -288,9 +302,9 @@ export const getSHAForPullRequestEvent = async (
|
|||
targetBranch = currentBranch
|
||||
}
|
||||
|
||||
if (isShallow && !inputs.skipInitialFetch) {
|
||||
if (!inputs.skipInitialFetch) {
|
||||
core.info('Repository is shallow, fetching more history...')
|
||||
|
||||
if (isShallow) {
|
||||
let prFetchExitCode = await gitFetch({
|
||||
cwd: workingDirectory,
|
||||
args: [
|
||||
|
@ -348,6 +362,19 @@ export const getSHAForPullRequestEvent = async (
|
|||
})
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (hasSubmodule && inputs.fetchSubmoduleHistory) {
|
||||
await gitFetchSubmodules({
|
||||
cwd: workingDirectory,
|
||||
args: [
|
||||
...gitFetchExtraArgs,
|
||||
'-u',
|
||||
'--progress',
|
||||
`--deepen=${inputs.fetchDepth}`
|
||||
]
|
||||
})
|
||||
}
|
||||
}
|
||||
core.info('Completed fetching more history.')
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ export type Inputs = {
|
|||
json: boolean
|
||||
escapeJson: boolean
|
||||
fetchDepth?: number
|
||||
fetchSubmoduleHistory?: boolean
|
||||
sinceLastRemoteCommit: boolean
|
||||
writeOutputFiles: boolean
|
||||
outputDir: string
|
||||
|
@ -189,6 +190,12 @@ export const getInputs = (): Inputs => {
|
|||
const skipInitialFetch = core.getBooleanInput('skip_initial_fetch', {
|
||||
required: false
|
||||
})
|
||||
const fetchSubmoduleHistory = core.getBooleanInput(
|
||||
'fetch_additional_submodule_history',
|
||||
{
|
||||
required: false
|
||||
}
|
||||
)
|
||||
|
||||
const inputs: Inputs = {
|
||||
files,
|
||||
|
@ -225,6 +232,7 @@ export const getInputs = (): Inputs => {
|
|||
oldNewSeparator,
|
||||
oldNewFilesSeparator,
|
||||
skipInitialFetch,
|
||||
fetchSubmoduleHistory,
|
||||
// End Not Supported via REST API
|
||||
dirNames,
|
||||
dirNamesExcludeCurrentDir,
|
||||
|
|
|
@ -317,7 +317,8 @@ export async function run(): Promise<void> {
|
|||
'recoverFiles',
|
||||
'recoverFilesIgnore',
|
||||
'includeAllOldNewRenamedFiles',
|
||||
'skipInitialFetch'
|
||||
'skipInitialFetch',
|
||||
'fetchSubmoduleHistory'
|
||||
]
|
||||
|
||||
for (const input of unsupportedInputs) {
|
||||
|
|
Loading…
Reference in a new issue