Skip to content

Commit 1907f8d

Browse files
authored
Merge branch 'main' into stanley/do-not-copy-over-if-require-commit
2 parents 31b5d2d + 035ca03 commit 1907f8d

File tree

3 files changed

+39
-11
lines changed

3 files changed

+39
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ This is the log of notable changes to EAS CLI and related packages.
1111
### 🐛 Bug fixes
1212

1313
- 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))
14+
- Fix `EISDIR` error when archiving project with submodules ignored. ([#2884](https://github.com/expo/eas-cli/pull/2884) by [@sjchmiela](https://github.com/sjchmiela))
1415

1516
### 🧹 Chores
1617

packages/eas-cli/src/vcs/clients/__tests__/git.test.ts

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,17 @@ import path from 'path';
66
import GitClient from '../git';
77

88
describe('git', () => {
9-
let repoRoot: string;
10-
beforeAll(async () => {
11-
repoRoot = await fs.mkdtemp(path.join(os.tmpdir(), 'eas-cli-git-test-'));
12-
await spawnAsync('git', ['init'], { cwd: repoRoot });
13-
});
14-
15-
afterAll(async () => {
16-
await fs.rm(repoRoot, { recursive: true, force: true });
17-
});
18-
199
describe('GitClient that does not require a commit', () => {
2010
let vcs: GitClient;
11+
let repoRoot: string;
12+
13+
afterAll(async () => {
14+
await fs.rm(repoRoot, { recursive: true, force: true });
15+
});
2116

2217
beforeAll(async () => {
18+
repoRoot = await fs.mkdtemp(path.join(os.tmpdir(), 'eas-cli-git-test-'));
19+
await spawnAsync('git', ['init'], { cwd: repoRoot });
2320
vcs = new GitClient({
2421
requireCommit: false,
2522
maybeCwdOverride: repoRoot,
@@ -135,4 +132,30 @@ describe('git', () => {
135132
});
136133
});
137134
});
135+
136+
it('is able to delete a submodule ignored by .easignore', async () => {
137+
const repoRoot = await fs.mkdtemp(path.join(os.tmpdir(), 'eas-cli-git-test-'));
138+
await spawnAsync('git', ['init'], { cwd: repoRoot });
139+
const vcs = new GitClient({
140+
requireCommit: false,
141+
maybeCwdOverride: repoRoot,
142+
});
143+
144+
await spawnAsync(
145+
'git',
146+
['submodule', 'add', 'https://github.com/expo/results.git', 'results'],
147+
{ cwd: repoRoot }
148+
);
149+
await spawnAsync('git', ['add', 'results'], { cwd: repoRoot });
150+
await spawnAsync('git', ['commit', '-m', 'add submodule'], { cwd: repoRoot });
151+
152+
const repoCloneNonIgnored = await fs.mkdtemp(path.join(os.tmpdir(), 'eas-cli-git-test-'));
153+
await expect(vcs.makeShallowCopyAsync(repoCloneNonIgnored)).resolves.not.toThrow();
154+
await expect(fs.stat(path.join(repoCloneNonIgnored, 'results'))).resolves.not.toThrow();
155+
156+
await fs.writeFile(`${repoRoot}/.easignore`, 'results');
157+
const repoCloneIgnored = await fs.mkdtemp(path.join(os.tmpdir(), 'eas-cli-git-test-'));
158+
await expect(vcs.makeShallowCopyAsync(repoCloneIgnored)).resolves.not.toThrow();
159+
await expect(fs.stat(path.join(repoCloneIgnored, 'results'))).rejects.toThrow('ENOENT');
160+
});
138161
});

packages/eas-cli/src/vcs/clients/git.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,11 @@ export default class GitClient extends Client {
210210
.filter(file => file !== '');
211211

212212
await Promise.all(
213-
cachedFilesWeShouldHaveIgnored.map(file => fs.rm(path.join(destinationPath, file)))
213+
cachedFilesWeShouldHaveIgnored.map(file =>
214+
// `ls-files` does not go over files within submodules. If submodule is
215+
// ignored, it is listed as a single path, so we need to `rm -rf` it.
216+
fs.rm(path.join(destinationPath, file), { recursive: true, force: true })
217+
)
214218
);
215219

216220
// Special-case `.git` which `git ls-files` will never consider ignored.

0 commit comments

Comments
 (0)