diff --git a/CHANGELOG.md b/CHANGELOG.md index 9bb6f3df77..53418dd77b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ This is the log of notable changes to EAS CLI and related packages. ### ๐Ÿ› Bug fixes - Do not copy files over onto a cloned Git repository when packing the project archive if `requireCommit` is true. ([#2885](https://github.com/expo/eas-cli/pull/2885) by [@sjchmiela](https://github.com/sjchmiela)) +- Fix `EISDIR` error when archiving project with submodules ignored. ([#2884](https://github.com/expo/eas-cli/pull/2884) by [@sjchmiela](https://github.com/sjchmiela)) ### ๐Ÿงน Chores diff --git a/packages/eas-cli/src/vcs/clients/__tests__/git.test.ts b/packages/eas-cli/src/vcs/clients/__tests__/git.test.ts index ad1429ba92..7b1086551c 100644 --- a/packages/eas-cli/src/vcs/clients/__tests__/git.test.ts +++ b/packages/eas-cli/src/vcs/clients/__tests__/git.test.ts @@ -6,20 +6,17 @@ import path from 'path'; import GitClient from '../git'; describe('git', () => { - let repoRoot: string; - beforeAll(async () => { - repoRoot = await fs.mkdtemp(path.join(os.tmpdir(), 'eas-cli-git-test-')); - await spawnAsync('git', ['init'], { cwd: repoRoot }); - }); - - afterAll(async () => { - await fs.rm(repoRoot, { recursive: true, force: true }); - }); - describe('GitClient that does not require a commit', () => { let vcs: GitClient; + let repoRoot: string; + + afterAll(async () => { + await fs.rm(repoRoot, { recursive: true, force: true }); + }); beforeAll(async () => { + repoRoot = await fs.mkdtemp(path.join(os.tmpdir(), 'eas-cli-git-test-')); + await spawnAsync('git', ['init'], { cwd: repoRoot }); vcs = new GitClient({ requireCommit: false, maybeCwdOverride: repoRoot, @@ -135,4 +132,30 @@ describe('git', () => { }); }); }); + + it('is able to delete a submodule ignored by .easignore', async () => { + const repoRoot = await fs.mkdtemp(path.join(os.tmpdir(), 'eas-cli-git-test-')); + await spawnAsync('git', ['init'], { cwd: repoRoot }); + const vcs = new GitClient({ + requireCommit: false, + maybeCwdOverride: repoRoot, + }); + + await spawnAsync( + 'git', + ['submodule', 'add', 'https://github.com/expo/results.git', 'results'], + { cwd: repoRoot } + ); + await spawnAsync('git', ['add', 'results'], { cwd: repoRoot }); + await spawnAsync('git', ['commit', '-m', 'add submodule'], { cwd: repoRoot }); + + const repoCloneNonIgnored = await fs.mkdtemp(path.join(os.tmpdir(), 'eas-cli-git-test-')); + await expect(vcs.makeShallowCopyAsync(repoCloneNonIgnored)).resolves.not.toThrow(); + await expect(fs.stat(path.join(repoCloneNonIgnored, 'results'))).resolves.not.toThrow(); + + await fs.writeFile(`${repoRoot}/.easignore`, 'results'); + const repoCloneIgnored = await fs.mkdtemp(path.join(os.tmpdir(), 'eas-cli-git-test-')); + await expect(vcs.makeShallowCopyAsync(repoCloneIgnored)).resolves.not.toThrow(); + await expect(fs.stat(path.join(repoCloneIgnored, 'results'))).rejects.toThrow('ENOENT'); + }); }); diff --git a/packages/eas-cli/src/vcs/clients/git.ts b/packages/eas-cli/src/vcs/clients/git.ts index d7abc6bb46..89a1abca3e 100644 --- a/packages/eas-cli/src/vcs/clients/git.ts +++ b/packages/eas-cli/src/vcs/clients/git.ts @@ -210,7 +210,11 @@ export default class GitClient extends Client { .filter(file => file !== ''); await Promise.all( - cachedFilesWeShouldHaveIgnored.map(file => fs.rm(path.join(destinationPath, file))) + cachedFilesWeShouldHaveIgnored.map(file => + // `ls-files` does not go over files within submodules. If submodule is + // ignored, it is listed as a single path, so we need to `rm -rf` it. + fs.rm(path.join(destinationPath, file), { recursive: true, force: true }) + ) ); // Special-case `.git` which `git ls-files` will never consider ignored.