From 1d671c69a385e6b40090bee907ddb7b3268efe21 Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Thu, 8 Nov 2018 19:17:56 -0800 Subject: [PATCH] chore(bisect): properly output bisect ranges + output styling (#3523) A bit more colors ![image](https://user-images.githubusercontent.com/746130/48240497-d1845180-e387-11e8-9bac-dcde29ef967e.png) --- utils/bisect.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/utils/bisect.js b/utils/bisect.js index 6b4f2c695487e..c20ecee9ad488 100755 --- a/utils/bisect.js +++ b/utils/bisect.js @@ -91,14 +91,23 @@ if (!fs.existsSync(scriptPath)) { outcome = COLOR_GREEN + 'GOOD' + COLOR_RESET; } const span = Math.abs(good - bad); - console.log(`- ${COLOR_YELLOW}r${revision}${COLOR_RESET} was ${outcome}. Bisecting [${good}, ${bad}] - ${COLOR_YELLOW}${span}${COLOR_RESET} revisions and ${COLOR_YELLOW}~${span.toString(2).length}${COLOR_RESET} iterations`); + let fromText = ''; + let toText = ''; + if (good < bad) { + fromText = COLOR_GREEN + good + COLOR_RESET; + toText = COLOR_RED + bad + COLOR_RESET; + } else { + fromText = COLOR_RED + bad + COLOR_RESET; + toText = COLOR_GREEN + good + COLOR_RESET; + } + console.log(`- ${COLOR_YELLOW}r${revision}${COLOR_RESET} was ${outcome}. Bisecting [${fromText}, ${toText}] - ${COLOR_YELLOW}${span}${COLOR_RESET} revisions and ${COLOR_YELLOW}~${span.toString(2).length}${COLOR_RESET} iterations`); } - const [goodSha, badSha] = await Promise.all([ - revisionToSha(good), - revisionToSha(bad), + const [fromSha, toSha] = await Promise.all([ + revisionToSha(Math.min(good, bad)), + revisionToSha(Math.max(good, bad)), ]); - console.log(`RANGE: https://chromium.googlesource.com/chromium/src/+log/${goodSha}..${badSha}`); + console.log(`RANGE: https://chromium.googlesource.com/chromium/src/+log/${fromSha}..${toSha}`); })(scriptPath, argv.good, argv.bad); function runScript(scriptPath, revisionInfo) {