Skip to content

Commit ce4272e

Browse files
committed
Support fetching without the --progress option
Setting the `progress` option to false in the `with` section of the workflow step will cause git fetch to run without `--progress`. The motivation is to be able to suppress the noisy progress status output which adds many hundreds of "remote: Counting objects: 85% (386/453)" and similar lines in the workflow log. This should be sufficient to resolve #894 and its older friends, though the solution is different to the one proposed there because it doesn't use the --quiet flag. IIUC git doesn't show the progress status by default since the output is not a terminal, so that's why removing the --progress option is all that's needed. Adding the --quiet flag doesn't make a lot of difference once the --progress flag is removed, and actually I think it would suppress some other useful output that would be better to show. Signed-off-by: Simon Baird <[email protected]>
1 parent 96f5310 commit ce4272e

File tree

9 files changed

+34
-4
lines changed

9 files changed

+34
-4
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ When Git 2.18 or higher is not in your PATH, falls back to the REST API to downl
8787
# Default: 1
8888
fetch-depth: ''
8989

90+
# Whether to show progress status output when fetching.
91+
# Default: true
92+
show-progress: ''
93+
9094
# Whether to download Git-LFS files
9195
# Default: false
9296
lfs: ''

__test__/git-auth-helper.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,7 @@ async function setup(testName: string): Promise<void> {
805805
sparseCheckout: [],
806806
sparseCheckoutConeMode: true,
807807
fetchDepth: 1,
808+
showProgress: true,
808809
lfs: false,
809810
submodules: false,
810811
nestedSubmodules: false,

__test__/input-helper.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ describe('input-helper tests', () => {
8282
expect(settings.sparseCheckout).toBe(undefined)
8383
expect(settings.sparseCheckoutConeMode).toBe(true)
8484
expect(settings.fetchDepth).toBe(1)
85+
expect(settings.showProgress).toBe(true)
8586
expect(settings.lfs).toBe(false)
8687
expect(settings.ref).toBe('refs/heads/some-ref')
8788
expect(settings.repositoryName).toBe('some-repo')

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ inputs:
6565
fetch-depth:
6666
description: 'Number of commits to fetch. 0 indicates all history for all branches and tags.'
6767
default: 1
68+
show-progress:
69+
description: 'Whether to show progress status output when fetching.'
70+
default: true
6871
lfs:
6972
description: 'Whether to download Git-LFS files'
7073
default: false

dist/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,10 @@ class GitCommandManager {
640640
if (!refSpec.some(x => x === refHelper.tagsRefSpec)) {
641641
args.push('--no-tags');
642642
}
643-
args.push('--prune', '--progress', '--no-recurse-submodules');
643+
args.push('--prune', '--no-recurse-submodules');
644+
if (options.showProgress) {
645+
args.push('--progress');
646+
}
644647
if (options.filter) {
645648
args.push(`--filter=${options.filter}`);
646649
}
@@ -1734,6 +1737,10 @@ function getInputs() {
17341737
result.fetchDepth = 0;
17351738
}
17361739
core.debug(`fetch depth = ${result.fetchDepth}`);
1740+
// Show fetch progress
1741+
result.showProgress =
1742+
(core.getInput('show-progress') || 'true').toUpperCase() === 'TRUE';
1743+
core.debug(`show progress = ${result.showProgress}`);
17371744
// LFS
17381745
result.lfs = (core.getInput('lfs') || 'false').toUpperCase() === 'TRUE';
17391746
core.debug(`lfs = ${result.lfs}`);

src/git-command-manager.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export interface IGitCommandManager {
3333
options: {
3434
filter?: string
3535
fetchDepth?: number
36+
showProgress?: boolean
3637
}
3738
): Promise<void>
3839
getDefaultBranch(repositoryUrl: string): Promise<string>
@@ -240,14 +241,17 @@ class GitCommandManager {
240241

241242
async fetch(
242243
refSpec: string[],
243-
options: {filter?: string; fetchDepth?: number}
244+
options: {filter?: string; fetchDepth?: number, showProgress?: boolean}
244245
): Promise<void> {
245246
const args = ['-c', 'protocol.version=2', 'fetch']
246247
if (!refSpec.some(x => x === refHelper.tagsRefSpec)) {
247248
args.push('--no-tags')
248249
}
249250

250-
args.push('--prune', '--progress', '--no-recurse-submodules')
251+
args.push('--prune', '--no-recurse-submodules')
252+
if (options.showProgress) {
253+
args.push('--progress')
254+
}
251255

252256
if (options.filter) {
253257
args.push(`--filter=${options.filter}`)

src/git-source-provider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
153153

154154
// Fetch
155155
core.startGroup('Fetching the repository')
156-
const fetchOptions: {filter?: string; fetchDepth?: number} = {}
156+
const fetchOptions: {filter?: string; fetchDepth?: number, showProgress?: boolean} = {}
157157
if (settings.sparseCheckout) fetchOptions.filter = 'blob:none'
158158
if (settings.fetchDepth <= 0) {
159159
// Fetch all branches and tags

src/git-source-settings.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ export interface IGitSourceSettings {
4444
*/
4545
fetchDepth: number
4646

47+
/**
48+
* Indicates whether to use the --progress option when fetching
49+
*/
50+
showProgress: boolean
51+
4752
/**
4853
* Indicates whether to fetch LFS objects
4954
*/

src/input-helper.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ export async function getInputs(): Promise<IGitSourceSettings> {
100100
}
101101
core.debug(`fetch depth = ${result.fetchDepth}`)
102102

103+
// Show fetch progress
104+
result.showProgress =
105+
(core.getInput('show-progress') || 'true').toUpperCase() === 'TRUE'
106+
core.debug(`show progress = ${result.showProgress}`)
107+
103108
// LFS
104109
result.lfs = (core.getInput('lfs') || 'false').toUpperCase() === 'TRUE'
105110
core.debug(`lfs = ${result.lfs}`)

0 commit comments

Comments
 (0)