Created
December 20, 2016 00:31
-
-
Save jacks0n/247e76e0ba1f7f1058eb543d9bc0f2ba to your computer and use it in GitHub Desktop.
Tampermonkey / Greasemonkey script to fill the GitHub PR review summary based on the resolution chosen.
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
// ==UserScript== | |
// @name Auto-fill GitHub PR Review Summary | |
// @namespace http://jacksonc.com/ | |
// @version 0.1 | |
// @description Fill the GitHub PR review summary based on the resolution chosen. | |
// @author Jackson Cooper <jackson@jacksonc.com> | |
// @match https://github.com/*/*/pull/*/files | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
// Map review resolution (radio button value) to review summaries. | |
var resolutionSummaries = { | |
'approve': 'Code approved :shipit:', | |
'reject': 'Code reviewed, a few comments to look at.' | |
}; | |
// Review summary `<textarea>`. | |
var reviewSummaryTextArea = document.querySelector('#pull_request_review_body'); | |
// Add a `click` handler for the review summary radio buttons. | |
var reviewRadios = document.querySelectorAll('[type=radio][name^=pull_request_review]'); | |
Array.prototype.map.call(reviewRadios, function(reviewRadio) { | |
reviewRadio.addEventListener('click', function(event) { | |
var radioValue = event.currentTarget.value; | |
if (radioValue in resolutionSummaries) { | |
reviewSummaryTextArea.value = resolutionSummaries[radioValue]; | |
} | |
}); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment