Skip to content

Commit

Permalink
Merge 9b6612f into 8f358da
Browse files Browse the repository at this point in the history
  • Loading branch information
dubzzz authored Nov 4, 2020
2 parents 8f358da + 9b6612f commit d704170
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions perf/benchmark.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ const formatRatio = (ratio) => {
};

async function run() {
let stashedId = null;
let stashedMessage = null;
if (!argv['allow-local-changes']) {
// Check that there is no local changes
const { err: gitDiffErr } = await execAsync('git diff-index --quiet HEAD --');
Expand All @@ -127,16 +127,16 @@ async function run() {
}
} else {
// Stash local changes
const localStashId = `bench-${Math.random().toString(16).substr(2)}`;
console.info(`${chalk.cyan('INFO ')} Stashing local changes if any under stash name ${localStashId}`);
const localStashMessage = `bench-${Math.random().toString(16).substr(2)}`;
console.info(`${chalk.cyan('INFO ')} Stashing local changes if any under stash name ${localStashMessage}`);
const { stdout: stashCountBefore } = await execAsync('git stash list | wc -l');
const { err: gitStashErr } = await execAsync(`git stash push -m "${localStashId}"`);
const { err: gitStashErr } = await execAsync(`git stash push -m "${localStashMessage}"`);
if (gitStashErr && gitStashErr.code) {
console.info(`${chalk.yellow('WARN ')} Something went wrong when trying to stash your changes`);
}
const { stdout: stashCountAfter } = await execAsync('git stash list | wc -l');
if (stashCountBefore != null && stashCountAfter != null && String(stashCountAfter) !== String(stashCountBefore)) {
stashedId = localStashId;
stashedMessage = localStashMessage;
console.info(`${chalk.cyan('INFO ')} Your local changes have been stashed`);
} else {
console.info(`${chalk.cyan('INFO ')} No local changes to stash`);
Expand Down Expand Up @@ -188,10 +188,10 @@ async function run() {
// Go back to the original branch
await execFileAsync('git', ['checkout', currentBranch]);

if (stashedId !== null) {
if (stashedMessage !== null) {
// Applying stash
console.info(`${chalk.cyan('INFO ')} Un-Stashing local changes stored under stash ${stashedId}`);
const { err: gitStashErr } = await execAsync(`git stash pop stash^{/${stashedId}}`);
console.info(`${chalk.cyan('INFO ')} Un-Stashing local changes stored under stash ${stashedMessage}`);
const { err: gitStashErr } = await execAsync(`git stash apply stash^{/${stashedMessage}}`); // pop does not handle messages
if (gitStashErr && gitStashErr.code) {
console.info(`${chalk.yellow('WARN ')} Something went wrong when trying to un-stash your changes`);
}
Expand Down

0 comments on commit d704170

Please sign in to comment.