Skip to content

Commit 98344b8

Browse files
authored
[eas-cli] Support excluding .git via .easignore (#2879)
<!-- If this PR requires a changelog entry, add it by commenting the PR with the command `/changelog-entry [breaking-change|new-feature|bug-fix|chore] [message]`. --> <!-- You can skip the changelog check by labeling the PR with "no changelog". --> # Why Currently it's not possible to exclude `.git` from being uploaded in project tarball. # How In `makeShallowCopyAsync()` we first clone the repository, then we delete files ignored by `.easignore` and then we copy working directory over. The "delete files ignored by `.easignore`" step is governed by `git ls-files --exclude-from=.easignore`. `git ls-files` is never going to consider `.git` directory to be excluded, even if specified in `.easignore`, so we need to special-case the `.git` directory and remove it manually if specified. # Test Plan Added `.git` to a test `.easignore`, ran `eas build:inspect` and confirmed the copied directory did _not_ contain `.git` folder.
1 parent f5480b4 commit 98344b8

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

CHANGELOG.md

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

1313
- Fixed `GitClient` not respecting `.easignore` file. ([#2873](https://github.com/expo/eas-cli/pull/2873) by [@sjchmiela](https://github.com/sjchmiela))
1414
- Fix symlink support in `makeShallowCopyAsync`. ([#2874](https://github.com/expo/eas-cli/pull/2874) by [@sjchmiela](https://github.com/sjchmiela))
15+
- Allow excluding `.git` directory from project archive by adding it to `.easignore`. ([#2879](https://github.com/expo/eas-cli/pull/2879) by [@sjchmiela](https://github.com/sjchmiela))
1516

1617
### 🧹 Chores
1718

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,12 @@ export default class GitClient extends Client {
212212
await Promise.all(
213213
cachedFilesWeShouldHaveIgnored.map(file => fs.rm(path.join(destinationPath, file)))
214214
);
215+
216+
// Special-case `.git` which `git ls-files` will never consider ignored.
217+
const ignore = await Ignore.createAsync(rootPath);
218+
if (ignore.ignores('.git')) {
219+
await fs.rm(path.join(destinationPath, '.git'), { recursive: true, force: true });
220+
}
215221
}
216222
} finally {
217223
await setGitCaseSensitivityAsync(isCaseSensitive, rootPath);
@@ -284,6 +290,7 @@ export default class GitClient extends Client {
284290
);
285291
}
286292

293+
/** NOTE: This method does not support checking whether `.git` is ignored by `.easignore` rules. */
287294
public override async isFileIgnoredAsync(filePath: string): Promise<boolean> {
288295
const rootPath = await this.getRootPathAsync();
289296

@@ -309,6 +316,7 @@ export default class GitClient extends Client {
309316
{ cwd: rootPath }
310317
)
311318
).stdout.trim() !== '';
319+
312320
// File is considered ignored if:
313321
// - makeShallowCopyAsync() will not copy it to the clone
314322
// AND

0 commit comments

Comments
 (0)