Last active
June 1, 2017 13:26
-
-
Save adamchainz/86c088a2a3ccf524e81ecc39091cc1ed to your computer and use it in GitHub Desktop.
GitHub Squash and Merge PR fixer
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 GitHub Squash and Merge PR fixer | |
// @namespace https://github.com/ | |
// @version 1.0 | |
// @description try to take over the world! | |
// @author Adam Johnson | |
// @match https://github.com/* | |
// @grant all | |
// ==/UserScript== | |
(function () { | |
'use strict' | |
const strip = function(string) { | |
return string.replace(/^\s+|\s+$/g, '') | |
} | |
const fixCommitInfo = function () { | |
const commitTitle = document.querySelector('input[name=commit_title]'), | |
commitMessage = document.querySelector('textarea[name=commit_message]') | |
console.log('>> fired') | |
if (!commitTitle || !commitMessage) | |
return | |
commitTitle.value = ( | |
strip(document.querySelector('.js-issue-title').textContent) + | |
' (' + | |
document.querySelector('.gh-header-number').textContent + | |
')' | |
) | |
commitMessage.value = ( | |
document.querySelector('textarea[name="pull_request[body]"]').value | |
) | |
} | |
document.addEventListener('DOMContentLoaded', fixCommitInfo) | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment