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
1
.github/workflows/test.yml
vendored
1
.github/workflows/test.yml
vendored
@ -82,7 +82,6 @@ jobs:
|
|||||||
- name: Verify Changed files
|
- name: Verify Changed files
|
||||||
uses: tj-actions/verify-changed-files@v16
|
uses: tj-actions/verify-changed-files@v16
|
||||||
id: changed_files
|
id: changed_files
|
||||||
if: github.event_name == 'pull_request'
|
|
||||||
with:
|
with:
|
||||||
files: |
|
files: |
|
||||||
src
|
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."
|
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
|
required: false
|
||||||
default: "false"
|
default: "false"
|
||||||
|
fetch_additional_submodule_history:
|
||||||
|
description: "Fetch additional history for submodules."
|
||||||
|
required: false
|
||||||
|
default: "false"
|
||||||
since_last_remote_commit:
|
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."
|
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
|
required: false
|
||||||
|
185
dist/index.js
generated
vendored
185
dist/index.js
generated
vendored
@ -82,6 +82,7 @@ const getRenamedFiles = ({ inputs, workingDirectory, hasSubmodule, diffResult, s
|
|||||||
sha2: submoduleShaResult.currentSha,
|
sha2: submoduleShaResult.currentSha,
|
||||||
diff
|
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 = '..';
|
diff = '..';
|
||||||
}
|
}
|
||||||
const submoduleRenamedFiles = yield (0, utils_1.gitRenamedFiles)({
|
const submoduleRenamedFiles = yield (0, utils_1.gitRenamedFiles)({
|
||||||
@ -146,6 +147,7 @@ const getAllDiffFiles = ({ workingDirectory, hasSubmodule, diffResult, submodule
|
|||||||
sha2: submoduleShaResult.currentSha,
|
sha2: submoduleShaResult.currentSha,
|
||||||
diff
|
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 = '..';
|
diff = '..';
|
||||||
}
|
}
|
||||||
const submoduleFiles = yield (0, utils_1.getAllChangedFiles)({
|
const submoduleFiles = yield (0, utils_1.getAllChangedFiles)({
|
||||||
@ -753,51 +755,66 @@ const getSHAForNonPullRequestEvent = (inputs, env, workingDirectory, isShallow,
|
|||||||
let targetBranch = env.GITHUB_REF_NAME;
|
let targetBranch = env.GITHUB_REF_NAME;
|
||||||
const currentBranch = targetBranch;
|
const currentBranch = targetBranch;
|
||||||
let initialCommit = false;
|
let initialCommit = false;
|
||||||
if (isShallow && !inputs.skipInitialFetch) {
|
if (!inputs.skipInitialFetch) {
|
||||||
core.info('Repository is shallow, fetching more history...');
|
if (isShallow) {
|
||||||
if (isTag) {
|
core.info('Repository is shallow, fetching more history...');
|
||||||
let sourceBranch = '';
|
if (isTag) {
|
||||||
if (github.context.payload.base_ref) {
|
let sourceBranch = '';
|
||||||
sourceBranch = github.context.payload.base_ref.replace('refs/heads/', '');
|
if (github.context.payload.base_ref) {
|
||||||
|
sourceBranch = github.context.payload.base_ref.replace('refs/heads/', '');
|
||||||
|
}
|
||||||
|
else if ((_h = github.context.payload.release) === null || _h === void 0 ? void 0 : _h.target_commitish) {
|
||||||
|
sourceBranch = (_j = github.context.payload.release) === null || _j === void 0 ? void 0 : _j.target_commitish;
|
||||||
|
}
|
||||||
|
yield (0, utils_1.gitFetch)({
|
||||||
|
cwd: workingDirectory,
|
||||||
|
args: [
|
||||||
|
...gitFetchExtraArgs,
|
||||||
|
'-u',
|
||||||
|
'--progress',
|
||||||
|
`--deepen=${inputs.fetchDepth}`,
|
||||||
|
'origin',
|
||||||
|
`+refs/heads/${sourceBranch}:refs/remotes/origin/${sourceBranch}`
|
||||||
|
]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else if ((_h = github.context.payload.release) === null || _h === void 0 ? void 0 : _h.target_commitish) {
|
else {
|
||||||
sourceBranch = (_j = github.context.payload.release) === null || _j === void 0 ? void 0 : _j.target_commitish;
|
yield (0, utils_1.gitFetch)({
|
||||||
|
cwd: workingDirectory,
|
||||||
|
args: [
|
||||||
|
...gitFetchExtraArgs,
|
||||||
|
'-u',
|
||||||
|
'--progress',
|
||||||
|
`--deepen=${inputs.fetchDepth}`,
|
||||||
|
'origin',
|
||||||
|
`+refs/heads/${targetBranch}:refs/remotes/origin/${targetBranch}`
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (hasSubmodule) {
|
||||||
|
yield (0, utils_1.gitFetchSubmodules)({
|
||||||
|
cwd: workingDirectory,
|
||||||
|
args: [
|
||||||
|
...gitFetchExtraArgs,
|
||||||
|
'-u',
|
||||||
|
'--progress',
|
||||||
|
`--deepen=${inputs.fetchDepth}`
|
||||||
|
]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
yield (0, utils_1.gitFetch)({
|
|
||||||
cwd: workingDirectory,
|
|
||||||
args: [
|
|
||||||
...gitFetchExtraArgs,
|
|
||||||
'-u',
|
|
||||||
'--progress',
|
|
||||||
`--deepen=${inputs.fetchDepth}`,
|
|
||||||
'origin',
|
|
||||||
`+refs/heads/${sourceBranch}:refs/remotes/origin/${sourceBranch}`
|
|
||||||
]
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
yield (0, utils_1.gitFetch)({
|
if (hasSubmodule && inputs.fetchSubmoduleHistory) {
|
||||||
cwd: workingDirectory,
|
yield (0, utils_1.gitFetchSubmodules)({
|
||||||
args: [
|
cwd: workingDirectory,
|
||||||
...gitFetchExtraArgs,
|
args: [
|
||||||
'-u',
|
...gitFetchExtraArgs,
|
||||||
'--progress',
|
'-u',
|
||||||
`--deepen=${inputs.fetchDepth}`,
|
'--progress',
|
||||||
'origin',
|
`--deepen=${inputs.fetchDepth}`
|
||||||
`+refs/heads/${targetBranch}:refs/remotes/origin/${targetBranch}`
|
]
|
||||||
]
|
});
|
||||||
});
|
}
|
||||||
}
|
|
||||||
if (hasSubmodule) {
|
|
||||||
yield (0, utils_1.gitFetchSubmodules)({
|
|
||||||
cwd: workingDirectory,
|
|
||||||
args: [
|
|
||||||
...gitFetchExtraArgs,
|
|
||||||
'-u',
|
|
||||||
'--progress',
|
|
||||||
`--deepen=${inputs.fetchDepth}`
|
|
||||||
]
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const currentSha = yield getCurrentSHA({ inputs, workingDirectory });
|
const currentSha = yield getCurrentSHA({ inputs, workingDirectory });
|
||||||
@ -910,48 +927,63 @@ const getSHAForPullRequestEvent = (inputs, env, workingDirectory, isShallow, has
|
|||||||
if (inputs.sinceLastRemoteCommit) {
|
if (inputs.sinceLastRemoteCommit) {
|
||||||
targetBranch = currentBranch;
|
targetBranch = currentBranch;
|
||||||
}
|
}
|
||||||
if (isShallow && !inputs.skipInitialFetch) {
|
if (!inputs.skipInitialFetch) {
|
||||||
core.info('Repository is shallow, fetching more history...');
|
core.info('Repository is shallow, fetching more history...');
|
||||||
let prFetchExitCode = yield (0, utils_1.gitFetch)({
|
if (isShallow) {
|
||||||
cwd: workingDirectory,
|
let prFetchExitCode = yield (0, utils_1.gitFetch)({
|
||||||
args: [
|
|
||||||
...gitFetchExtraArgs,
|
|
||||||
'-u',
|
|
||||||
'--progress',
|
|
||||||
'origin',
|
|
||||||
`pull/${(_q = github.context.payload.pull_request) === null || _q === void 0 ? void 0 : _q.number}/head:${currentBranch}`
|
|
||||||
]
|
|
||||||
});
|
|
||||||
if (prFetchExitCode !== 0) {
|
|
||||||
prFetchExitCode = yield (0, utils_1.gitFetch)({
|
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
args: [
|
args: [
|
||||||
...gitFetchExtraArgs,
|
...gitFetchExtraArgs,
|
||||||
'-u',
|
'-u',
|
||||||
'--progress',
|
'--progress',
|
||||||
`--deepen=${inputs.fetchDepth}`,
|
|
||||||
'origin',
|
'origin',
|
||||||
`+refs/heads/${currentBranch}*:refs/remotes/origin/${currentBranch}*`
|
`pull/${(_q = github.context.payload.pull_request) === null || _q === void 0 ? void 0 : _q.number}/head:${currentBranch}`
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
if (prFetchExitCode !== 0) {
|
||||||
|
prFetchExitCode = yield (0, utils_1.gitFetch)({
|
||||||
|
cwd: workingDirectory,
|
||||||
|
args: [
|
||||||
|
...gitFetchExtraArgs,
|
||||||
|
'-u',
|
||||||
|
'--progress',
|
||||||
|
`--deepen=${inputs.fetchDepth}`,
|
||||||
|
'origin',
|
||||||
|
`+refs/heads/${currentBranch}*:refs/remotes/origin/${currentBranch}*`
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (prFetchExitCode !== 0) {
|
||||||
|
throw new Error('Failed to fetch pull request branch. Please ensure "persist-credentials" is set to "true" when checking out the repository. See: https://github.com/actions/checkout#usage');
|
||||||
|
}
|
||||||
|
if (!inputs.sinceLastRemoteCommit) {
|
||||||
|
core.debug('Fetching target branch...');
|
||||||
|
yield (0, utils_1.gitFetch)({
|
||||||
|
cwd: workingDirectory,
|
||||||
|
args: [
|
||||||
|
...gitFetchExtraArgs,
|
||||||
|
'-u',
|
||||||
|
'--progress',
|
||||||
|
`--deepen=${inputs.fetchDepth}`,
|
||||||
|
'origin',
|
||||||
|
`+refs/heads/${targetBranch}:refs/remotes/origin/${targetBranch}`
|
||||||
|
]
|
||||||
|
});
|
||||||
|
if (hasSubmodule) {
|
||||||
|
yield (0, utils_1.gitFetchSubmodules)({
|
||||||
|
cwd: workingDirectory,
|
||||||
|
args: [
|
||||||
|
...gitFetchExtraArgs,
|
||||||
|
'-u',
|
||||||
|
'--progress',
|
||||||
|
`--deepen=${inputs.fetchDepth}`
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (prFetchExitCode !== 0) {
|
else {
|
||||||
throw new Error('Failed to fetch pull request branch. Please ensure "persist-credentials" is set to "true" when checking out the repository. See: https://github.com/actions/checkout#usage');
|
if (hasSubmodule && inputs.fetchSubmoduleHistory) {
|
||||||
}
|
|
||||||
if (!inputs.sinceLastRemoteCommit) {
|
|
||||||
core.debug('Fetching target branch...');
|
|
||||||
yield (0, utils_1.gitFetch)({
|
|
||||||
cwd: workingDirectory,
|
|
||||||
args: [
|
|
||||||
...gitFetchExtraArgs,
|
|
||||||
'-u',
|
|
||||||
'--progress',
|
|
||||||
`--deepen=${inputs.fetchDepth}`,
|
|
||||||
'origin',
|
|
||||||
`+refs/heads/${targetBranch}:refs/remotes/origin/${targetBranch}`
|
|
||||||
]
|
|
||||||
});
|
|
||||||
if (hasSubmodule) {
|
|
||||||
yield (0, utils_1.gitFetchSubmodules)({
|
yield (0, utils_1.gitFetchSubmodules)({
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
args: [
|
args: [
|
||||||
@ -1288,6 +1320,9 @@ const getInputs = () => {
|
|||||||
const skipInitialFetch = core.getBooleanInput('skip_initial_fetch', {
|
const skipInitialFetch = core.getBooleanInput('skip_initial_fetch', {
|
||||||
required: false
|
required: false
|
||||||
});
|
});
|
||||||
|
const fetchSubmoduleHistory = core.getBooleanInput('fetch_additional_submodule_history', {
|
||||||
|
required: false
|
||||||
|
});
|
||||||
const inputs = {
|
const inputs = {
|
||||||
files,
|
files,
|
||||||
filesSeparator,
|
filesSeparator,
|
||||||
@ -1323,6 +1358,7 @@ const getInputs = () => {
|
|||||||
oldNewSeparator,
|
oldNewSeparator,
|
||||||
oldNewFilesSeparator,
|
oldNewFilesSeparator,
|
||||||
skipInitialFetch,
|
skipInitialFetch,
|
||||||
|
fetchSubmoduleHistory,
|
||||||
// End Not Supported via REST API
|
// End Not Supported via REST API
|
||||||
dirNames,
|
dirNames,
|
||||||
dirNamesExcludeCurrentDir,
|
dirNamesExcludeCurrentDir,
|
||||||
@ -1596,7 +1632,8 @@ function run() {
|
|||||||
'recoverFiles',
|
'recoverFiles',
|
||||||
'recoverFilesIgnore',
|
'recoverFilesIgnore',
|
||||||
'includeAllOldNewRenamedFiles',
|
'includeAllOldNewRenamedFiles',
|
||||||
'skipInitialFetch'
|
'skipInitialFetch',
|
||||||
|
'fetchSubmoduleHistory'
|
||||||
];
|
];
|
||||||
for (const input of unsupportedInputs) {
|
for (const input of unsupportedInputs) {
|
||||||
if (inputs[input]) {
|
if (inputs[input]) {
|
||||||
|
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
@ -65,6 +65,9 @@ export const getRenamedFiles = async ({
|
|||||||
diff
|
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 = '..'
|
diff = '..'
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,6 +160,9 @@ export const getAllDiffFiles = async ({
|
|||||||
diff
|
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 = '..'
|
diff = '..'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
195
src/commitSha.ts
195
src/commitSha.ts
@ -93,56 +93,70 @@ export const getSHAForNonPullRequestEvent = async (
|
|||||||
const currentBranch = targetBranch
|
const currentBranch = targetBranch
|
||||||
let initialCommit = false
|
let initialCommit = false
|
||||||
|
|
||||||
if (isShallow && !inputs.skipInitialFetch) {
|
if (!inputs.skipInitialFetch) {
|
||||||
core.info('Repository is shallow, fetching more history...')
|
if (isShallow) {
|
||||||
|
core.info('Repository is shallow, fetching more history...')
|
||||||
|
|
||||||
if (isTag) {
|
if (isTag) {
|
||||||
let sourceBranch = ''
|
let sourceBranch = ''
|
||||||
|
|
||||||
if (github.context.payload.base_ref) {
|
if (github.context.payload.base_ref) {
|
||||||
sourceBranch = github.context.payload.base_ref.replace(
|
sourceBranch = github.context.payload.base_ref.replace(
|
||||||
'refs/heads/',
|
'refs/heads/',
|
||||||
''
|
''
|
||||||
)
|
)
|
||||||
} else if (github.context.payload.release?.target_commitish) {
|
} else if (github.context.payload.release?.target_commitish) {
|
||||||
sourceBranch = github.context.payload.release?.target_commitish
|
sourceBranch = github.context.payload.release?.target_commitish
|
||||||
|
}
|
||||||
|
|
||||||
|
await gitFetch({
|
||||||
|
cwd: workingDirectory,
|
||||||
|
args: [
|
||||||
|
...gitFetchExtraArgs,
|
||||||
|
'-u',
|
||||||
|
'--progress',
|
||||||
|
`--deepen=${inputs.fetchDepth}`,
|
||||||
|
'origin',
|
||||||
|
`+refs/heads/${sourceBranch}:refs/remotes/origin/${sourceBranch}`
|
||||||
|
]
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
await gitFetch({
|
||||||
|
cwd: workingDirectory,
|
||||||
|
args: [
|
||||||
|
...gitFetchExtraArgs,
|
||||||
|
'-u',
|
||||||
|
'--progress',
|
||||||
|
`--deepen=${inputs.fetchDepth}`,
|
||||||
|
'origin',
|
||||||
|
`+refs/heads/${targetBranch}:refs/remotes/origin/${targetBranch}`
|
||||||
|
]
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
await gitFetch({
|
if (hasSubmodule) {
|
||||||
cwd: workingDirectory,
|
await gitFetchSubmodules({
|
||||||
args: [
|
cwd: workingDirectory,
|
||||||
...gitFetchExtraArgs,
|
args: [
|
||||||
'-u',
|
...gitFetchExtraArgs,
|
||||||
'--progress',
|
'-u',
|
||||||
`--deepen=${inputs.fetchDepth}`,
|
'--progress',
|
||||||
'origin',
|
`--deepen=${inputs.fetchDepth}`
|
||||||
`+refs/heads/${sourceBranch}:refs/remotes/origin/${sourceBranch}`
|
]
|
||||||
]
|
})
|
||||||
})
|
}
|
||||||
} else {
|
} else {
|
||||||
await gitFetch({
|
if (hasSubmodule && inputs.fetchSubmoduleHistory) {
|
||||||
cwd: workingDirectory,
|
await gitFetchSubmodules({
|
||||||
args: [
|
cwd: workingDirectory,
|
||||||
...gitFetchExtraArgs,
|
args: [
|
||||||
'-u',
|
...gitFetchExtraArgs,
|
||||||
'--progress',
|
'-u',
|
||||||
`--deepen=${inputs.fetchDepth}`,
|
'--progress',
|
||||||
'origin',
|
`--deepen=${inputs.fetchDepth}`
|
||||||
`+refs/heads/${targetBranch}:refs/remotes/origin/${targetBranch}`
|
]
|
||||||
]
|
})
|
||||||
})
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (hasSubmodule) {
|
|
||||||
await gitFetchSubmodules({
|
|
||||||
cwd: workingDirectory,
|
|
||||||
args: [
|
|
||||||
...gitFetchExtraArgs,
|
|
||||||
'-u',
|
|
||||||
'--progress',
|
|
||||||
`--deepen=${inputs.fetchDepth}`
|
|
||||||
]
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,55 +302,68 @@ export const getSHAForPullRequestEvent = async (
|
|||||||
targetBranch = currentBranch
|
targetBranch = currentBranch
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isShallow && !inputs.skipInitialFetch) {
|
if (!inputs.skipInitialFetch) {
|
||||||
core.info('Repository is shallow, fetching more history...')
|
core.info('Repository is shallow, fetching more history...')
|
||||||
|
if (isShallow) {
|
||||||
let prFetchExitCode = await gitFetch({
|
let prFetchExitCode = await gitFetch({
|
||||||
cwd: workingDirectory,
|
|
||||||
args: [
|
|
||||||
...gitFetchExtraArgs,
|
|
||||||
'-u',
|
|
||||||
'--progress',
|
|
||||||
'origin',
|
|
||||||
`pull/${github.context.payload.pull_request?.number}/head:${currentBranch}`
|
|
||||||
]
|
|
||||||
})
|
|
||||||
|
|
||||||
if (prFetchExitCode !== 0) {
|
|
||||||
prFetchExitCode = await gitFetch({
|
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
args: [
|
args: [
|
||||||
...gitFetchExtraArgs,
|
...gitFetchExtraArgs,
|
||||||
'-u',
|
'-u',
|
||||||
'--progress',
|
'--progress',
|
||||||
`--deepen=${inputs.fetchDepth}`,
|
|
||||||
'origin',
|
'origin',
|
||||||
`+refs/heads/${currentBranch}*:refs/remotes/origin/${currentBranch}*`
|
`pull/${github.context.payload.pull_request?.number}/head:${currentBranch}`
|
||||||
]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if (prFetchExitCode !== 0) {
|
|
||||||
throw new Error(
|
|
||||||
'Failed to fetch pull request branch. Please ensure "persist-credentials" is set to "true" when checking out the repository. See: https://github.com/actions/checkout#usage'
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!inputs.sinceLastRemoteCommit) {
|
|
||||||
core.debug('Fetching target branch...')
|
|
||||||
await gitFetch({
|
|
||||||
cwd: workingDirectory,
|
|
||||||
args: [
|
|
||||||
...gitFetchExtraArgs,
|
|
||||||
'-u',
|
|
||||||
'--progress',
|
|
||||||
`--deepen=${inputs.fetchDepth}`,
|
|
||||||
'origin',
|
|
||||||
`+refs/heads/${targetBranch}:refs/remotes/origin/${targetBranch}`
|
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
if (hasSubmodule) {
|
if (prFetchExitCode !== 0) {
|
||||||
|
prFetchExitCode = await gitFetch({
|
||||||
|
cwd: workingDirectory,
|
||||||
|
args: [
|
||||||
|
...gitFetchExtraArgs,
|
||||||
|
'-u',
|
||||||
|
'--progress',
|
||||||
|
`--deepen=${inputs.fetchDepth}`,
|
||||||
|
'origin',
|
||||||
|
`+refs/heads/${currentBranch}*:refs/remotes/origin/${currentBranch}*`
|
||||||
|
]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prFetchExitCode !== 0) {
|
||||||
|
throw new Error(
|
||||||
|
'Failed to fetch pull request branch. Please ensure "persist-credentials" is set to "true" when checking out the repository. See: https://github.com/actions/checkout#usage'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!inputs.sinceLastRemoteCommit) {
|
||||||
|
core.debug('Fetching target branch...')
|
||||||
|
await gitFetch({
|
||||||
|
cwd: workingDirectory,
|
||||||
|
args: [
|
||||||
|
...gitFetchExtraArgs,
|
||||||
|
'-u',
|
||||||
|
'--progress',
|
||||||
|
`--deepen=${inputs.fetchDepth}`,
|
||||||
|
'origin',
|
||||||
|
`+refs/heads/${targetBranch}:refs/remotes/origin/${targetBranch}`
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
if (hasSubmodule) {
|
||||||
|
await gitFetchSubmodules({
|
||||||
|
cwd: workingDirectory,
|
||||||
|
args: [
|
||||||
|
...gitFetchExtraArgs,
|
||||||
|
'-u',
|
||||||
|
'--progress',
|
||||||
|
`--deepen=${inputs.fetchDepth}`
|
||||||
|
]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (hasSubmodule && inputs.fetchSubmoduleHistory) {
|
||||||
await gitFetchSubmodules({
|
await gitFetchSubmodules({
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
args: [
|
args: [
|
||||||
|
@ -34,6 +34,7 @@ export type Inputs = {
|
|||||||
json: boolean
|
json: boolean
|
||||||
escapeJson: boolean
|
escapeJson: boolean
|
||||||
fetchDepth?: number
|
fetchDepth?: number
|
||||||
|
fetchSubmoduleHistory?: boolean
|
||||||
sinceLastRemoteCommit: boolean
|
sinceLastRemoteCommit: boolean
|
||||||
writeOutputFiles: boolean
|
writeOutputFiles: boolean
|
||||||
outputDir: string
|
outputDir: string
|
||||||
@ -189,6 +190,12 @@ export const getInputs = (): Inputs => {
|
|||||||
const skipInitialFetch = core.getBooleanInput('skip_initial_fetch', {
|
const skipInitialFetch = core.getBooleanInput('skip_initial_fetch', {
|
||||||
required: false
|
required: false
|
||||||
})
|
})
|
||||||
|
const fetchSubmoduleHistory = core.getBooleanInput(
|
||||||
|
'fetch_additional_submodule_history',
|
||||||
|
{
|
||||||
|
required: false
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
const inputs: Inputs = {
|
const inputs: Inputs = {
|
||||||
files,
|
files,
|
||||||
@ -225,6 +232,7 @@ export const getInputs = (): Inputs => {
|
|||||||
oldNewSeparator,
|
oldNewSeparator,
|
||||||
oldNewFilesSeparator,
|
oldNewFilesSeparator,
|
||||||
skipInitialFetch,
|
skipInitialFetch,
|
||||||
|
fetchSubmoduleHistory,
|
||||||
// End Not Supported via REST API
|
// End Not Supported via REST API
|
||||||
dirNames,
|
dirNames,
|
||||||
dirNamesExcludeCurrentDir,
|
dirNamesExcludeCurrentDir,
|
||||||
|
@ -317,7 +317,8 @@ export async function run(): Promise<void> {
|
|||||||
'recoverFiles',
|
'recoverFiles',
|
||||||
'recoverFilesIgnore',
|
'recoverFilesIgnore',
|
||||||
'includeAllOldNewRenamedFiles',
|
'includeAllOldNewRenamedFiles',
|
||||||
'skipInitialFetch'
|
'skipInitialFetch',
|
||||||
|
'fetchSubmoduleHistory'
|
||||||
]
|
]
|
||||||
|
|
||||||
for (const input of unsupportedInputs) {
|
for (const input of unsupportedInputs) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user