Allow filter: none to disable the implicit blob:none for sparse checkout

When sparse-checkout is set and filter is not, checkout fetches with
--filter=blob:none. If the sparse patterns keep most of the repository,
the following checkout fetches each blob lazily from the promisor remote,
which is slower than one full pack.

Setting filter to 'none' now fetches without a filter. 'none' is not a
valid git filter-spec, so no existing workflow can depend on it.

The effective filter is now resolved in input-helper, so
git-source-provider has one decision point.
This commit is contained in:
Jellyfrog 2026-10-02 01:45:20 +02:00
parent f548e57e54
commit 4fba4c42af
8 changed files with 110 additions and 22 deletions

View file

@ -215,6 +215,47 @@ describe('input-helper tests', () => {
expect(settings.commit).toBe('1111111111222222222233333333334444444444')
})
describe('filter', () => {
it('is not set without sparse checkout', async () => {
const settings: IGitSourceSettings = await inputHelper.getInputs()
expect(settings.filter).toBe(undefined)
})
it('defaults to blob:none with sparse checkout', async () => {
inputs['sparse-checkout'] = 'src\ndocs'
const settings: IGitSourceSettings = await inputHelper.getInputs()
expect(settings.sparseCheckout).toEqual(['src', 'docs'])
expect(settings.filter).toBe('blob:none')
})
it('uses the given filter with sparse checkout', async () => {
inputs['sparse-checkout'] = 'src'
inputs.filter = 'tree:0'
const settings: IGitSourceSettings = await inputHelper.getInputs()
expect(settings.filter).toBe('tree:0')
})
it('uses the given filter without sparse checkout', async () => {
inputs.filter = 'blob:limit=1m'
const settings: IGitSourceSettings = await inputHelper.getInputs()
expect(settings.filter).toBe('blob:limit=1m')
})
it('is not set when none with sparse checkout', async () => {
inputs['sparse-checkout'] = 'src'
inputs.filter = 'none'
const settings: IGitSourceSettings = await inputHelper.getInputs()
expect(settings.sparseCheckout).toEqual(['src'])
expect(settings.filter).toBe(undefined)
})
it('is not set when none without sparse checkout', async () => {
inputs.filter = 'None'
const settings: IGitSourceSettings = await inputHelper.getInputs()
expect(settings.filter).toBe(undefined)
})
})
it('sets workflow organization ID', async () => {
const settings: IGitSourceSettings = await inputHelper.getInputs()
expect(settings.workflowOrganizationId).toBe(123456)