Last active
March 10, 2020 16:00
-
-
Save marcomontalbano/f984e08e0abb864b62e52a1e11f31cb0 to your computer and use it in GitHub Desktop.
Bitbucket Helpers :)
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
function getCommits(includeMerge = false) { | |
return Array.from(document.querySelectorAll(`.commits-table tbody tr${ includeMerge ? '' : ':not(.merge)' }`)).map(e => ({ | |
...(JSON.parse(e.dataset.commitJson)), | |
isMerge: e.classList.contains('merge') | |
})) | |
} | |
function getBranches() { | |
return Array.from(document.querySelectorAll('#branch-list tbody tr:not(.base-branch)')).map(e => ({ | |
name: e.querySelector('.branch-name-column').innerText, | |
behind: parseInt(e.querySelector('.ahead-behind-column .count-graph.behind-graph').innerText) || 0, | |
ahead: parseInt(e.querySelector('.ahead-behind-column .count-graph.ahead-graph').innerText) || 0, | |
updated: e.querySelector('.last-updated-column time').getAttribute('datetime') | |
})) | |
} | |
function getStaleBranches() { | |
return getBranches().filter(b => b.ahead === 0) | |
} | |
// remove all released branches (ahead = 0) | |
console.log(`git push origin :${ getStaleBranches().map(b => b.name).join(' :') }`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment