Skip to content

Commit

Permalink
Merge branch 'main' into stanley/do-not-copy-over-if-require-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
sjchmiela authored Feb 6, 2025
2 parents 31b5d2d + 035ca03 commit 1907f8d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

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

0 comments on commit 1907f8d

Please sign in to comment.