Check git version before attempting to disable sparse-checkout`

This commit is contained in:
John Wesley Walker III 2024-03-12 15:22:04 +00:00
parent 8410ad0602
commit 5fd05b69b4
6 changed files with 76 additions and 27 deletions

View file

@ -9,7 +9,7 @@ import * as path from 'path'
import * as refHelper from './ref-helper'
import * as stateHelper from './state-helper'
import * as urlHelper from './url-helper'
import {IGitCommandManager} from './git-command-manager'
import {MinimumGitSparseCheckoutVersion, IGitCommandManager} from './git-command-manager'
import {IGitSourceSettings} from './git-source-settings'
export async function getSource(settings: IGitSourceSettings): Promise<void> {
@ -209,7 +209,11 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
// Sparse checkout
if (!settings.sparseCheckout) {
await git.disableSparseCheckout()
let gitVersion = await git.version()
// no need to disable sparse-checkout if the installed git runtime doesn't even support it.
if (gitVersion.checkMinimum(MinimumGitSparseCheckoutVersion)) {
await git.disableSparseCheckout()
}
} else {
core.startGroup('Setting up sparse checkout')
if (settings.sparseCheckoutConeMode) {