Skip to content

Instantly share code, notes, and snippets.

@mourner
Last active December 17, 2015 02:49
Show Gist options
  • Select an option

  • Save mourner/5539259 to your computer and use it in GitHub Desktop.

Select an option

Save mourner/5539259 to your computer and use it in GitHub Desktop.
A bookmarklet for generating changelog lines from GitHub pull request and commit pages.

A bookmarklet for generating changelog lines from GitHub pull request and commit pages (including links to all mentioned issues and a link to the author in case of pull request) — saves a lot of time managing the changelog. Just save as a bookmark, click while you're on a pull request page and copy the text.

Doesn't include the pull title as I prefer to write description in my own words, but the bookmarklet can be customized quite easily. Also, doesn't include author name on commit pages (as they're usually commited by me). Example generated string:

(by [@kristerkari](https://github.com/kristerkari)). [#1607](https://github.com/Leaflet/Leaflet/issues/1607) [#1288](https://github.com/Leaflet/Leaflet/issues/1288)
javascript: (function() {
var input = document.createElement('input');
input.type = 'text';
input.style.width = '100%';
var issues = Array.prototype.map.call(document.querySelectorAll('.issue-link'), function(link) {
return '[' + link.innerHTML + '](' + link.href + ')';
});
var url = window.location.href,
paths = url.split('/'),
pull = paths[5] === 'pull' ? '[#' + paths[paths.length - 1] + '](' + url + ')' : null,
authorLink = document.querySelector('.js-discussion .author') || document.querySelector('.authorship a');
issues = (authorLink ? [pull] : []).concat(issues).filter(function(issue, i, issues) {
return issues.lastIndexOf(issue) === i;
});
var text = authorLink ? ' (by [@' + authorLink.innerHTML + '](' + authorLink.href + ')). ' : '. ';
text += issues.join(' ');
input.value = text;
(document.querySelector('.js-issue-title') || document.querySelector('.commit-title')).appendChild(input);
input.focus();
input.select();
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment