From 4ddc76db4c7bbedcb52b82d9e86f25e82d741819 Mon Sep 17 00:00:00 2001 From: Vaibhav Acharya Date: Wed, 18 Nov 2026 12:25:45 +0530 Subject: [PATCH 1/5] fix(deploy): keep root files that share a prefix with ignored folders --- src/utils/deploy/upload-source-zip.ts | 32 +++++++++---------- .../utils/deploy/upload-source-zip.test.ts | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/utils/deploy/upload-source-zip.ts b/src/utils/deploy/upload-source-zip.ts index 4bfc45d0275..817a125561e 100644 --- a/src/utils/deploy/upload-source-zip.ts +++ b/src/utils/deploy/upload-source-zip.ts @@ -18,26 +18,26 @@ interface UploadSourceZipOptions { } const DEFAULT_IGNORE_PATTERNS = [ - 'node_modules*', - '.git*', - '.netlify*', - '.next*', - 'dist*', - 'build*', - '.nuxt*', - '.output*', - '.vercel*', - '__pycache__*', - '.venv*', + 'node_modules/*', + '.git/*', + '.netlify/*', + '.next/*', + 'dist/*', + 'build/*', + '.nuxt/*', + '.output/*', + '.vercel/*', + '__pycache__/*', + '.venv/*', '.env', '.DS_Store', 'Thumbs.db', '*.log', - '.nyc_output*', - 'coverage*', - '.cache*', - '.tmp*', - '.temp*', + '.nyc_output/*', + 'coverage/*', + '.cache/*', + '.tmp/*', + '.temp/*', ] const isExecaError = (error: unknown): error is ExecaError => error instanceof Error && 'command' in error diff --git a/tests/unit/utils/deploy/upload-source-zip.test.ts b/tests/unit/utils/deploy/upload-source-zip.test.ts index 1bb93c588ee..004a1ff945e 100644 --- a/tests/unit/utils/deploy/upload-source-zip.test.ts +++ b/tests/unit/utils/deploy/upload-source-zip.test.ts @@ -192,7 +192,7 @@ describe('uploadSourceZip', () => { expect(mockExeca.default).toHaveBeenCalledWith( 'zip', - expect.arrayContaining(['-x', 'node_modules*', '-x', '.git*', '-x', '.netlify*', '-x', '.env']), + expect.arrayContaining(['-x', 'node_modules/*', '-x', '.git/*', '-x', '.netlify/*', '-x', '.env']), expect.objectContaining({ cwd: '/test/source' }), ) }) From e1ca8e2cc20657bd5f51b9c4f7c80ff2c5c61efb Mon Sep 17 00:00:00 2001 From: Vaibhav Acharya Date: Wed, 18 Nov 2026 14:01:36 +0530 Subject: [PATCH 2/5] fix(deploy): keep .git-credentials out of the source zip --- src/utils/deploy/upload-source-zip.ts | 1 + .../deploy/upload-source-zip-contents.test.ts | 101 ++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 tests/unit/utils/deploy/upload-source-zip-contents.test.ts diff --git a/src/utils/deploy/upload-source-zip.ts b/src/utils/deploy/upload-source-zip.ts index 817a125561e..0bb03eab61d 100644 --- a/src/utils/deploy/upload-source-zip.ts +++ b/src/utils/deploy/upload-source-zip.ts @@ -20,6 +20,7 @@ interface UploadSourceZipOptions { const DEFAULT_IGNORE_PATTERNS = [ 'node_modules/*', '.git/*', + '.git-credentials', '.netlify/*', '.next/*', 'dist/*', diff --git a/tests/unit/utils/deploy/upload-source-zip-contents.test.ts b/tests/unit/utils/deploy/upload-source-zip-contents.test.ts new file mode 100644 index 00000000000..2ad194d84fa --- /dev/null +++ b/tests/unit/utils/deploy/upload-source-zip-contents.test.ts @@ -0,0 +1,101 @@ +import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises' +import { tmpdir } from 'node:os' +import { dirname, join } from 'node:path' + +import execa from 'execa' +import fetch from 'node-fetch' +import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest' + +import { uploadSourceZip } from '../../../../src/utils/deploy/upload-source-zip.js' + +vi.mock('node-fetch', () => ({ + default: vi.fn(), +})) + +vi.mock('../../../../src/utils/command-helpers.js', () => ({ + log: vi.fn(), + warn: vi.fn(), +})) + +const zippedPaths = async (workDir: string, files: string[]) => { + const sourceDir = join(workDir, 'source') + for (const file of files) { + await mkdir(dirname(join(sourceDir, file)), { recursive: true }) + await writeFile(join(sourceDir, file), '') + } + + let uploadedZip: Buffer | undefined + vi.mocked(fetch).mockImplementation((_url, init) => { + uploadedZip = init?.body as Buffer + return Promise.resolve({ ok: true, status: 200, statusText: 'OK' } as Awaited>) + }) + + await uploadSourceZip({ + sourceDir, + uploadUrl: 'https://s3.example.com/upload-url', + filename: 'workspace-snapshots/source.zip', + }) + + const zipPath = join(workDir, 'uploaded.zip') + await writeFile(zipPath, uploadedZip ?? Buffer.alloc(0)) + const { stdout } = await execa('unzip', ['-Z1', zipPath]) + return stdout.split('\n').filter((path) => !path.endsWith('/')) +} + +describe.skipIf(process.platform === 'win32')('uploadSourceZip contents', () => { + let workDir: string + + beforeEach(async () => { + workDir = await mkdtemp(join(tmpdir(), 'upload-source-zip-')) + }) + + afterEach(async () => { + await rm(workDir, { recursive: true, force: true }) + }) + + test('keeps root files that share a prefix with an ignored folder', async () => { + const paths = await zippedPaths(workDir, [ + 'index.html', + 'build.cjs', + 'build.sh', + 'builder.config.js', + 'distribute.js', + 'coverage.md', + '.gitignore', + '.github/workflows/ci.yml', + 'src/build/index.js', + ]) + + expect(paths.sort()).toEqual( + [ + 'index.html', + 'build.cjs', + 'build.sh', + 'builder.config.js', + 'distribute.js', + 'coverage.md', + '.gitignore', + '.github/workflows/ci.yml', + 'src/build/index.js', + ].sort(), + ) + }) + + test('leaves out ignored folders and files', async () => { + const paths = await zippedPaths(workDir, [ + 'index.html', + 'node_modules/pkg/index.js', + '.git/HEAD', + '.git-credentials', + '.netlify/state.json', + '.next/server.js', + 'dist/app.js', + 'build/app.js', + 'coverage/lcov.info', + '.env', + 'debug.log', + ]) + + expect(paths).toEqual(['index.html']) + }) +}) From f4eb8565aaef03c179a6f17ceee3ee4339b7efe2 Mon Sep 17 00:00:00 2001 From: Vaibhav Acharya Date: Thu, 19 Nov 2026 20:09:04 +0530 Subject: [PATCH 3/5] fix(deploy): keep worktree .git file and .git-credentials.lock out of the source zip --- src/utils/deploy/upload-source-zip.ts | 2 ++ tests/unit/utils/deploy/upload-source-zip-contents.test.ts | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/src/utils/deploy/upload-source-zip.ts b/src/utils/deploy/upload-source-zip.ts index 0bb03eab61d..36cafc5daac 100644 --- a/src/utils/deploy/upload-source-zip.ts +++ b/src/utils/deploy/upload-source-zip.ts @@ -19,8 +19,10 @@ interface UploadSourceZipOptions { const DEFAULT_IGNORE_PATTERNS = [ 'node_modules/*', + '.git', '.git/*', '.git-credentials', + '.git-credentials.lock', '.netlify/*', '.next/*', 'dist/*', diff --git a/tests/unit/utils/deploy/upload-source-zip-contents.test.ts b/tests/unit/utils/deploy/upload-source-zip-contents.test.ts index 2ad194d84fa..686c3e13880 100644 --- a/tests/unit/utils/deploy/upload-source-zip-contents.test.ts +++ b/tests/unit/utils/deploy/upload-source-zip-contents.test.ts @@ -87,6 +87,7 @@ describe.skipIf(process.platform === 'win32')('uploadSourceZip contents', () => 'node_modules/pkg/index.js', '.git/HEAD', '.git-credentials', + '.git-credentials.lock', '.netlify/state.json', '.next/server.js', 'dist/app.js', @@ -98,4 +99,10 @@ describe.skipIf(process.platform === 'win32')('uploadSourceZip contents', () => expect(paths).toEqual(['index.html']) }) + + test('leaves out the .git file of a linked worktree', async () => { + const paths = await zippedPaths(workDir, ['index.html', '.git', '.gitignore']) + + expect(paths.sort()).toEqual(['.gitignore', 'index.html']) + }) }) From 49bf21c3f07b57fa944096d6dfe8d13c6387ff9e Mon Sep 17 00:00:00 2001 From: Vaibhav Acharya Date: Thu, 19 Nov 2026 20:23:06 +0530 Subject: [PATCH 4/5] fix(deploy): keep .gitconfig out of the source zip --- src/utils/deploy/upload-source-zip.ts | 1 + tests/unit/utils/deploy/upload-source-zip-contents.test.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/src/utils/deploy/upload-source-zip.ts b/src/utils/deploy/upload-source-zip.ts index 36cafc5daac..56affaa2451 100644 --- a/src/utils/deploy/upload-source-zip.ts +++ b/src/utils/deploy/upload-source-zip.ts @@ -23,6 +23,7 @@ const DEFAULT_IGNORE_PATTERNS = [ '.git/*', '.git-credentials', '.git-credentials.lock', + '.gitconfig', '.netlify/*', '.next/*', 'dist/*', diff --git a/tests/unit/utils/deploy/upload-source-zip-contents.test.ts b/tests/unit/utils/deploy/upload-source-zip-contents.test.ts index 686c3e13880..18091f72114 100644 --- a/tests/unit/utils/deploy/upload-source-zip-contents.test.ts +++ b/tests/unit/utils/deploy/upload-source-zip-contents.test.ts @@ -88,6 +88,7 @@ describe.skipIf(process.platform === 'win32')('uploadSourceZip contents', () => '.git/HEAD', '.git-credentials', '.git-credentials.lock', + '.gitconfig', '.netlify/state.json', '.next/server.js', 'dist/app.js', From 43c260b8c742e2ee9d5adee8a50782b402a8e3ef Mon Sep 17 00:00:00 2001 From: Vaibhav Acharya Date: Thu, 19 Nov 2026 20:37:27 +0530 Subject: [PATCH 5/5] fix(deploy): keep .gitconfig.lock and .gitcookies out of the source zip --- src/utils/deploy/upload-source-zip.ts | 2 ++ tests/unit/utils/deploy/upload-source-zip-contents.test.ts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/utils/deploy/upload-source-zip.ts b/src/utils/deploy/upload-source-zip.ts index 56affaa2451..f38af9754a1 100644 --- a/src/utils/deploy/upload-source-zip.ts +++ b/src/utils/deploy/upload-source-zip.ts @@ -24,6 +24,8 @@ const DEFAULT_IGNORE_PATTERNS = [ '.git-credentials', '.git-credentials.lock', '.gitconfig', + '.gitconfig.lock', + '.gitcookies', '.netlify/*', '.next/*', 'dist/*', diff --git a/tests/unit/utils/deploy/upload-source-zip-contents.test.ts b/tests/unit/utils/deploy/upload-source-zip-contents.test.ts index 18091f72114..28d2cea7a30 100644 --- a/tests/unit/utils/deploy/upload-source-zip-contents.test.ts +++ b/tests/unit/utils/deploy/upload-source-zip-contents.test.ts @@ -89,6 +89,8 @@ describe.skipIf(process.platform === 'win32')('uploadSourceZip contents', () => '.git-credentials', '.git-credentials.lock', '.gitconfig', + '.gitconfig.lock', + '.gitcookies', '.netlify/state.json', '.next/server.js', 'dist/app.js',