Skip to content

Instantly share code, notes, and snippets.

@dholdren
Created July 10, 2015 18:11
Show Gist options
  • Save dholdren/5714655686d5f962a488 to your computer and use it in GitHub Desktop.
Save dholdren/5714655686d5f962a488 to your computer and use it in GitHub Desktop.
prevent merge when there's multiple commits in a PR
var num_commits = parseInt($('#commits_tab_counter').text());
var button = $("div.merge-message > button");
if (num_commits > 1) {
console.log("disabling");
button.attr('disabled','disabled');
button.text("Squash those commits!");
div = $("div.merge-message");
div.append("<button class='btn btn-primary' id='enable_merge' style='float:right;' type='button'>Override</button>");
enable_button = $('button#enable_merge');
enable_button.on('click', function() {
console.log("re-enabling button");
button.removeAttr('disabled');
button.text("Merge without squash");
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment