Skip to content

Commit

Permalink
Log dirty files in non-interactive when bailing (#2288)
Browse files Browse the repository at this point in the history
  • Loading branch information
sjchmiela committed Mar 18, 2024
1 parent 7e2aae3 commit 32848f6
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
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

### 🧹 Chores
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

0 comments on commit 32848f6

Please sign in to comment.