3
0
Fork 0
mirror of https://code.forgejo.org/actions/checkout.git synced 2025-04-24 12:25:34 +00:00
This commit is contained in:
Alexander Cranga 2025-01-17 09:35:31 +02:00 committed by GitHub
commit 5c521f3d4b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 72 additions and 8 deletions

24
dist/index.js vendored
View file

@ -1278,7 +1278,7 @@ function getSource(settings) {
else if (settings.sparseCheckout) {
fetchOptions.filter = 'blob:none';
}
if (settings.fetchDepth <= 0) {
if (settings.fetchDepth <= 0 || settings.defaultBranchCheckout) {
// Fetch all branches and tags
let refSpec = refHelper.getRefSpecForAllHistory(settings.ref, settings.commit);
yield git.fetch(refSpec, fetchOptions);
@ -1298,7 +1298,22 @@ function getSource(settings) {
core.endGroup();
// Checkout info
core.startGroup('Determining the checkout info');
const checkoutInfo = yield refHelper.getCheckoutInfo(git, settings.ref, settings.commit);
let checkoutInfo;
try {
checkoutInfo = yield refHelper.getCheckoutInfo(git, settings.ref, settings.commit);
}
catch (error) {
if (settings.defaultBranchCheckout) {
core.info('Could not determine the checkout info. Trying the default repository branch');
const repositoryDefaultBranch = settings.sshKey
? yield git.getDefaultBranch(repositoryUrl)
: yield githubApiHelper.getDefaultBranch(settings.authToken, settings.repositoryOwner, settings.repositoryName);
checkoutInfo = yield refHelper.getCheckoutInfo(git, repositoryDefaultBranch, settings.commit);
}
else {
throw error;
}
}
core.endGroup();
// LFS fetch
// Explicit lfs-fetch to avoid slow checkout (fetches one lfs object at a time).
@ -1763,6 +1778,11 @@ function getInputs() {
}
core.debug(`ref = '${result.ref}'`);
core.debug(`commit = '${result.commit}'`);
// Default branch checkout
result.defaultBranchCheckout =
(core.getInput('default-branch-checkout') || 'false').toUpperCase() ===
'TRUE';
core.debug(`default-branch-checkout = '${result.defaultBranchCheckout}'`);
// Clean
result.clean = (core.getInput('clean') || 'true').toUpperCase() === 'TRUE';
core.debug(`clean = ${result.clean}`);