GitHubFlow PR merge idiot-proofing

Confirmation before common mistakes when merging Pull Requests in github

Tính đến 21-04-2016. Xem phiên bản mới nhất.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

Bạn sẽ cần cài đặt một tiện ích mở rộng như Tampermonkey hoặc Violentmonkey để cài đặt kịch bản này.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         GitHubFlow PR merge idiot-proofing
// @namespace    https://gist.github.com/raveren/f08ba2673a92c582692e1a233621762f
// @version      0.3
// @author       raveren
// @description  Confirmation before common mistakes when merging Pull Requests in github
// @match        https://github.com/*/pull/*
// ==/UserScript==

(function() {
    document.querySelector('.js-merge-branch-action').addEventListener('click', function(e){
        if ( document.querySelector('#commits_tab_counter').innerHTML.trim()!='1'
            && !confirm('More than one commit, you still wanna merge?')) {
            e.preventDefault();
            e.stopPropagation();
            return false;
        }
        
        if ( document.querySelector('.text-pending') && !confirm('Build not complete yet, you still wanna merge?')) {
            e.preventDefault();
            e.stopPropagation();
            return false;
        }
    });
})();