Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[eas-cli] Fix deleting ignored submodules when archiving project #2884

Merged
merged 3 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ This is the log of notable changes to EAS CLI and related packages.

### 🐛 Bug fixes

- 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

## [15.0.4](https://github.com/expo/eas-cli/releases/tag/v15.0.4) - 2025-02-05
Expand Down
43 changes: 33 additions & 10 deletions packages/eas-cli/src/vcs/clients/__tests__/git.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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');
});
});
6 changes: 5 additions & 1 deletion packages/eas-cli/src/vcs/clients/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down