Skip to content

Instantly share code, notes, and snippets.

@donato
Created October 9, 2015 15:47
Show Gist options
  • Save donato/3365592ffea0141e17e1 to your computer and use it in GitHub Desktop.
Save donato/3365592ffea0141e17e1 to your computer and use it in GitHub Desktop.
Delete merged and closed branches from github which don't have recent activity
function deleteBefore(days) {
var ONE_DAY = 1000 * 60 * 60 * 24;
$('.branch-summary:not(.is-deleted)').each(function () {
var $this = $(this);
var datetime = new Date($this.find('time').attr('datetime')).getTime();
var today = (new Date().getTime());
var filter = today - (ONE_DAY * days);
if (datetime < filter) {
if ($this.find('.state').is('.state-merged, .state-closed')) {
$this.find('button.branch-delete').click();
}
}
});
}
@donato
Copy link
Author

donato commented Jul 27, 2016

Github removed jQuery from their site, this is the new version: https://github.com/donato/github-branch-cleaner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment