mirror of
https://github.com/actions/checkout.git
synced 2026-11-16 14:35:03 +08:00
feat: make show-progress control checkout verbosity, not just fetch
Previously checkout/checkoutDetach always ran with --progress regardless of the show-progress input, and settings.showProgress was never propagated into fetchOptions. Thread showProgress through checkout and checkoutDetach so they use --quiet when show-progress is false, giving a genuinely quiet checkout when show-progress: false is set. Ported from schlags/checkout (show-progress-required branch) onto current actions/checkout main.
This commit is contained in:
parent
f548e57e54
commit
2f547d07f2
7 changed files with 33 additions and 17 deletions
|
|
@ -22,8 +22,8 @@ export interface IGitCommandManager {
|
|||
disableSparseCheckout(): Promise<void>
|
||||
sparseCheckout(sparseCheckout: string[]): Promise<void>
|
||||
sparseCheckoutNonConeMode(sparseCheckout: string[]): Promise<void>
|
||||
checkout(ref: string, startPoint: string): Promise<void>
|
||||
checkoutDetach(): Promise<void>
|
||||
checkout(ref: string, startPoint: string, showProgress: boolean): Promise<void>
|
||||
checkoutDetach(showProgress: boolean): Promise<void>
|
||||
config(
|
||||
configKey: string,
|
||||
configValue: string,
|
||||
|
|
@ -220,8 +220,12 @@ class GitCommandManager {
|
|||
)
|
||||
}
|
||||
|
||||
async checkout(ref: string, startPoint: string): Promise<void> {
|
||||
const args = ['checkout', '--progress', '--force']
|
||||
async checkout(
|
||||
ref: string,
|
||||
startPoint: string,
|
||||
showProgress: boolean
|
||||
): Promise<void> {
|
||||
const args = ['checkout', showProgress ? '--progress' : '--quiet', '--force']
|
||||
if (startPoint) {
|
||||
args.push('-B', ref, startPoint)
|
||||
} else {
|
||||
|
|
@ -231,8 +235,8 @@ class GitCommandManager {
|
|||
await this.execGit(args)
|
||||
}
|
||||
|
||||
async checkoutDetach(): Promise<void> {
|
||||
const args = ['checkout', '--detach']
|
||||
async checkoutDetach(showProgress: boolean): Promise<void> {
|
||||
const args = ['checkout', '--detach', showProgress ? '--progress' : '--quiet']
|
||||
await this.execGit(args)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ export async function prepareExistingDirectory(
|
|||
core.startGroup('Removing previously created refs, to avoid conflicts')
|
||||
// Checkout detached HEAD
|
||||
if (!(await git.isDetached())) {
|
||||
await git.checkoutDetach()
|
||||
await git.checkoutDetach(false)
|
||||
}
|
||||
|
||||
// Remove all refs/heads/*
|
||||
|
|
|
|||
|
|
@ -179,6 +179,10 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
|
|||
showProgress?: boolean
|
||||
} = {}
|
||||
|
||||
if (settings.showProgress) {
|
||||
fetchOptions.showProgress = true
|
||||
}
|
||||
|
||||
if (settings.filter) {
|
||||
fetchOptions.filter = settings.filter
|
||||
} else if (settings.sparseCheckout) {
|
||||
|
|
@ -268,7 +272,11 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
|
|||
|
||||
// Checkout
|
||||
core.startGroup('Checking out the ref')
|
||||
await git.checkout(checkoutInfo.ref, checkoutInfo.startPoint)
|
||||
await git.checkout(
|
||||
checkoutInfo.ref,
|
||||
checkoutInfo.startPoint,
|
||||
settings.showProgress
|
||||
)
|
||||
core.endGroup()
|
||||
|
||||
// Submodules
|
||||
|
|
|
|||
|
|
@ -55,7 +55,8 @@ export interface IGitSourceSettings {
|
|||
fetchTags: boolean
|
||||
|
||||
/**
|
||||
* Indicates whether to use the --progress option when fetching
|
||||
* Indicates whether to show progress status output for git operations.
|
||||
* When false, git commands use --quiet to suppress verbose output.
|
||||
*/
|
||||
showProgress: boolean
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue