Skip to content

Instantly share code, notes, and snippets.

@adamchainz
Last active June 1, 2017 13:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamchainz/86c088a2a3ccf524e81ecc39091cc1ed to your computer and use it in GitHub Desktop.
Save adamchainz/86c088a2a3ccf524e81ecc39091cc1ed to your computer and use it in GitHub Desktop.
GitHub Squash and Merge PR fixer
// ==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