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] Skip makeShallowCopyAsync if requireCommit #2885

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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,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
13 changes: 9 additions & 4 deletions packages/eas-cli/src/vcs/clients/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,15 @@ export default class GitClient extends Client {
await setGitCaseSensitivityAsync(isCaseSensitive, rootPath);
}

// After we create the shallow Git copy, we copy the files
// again. This way we include the changed and untracked files
// (`git clone` only copies the committed changes).
await makeShallowCopyAsync(rootPath, destinationPath);
if (!this.requireCommit) {
// After we create the shallow Git copy, we copy the files
// again. This way we include the changed and untracked files
// (`git clone` only copies the committed changes).
//
// We only do this if `requireCommit` is false because `requireCommit: true`
// setups expect no changes in files (e.g. locked files should remain locked).
await makeShallowCopyAsync(rootPath, destinationPath);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if I understand. Why should we not do git clone when requireCommit: true is present?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It comes down to secrets and locked / unlocked repository (if using git-crypt).

Looks like requireCommit flag wasn't being used just as a "it's a good practice to always commit your changes", but more like "make tarball look exactly like a cloned repository at this commit would". In the former understanding it's not a big deal if we copy unlocked files to the tarball because the user did make a commit. In the latter understanding requireCommit is more like makeTarballResembleClone or something.

See discussion in here and how it broke Brent's setup with encrypted files (he was using requireCommit: true and was expecting encrypted files to be locked and worktree clean).

}
}

public override async getCommitHashAsync(): Promise<string | undefined> {
Expand Down