Last active
February 20, 2018 14:38
-
-
Save ErikBrendel/7013117ff8fafb1b086ae42a1a7257ea to your computer and use it in GitHub Desktop.
[BitBucket] Show the total changes of a diff / pullrequest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//this little js snippet tells you the total amount of additions & deletions of a bitbucket PR or a branch comparison. | |
//Just open up the site, open up your browser console (Ctrl+Shift+K on Firefox) and paste and execute this code. | |
//It uses XPath to query all span-elements with the right class | |
function xpathSum(path) { | |
var iter = document.evaluate(path, document, null, XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null); | |
var sum = 0; | |
var thisNode = iter.iterateNext(); | |
while (thisNode) { | |
var value = parseInt(thisNode.textContent); | |
if (!isNaN(value)) { | |
sum += value; | |
} | |
thisNode = iter.iterateNext(); | |
} | |
return sum; | |
} | |
var additions = xpathSum('//span[@class=\"lines-added\"]'); | |
var removes = xpathSum('//span[@class=\"lines-removed\"]'); | |
alert(additions + " / " + removes + " = " + (additions + removes) + " (total of " + (additions - removes) + ")"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment