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

Log dirty files in non-interactive when bailing #2288

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -8,6 +8,8 @@ This is the log of notable changes to EAS CLI and related packages.

### 🎉 New features

- Print uncommitted files in non-interactive mode if they fail the execution. ([#2288](https://github.com/expo/eas-cli/pull/2288) by [@sjchmiela](https://github.com/sjchmiela))

### 🐛 Bug fixes

- Fix expo-updates package version detection for canaries. ([#2243](https://github.com/expo/eas-cli/pull/2243) by [@wschurman](https://github.com/wschurman))
Expand Down
2 changes: 1 addition & 1 deletion packages/eas-cli/src/build/configure.ts
Expand Up @@ -40,7 +40,7 @@ async function configureAsync({
nonInteractive,
vcsClient,
}: ConfigureParams): Promise<void> {
await maybeBailOnRepoStatusAsync(vcsClient);
await maybeBailOnRepoStatusAsync(vcsClient, nonInteractive);

await createEasJsonAsync(projectDir, vcsClient);

Expand Down
13 changes: 12 additions & 1 deletion packages/eas-cli/src/build/utils/repository.ts
Expand Up @@ -12,7 +12,10 @@ import { getTmpDirectory } from '../../utils/paths';
import { endTimer, formatMilliseconds, startTimer } from '../../utils/timer';
import { Client } from '../../vcs/vcs';

export async function maybeBailOnRepoStatusAsync(vcsClient: Client): Promise<void> {
export async function maybeBailOnRepoStatusAsync(
vcsClient: Client,
nonInteractive: boolean
): Promise<void> {
if (!(await vcsClient.isCommitRequiredAsync())) {
return;
}
Expand All @@ -28,6 +31,11 @@ export async function maybeBailOnRepoStatusAsync(vcsClient: Client): Promise<voi
});

if (!answer) {
if (nonInteractive) {
Log.log('The following files need to be committed:');
await vcsClient.showChangedFilesAsync();
}

throw new Error('Commit all changes. Aborting...');
}
}
Expand All @@ -47,6 +55,9 @@ export async function ensureRepoIsCleanAsync(
)}.`
);
if (nonInteractive) {
Log.log('The following files need to be committed:');
await vcsClient.showChangedFilesAsync();

throw new Error('Commit all changes. Aborting...');
}
const answer = await confirmAsync({
Expand Down
5 changes: 5 additions & 0 deletions packages/eas-cli/src/vcs/clients/git.ts
Expand Up @@ -111,6 +111,11 @@ export default class GitClient extends Client {
return await this.hasUncommittedChangesAsync();
}

public override async showChangedFilesAsync(): Promise<void> {
const gitStatusOutput = await gitStatusAsync({ showUntracked: true });
Log.log(gitStatusOutput);
}

public override async hasUncommittedChangesAsync(): Promise<boolean> {
const changes = await gitStatusAsync({ showUntracked: true });
return changes.length > 0;
Expand Down
3 changes: 3 additions & 0 deletions packages/eas-cli/src/vcs/vcs.ts
Expand Up @@ -51,6 +51,9 @@ export abstract class Client {
// `commitAsync({ commitAllFiles: false })`
public async showDiffAsync(): Promise<void> {}

/** (optional) print list of changed files */
public async showChangedFilesAsync(): Promise<void> {}

// (optional) returns hash of the last commit
// used for metadata - implementation can be safely skipped
public async getCommitHashAsync(): Promise<string | undefined> {
Expand Down