mirror of
https://code.forgejo.org/actions/checkout.git
synced 2026-01-21 03:24:46 +00:00
add our feature
This commit is contained in:
parent
b4ffde65f4
commit
e72243fb91
7 changed files with 101 additions and 8 deletions
|
|
@ -130,6 +130,21 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
|
|||
await authHelper.configureAuth()
|
||||
core.endGroup()
|
||||
|
||||
if (settings.defaultRefOnError && settings.defaultRefOnError === true) {
|
||||
// Configure default branch
|
||||
core.startGroup('Setting up default branch')
|
||||
if (settings.sshKey) {
|
||||
settings.defaultBranch = await git.getDefaultBranch(repositoryUrl)
|
||||
} else {
|
||||
settings.defaultBranch = await githubApiHelper.getDefaultBranch(
|
||||
settings.authToken,
|
||||
settings.repositoryOwner,
|
||||
settings.repositoryName
|
||||
)
|
||||
}
|
||||
core.endGroup()
|
||||
}
|
||||
|
||||
// Determine the default branch
|
||||
if (!settings.ref && !settings.commit) {
|
||||
core.startGroup('Determining the default branch')
|
||||
|
|
@ -166,7 +181,10 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
|
|||
fetchOptions.filter = 'blob:none'
|
||||
}
|
||||
|
||||
if (settings.fetchDepth <= 0) {
|
||||
if (
|
||||
settings.fetchDepth <= 0 ||
|
||||
(settings.defaultRefOnError && settings.defaultRefOnError === true)
|
||||
) {
|
||||
// Fetch all branches and tags
|
||||
let refSpec = refHelper.getRefSpecForAllHistory(
|
||||
settings.ref,
|
||||
|
|
@ -190,11 +208,31 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
|
|||
|
||||
// Checkout info
|
||||
core.startGroup('Determining the checkout info')
|
||||
const checkoutInfo = await refHelper.getCheckoutInfo(
|
||||
git,
|
||||
settings.ref,
|
||||
settings.commit
|
||||
)
|
||||
let checkoutInfo: refHelper.ICheckoutInfo
|
||||
if (settings.defaultRefOnError && settings.defaultRefOnError === true) {
|
||||
try {
|
||||
checkoutInfo = await refHelper.getCheckoutInfo(
|
||||
git,
|
||||
settings.ref,
|
||||
settings.commit
|
||||
)
|
||||
} catch (error) {
|
||||
core.info(
|
||||
'Could not determine the checkout info. Trying the default repo branch'
|
||||
)
|
||||
checkoutInfo = await refHelper.getCheckoutInfo(
|
||||
git,
|
||||
settings.defaultBranch,
|
||||
settings.commit
|
||||
)
|
||||
}
|
||||
} else {
|
||||
checkoutInfo = await refHelper.getCheckoutInfo(
|
||||
git,
|
||||
settings.ref,
|
||||
settings.commit
|
||||
)
|
||||
}
|
||||
core.endGroup()
|
||||
|
||||
// LFS fetch
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue