Skip to content

Instantly share code, notes, and snippets.

@marcomontalbano
Last active March 10, 2020 16:00
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 marcomontalbano/f984e08e0abb864b62e52a1e11f31cb0 to your computer and use it in GitHub Desktop.
Save marcomontalbano/f984e08e0abb864b62e52a1e11f31cb0 to your computer and use it in GitHub Desktop.
Bitbucket Helpers :)
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