mirror of
https://github.com/actions/checkout.git
synced 2025-04-02 22:40:06 +02:00
If no sparse-checkout
parameter is specified, disable it
This should allow users to reuse existing folders when running `actions/checkout` where a previous run asked for a sparse checkout but the current run does not ask for a sparse checkout. This fixes https://github.com/actions/checkout/issues/1475 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
parent
b4ffde65f4
commit
5adf77fbfc
4 changed files with 10 additions and 1 deletions
|
@ -727,6 +727,7 @@ async function setup(testName: string): Promise<void> {
|
||||||
branchDelete: jest.fn(),
|
branchDelete: jest.fn(),
|
||||||
branchExists: jest.fn(),
|
branchExists: jest.fn(),
|
||||||
branchList: jest.fn(),
|
branchList: jest.fn(),
|
||||||
|
disableSparseCheckout: jest.fn(),
|
||||||
sparseCheckout: jest.fn(),
|
sparseCheckout: jest.fn(),
|
||||||
sparseCheckoutNonConeMode: jest.fn(),
|
sparseCheckoutNonConeMode: jest.fn(),
|
||||||
checkout: jest.fn(),
|
checkout: jest.fn(),
|
||||||
|
|
|
@ -462,6 +462,7 @@ async function setup(testName: string): Promise<void> {
|
||||||
branchList: jest.fn(async () => {
|
branchList: jest.fn(async () => {
|
||||||
return []
|
return []
|
||||||
}),
|
}),
|
||||||
|
disableSparseCheckout: jest.fn(),
|
||||||
sparseCheckout: jest.fn(),
|
sparseCheckout: jest.fn(),
|
||||||
sparseCheckoutNonConeMode: jest.fn(),
|
sparseCheckoutNonConeMode: jest.fn(),
|
||||||
checkout: jest.fn(),
|
checkout: jest.fn(),
|
||||||
|
|
|
@ -17,6 +17,7 @@ export interface IGitCommandManager {
|
||||||
branchDelete(remote: boolean, branch: string): Promise<void>
|
branchDelete(remote: boolean, branch: string): Promise<void>
|
||||||
branchExists(remote: boolean, pattern: string): Promise<boolean>
|
branchExists(remote: boolean, pattern: string): Promise<boolean>
|
||||||
branchList(remote: boolean): Promise<string[]>
|
branchList(remote: boolean): Promise<string[]>
|
||||||
|
disableSparseCheckout(): Promise<void>
|
||||||
sparseCheckout(sparseCheckout: string[]): Promise<void>
|
sparseCheckout(sparseCheckout: string[]): Promise<void>
|
||||||
sparseCheckoutNonConeMode(sparseCheckout: string[]): Promise<void>
|
sparseCheckoutNonConeMode(sparseCheckout: string[]): Promise<void>
|
||||||
checkout(ref: string, startPoint: string): Promise<void>
|
checkout(ref: string, startPoint: string): Promise<void>
|
||||||
|
@ -171,6 +172,10 @@ class GitCommandManager {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async disableSparseCheckout(): Promise<void> {
|
||||||
|
await this.execGit(['sparse-checkout', 'disable'])
|
||||||
|
}
|
||||||
|
|
||||||
async sparseCheckout(sparseCheckout: string[]): Promise<void> {
|
async sparseCheckout(sparseCheckout: string[]): Promise<void> {
|
||||||
await this.execGit(['sparse-checkout', 'set', ...sparseCheckout])
|
await this.execGit(['sparse-checkout', 'set', ...sparseCheckout])
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,7 +208,9 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sparse checkout
|
// Sparse checkout
|
||||||
if (settings.sparseCheckout) {
|
if (!settings.sparseCheckout) {
|
||||||
|
await git.disableSparseCheckout()
|
||||||
|
} else {
|
||||||
core.startGroup('Setting up sparse checkout')
|
core.startGroup('Setting up sparse checkout')
|
||||||
if (settings.sparseCheckoutConeMode) {
|
if (settings.sparseCheckoutConeMode) {
|
||||||
await git.sparseCheckout(settings.sparseCheckout)
|
await git.sparseCheckout(settings.sparseCheckout)
|
||||||
|
|
Loading…
Add table
Reference in a new issue