diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d3df26bbc..1cc7e23011 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ This is the log of notable changes to EAS CLI and related packages. - Fixed `GitClient` not respecting `.easignore` file. ([#2873](https://github.com/expo/eas-cli/pull/2873) by [@sjchmiela](https://github.com/sjchmiela)) - Fix symlink support in `makeShallowCopyAsync`. ([#2874](https://github.com/expo/eas-cli/pull/2874) by [@sjchmiela](https://github.com/sjchmiela)) +- 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)) ### 🧹 Chores diff --git a/packages/eas-cli/src/vcs/clients/git.ts b/packages/eas-cli/src/vcs/clients/git.ts index a1fd6a0e29..12ea2bf01b 100644 --- a/packages/eas-cli/src/vcs/clients/git.ts +++ b/packages/eas-cli/src/vcs/clients/git.ts @@ -212,6 +212,12 @@ export default class GitClient extends Client { await Promise.all( cachedFilesWeShouldHaveIgnored.map(file => fs.rm(path.join(destinationPath, file))) ); + + // Special-case `.git` which `git ls-files` will never consider ignored. + const ignore = await Ignore.createAsync(rootPath); + if (ignore.ignores('.git')) { + await fs.rm(path.join(destinationPath, '.git'), { recursive: true, force: true }); + } } } finally { await setGitCaseSensitivityAsync(isCaseSensitive, rootPath); @@ -284,6 +290,7 @@ export default class GitClient extends Client { ); } + /** NOTE: This method does not support checking whether `.git` is ignored by `.easignore` rules. */ public override async isFileIgnoredAsync(filePath: string): Promise { const rootPath = await this.getRootPathAsync(); @@ -309,6 +316,7 @@ export default class GitClient extends Client { { cwd: rootPath } ) ).stdout.trim() !== ''; + // File is considered ignored if: // - makeShallowCopyAsync() will not copy it to the clone // AND