Skip to content

Commit

Permalink
fix: prevent local changes from breaking compare (#129)
Browse files Browse the repository at this point in the history
## Details

When external storage is used and there are local changes, the git CLI fails to execute `git stash pop` because `git stash` was never executed. This change uses a boolean to make sure we only pop if we stashed. This should fix lightning-components perf runs which are currently failing with `Error: No stash found`.

## Does this PR introduce a breaking change?

* [ ] Yes
* [x] No
  • Loading branch information
zerious authored and diervo committed Nov 2, 2018
1 parent 1f80e45 commit 1879ef3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/best-cli/src/run_compare.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export async function runCompare(globalConfig, configs, outputStream) {

let baseCommit = compareStats[0] || 'master';
let compareCommit = compareStats[1] || (gitLocalChanges ? 'local' : 'current');
let stashedLocalChanges = false;

if (compareStats.length > 2) {
throw new Error('Cannot compare more than 2 commits.');
Expand Down Expand Up @@ -56,6 +57,7 @@ export async function runCompare(globalConfig, configs, outputStream) {
storageProvider.initialize({ rootDir });
if (gitLocalChanges) {
await gitCLI.stash({ '--include-untracked': true });
stashedLocalChanges = true;
}

// Run base commit.
Expand All @@ -67,7 +69,7 @@ export async function runCompare(globalConfig, configs, outputStream) {
if (compareCommit === 'local') {
preRunMessager.print(`\n Running best for local changes \n`, outputStream);
await gitCLI.checkout(initialBranch);
if (gitLocalChanges) {
if (stashedLocalChanges) {
await gitCLI.stash({ pop: true });
}
} else {
Expand All @@ -94,7 +96,7 @@ export async function runCompare(globalConfig, configs, outputStream) {
} finally {
// Return local files to their initial state no matter what happens.
await gitCLI.checkout(initialBranch);
if (gitLocalChanges && (compareCommit !== 'local')) {
if (stashedLocalChanges) {
await gitCLI.stash({ pop: true });
}
}
Expand Down

0 comments on commit 1879ef3

Please sign in to comment.