Skip to content

Instantly share code, notes, and snippets.

@rescribet
Last active December 19, 2018 09:24
Show Gist options
  • Save rescribet/8723c2e6aa6326352ac3d1f9f3d37810 to your computer and use it in GitHub Desktop.
Save rescribet/8723c2e6aa6326352ac3d1f9f3d37810 to your computer and use it in GitHub Desktop.
Snippet to count the amount of lines added/removed in bitbucket pull requests
(function countLines() {
let addedArr = [];
let removedArr = [];
document.querySelectorAll('#commit-files-summary .lines-added').forEach((n) => { addedArr.push(n.innerText) });
document.querySelectorAll('#commit-files-summary .lines-removed').forEach((n) => { removedArr.push(n.innerText) });
let added = addedArr
.map((n) => parseInt(n))
.reduce((a, b) => { return b + a } );
let removed = removedArr
.map((n) => parseInt(n))
.reduce((a, b) => { return b + a } );
return added + removed;
}())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment