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] Use Git to pack Git projects #2841

Merged

Conversation

sjchmiela
Copy link
Contributor

@sjchmiela sjchmiela commented Jan 27, 2025

Why

Currently, when eas-cli create a project tarball for EAS Build or Workflows, unless the user has requireCommit: true in eas.json, the project is being packed with a plain makeShallowCopyAsync which copies all the files that are deemed ignored by ignore package and .easignore or .gitignore files.

This is suboptimal for eas workflow:run experience — a developer with a project with Git expects the repository to exist on EAS.

How

This was a big pain.

Previously, we had GitClient which required commit and its subclass, GitNoCommitClient which overrode some functions to allow uncommitted changes. On top of that, GitClient copied project with git clone, while GitNoCommitClient copied it with makeShallowCopyAsync. This meant GitClient's copy would include .git, whereas GitNoCommitClient would not. Moreover, thus, GitClient would adhere to .gitignore and GitNoCommitClient would not — only to .easignore.

This pull request:

  • merges the two Git clients into one with requireCommit option
  • this causes .git directory to exist in copies with requireCommit = false
  • changes how we log changes caused by Git case sensitivity change (we need to handle the case where there is a preexisting dirty tree)
  • after we clone the repository, we delete files that should have been ignored according to .easignore
  • afterwards, we make a shallow copy of all the files over to the clone. This copies live changes to the working tree over to the clean clone. (They may only exist in requireCommit = false situation.)
  • adds better support for .easignore to isFileIgnoredAsync.

As far as I can see the behavior looks like this:

Bez tytułu-2025-01-11-0010

The breaking change in here is that we're going to start adhering to .easignore even if someone has requireCommit = true.

Test Plan

I used easd build:inspect a bunch to verify it works like I expect. I encourage fellow reviewers to do the same.

Copy link

linear bot commented Jan 27, 2025

Copy link

github-actions bot commented Jan 27, 2025

Size Change: -3.95 kB (-0.01%)

Total Size: 53.4 MB

Filename Size Change
./packages/eas-cli/dist/eas-linux-x64.tar.gz 53.4 MB -3.95 kB (-0.01%)

compressed-size-action

Copy link

codecov bot commented Jan 27, 2025

Codecov Report

Attention: Patch coverage is 8.92857% with 51 lines in your changes missing coverage. Please review.

Project coverage is 52.87%. Comparing base (b31ddee) to head (e01a830).
Report is 25 commits behind head on main.

Files with missing lines Patch % Lines
packages/eas-cli/src/vcs/clients/git.ts 4.26% 39 Missing and 6 partials ⚠️
packages/eas-cli/src/commands/build/internal.ts 33.34% 1 Missing and 1 partial ⚠️
packages/eas-cli/src/commands/submit/internal.ts 33.34% 1 Missing and 1 partial ⚠️
...ackages/eas-cli/src/commands/project/onboarding.ts 0.00% 1 Missing ⚠️
packages/eas-cli/src/vcs/index.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2841      +/-   ##
==========================================
+ Coverage   52.62%   52.87%   +0.26%     
==========================================
  Files         584      583       -1     
  Lines       22638    22647       +9     
  Branches     4707     4715       +8     
==========================================
+ Hits        11910    11973      +63     
+ Misses       9800     9741      -59     
- Partials      928      933       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sjchmiela sjchmiela force-pushed the stanley/eng-14846-pack-projects-with-git-in-no-commit-mode branch from e250482 to d3e8dfb Compare January 27, 2025 16:34
Copy link

✅ Thank you for adding the changelog entry!

@sjchmiela sjchmiela marked this pull request as ready for review January 28, 2025 15:57
Copy link

Subscribed to pull request

File Patterns Mentions
**/* @szdziedzic, @khamilowicz, @radoslawkrzemien

Generated by CodeMention

Comment on lines +456 to +458
if (
uncommitedChangesAfterCaseSensitivityChange !== uncommittedChangesBeforeCaseSensitivityChange
) {
Copy link
Member

Choose a reason for hiding this comment

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

what is the format of these 2? is there a chance that git will return files in different order causing us to enter this if statement even if nothing changed? maybe we should operate on sets here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I assumed there is no chance that Git would return files in different order.

// that were marked as changed after the case sensitivity change.
const uncommittedChangesBeforeCaseSensitivityChange = await gitStatusAsync({
showUntracked: true,
cwd,
Copy link
Member

Choose a reason for hiding this comment

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

we are using rootPath as cwd for it here, but previously we used this.maybeCwdOverride

does this change matter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

rootPath is supposed to be root of the Git repository and should take maybeCwdOverride into consideration:

Zrzut ekranu 2025-01-30 o 20 01 44

Copy link
Contributor

@radoslawkrzemien radoslawkrzemien left a comment

Choose a reason for hiding this comment

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

I think it looks good, but I'm not too familiar with this part of the codebase

@sjchmiela sjchmiela requested a review from szdziedzic February 3, 2025 10:42
Copy link
Member

@szdziedzic szdziedzic left a comment

Choose a reason for hiding this comment

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

looks reasonable

@sjchmiela sjchmiela merged commit 18bf417 into main Feb 4, 2025
11 checks passed
@sjchmiela sjchmiela deleted the stanley/eng-14846-pack-projects-with-git-in-no-commit-mode branch February 4, 2025 09:13
szdziedzic added a commit that referenced this pull request Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants