Skip to content

Instantly share code, notes, and snippets.

@robyoder
Created December 13, 2019 10:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robyoder/2e439f5bbe229e24482b72ab6754daaf to your computer and use it in GitHub Desktop.
Save robyoder/2e439f5bbe229e24482b72ab6754daaf to your computer and use it in GitHub Desktop.
A quick script to get the overall diff size between the current HEAD and master
const child_process = require("child_process");
const output = child_process.execSync("git diff HEAD master --shortstat", { encoding: "utf8" });
// "6 files changed, 34 insertions(+), 4 deletions(-)"
const matches = output.match(/\s*\d+ files? changed, (\d+)\D+(\d+)?/)
// console.log(matches);
const sum = matches ? parseInt(matches[1]) + (parseInt(matches[2]) || 0) : 0;
console.log("\x1b[0m" + sum);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment