Skip to content

Instantly share code, notes, and snippets.

@dalepgrant
Last active May 3, 2022 08:41
Show Gist options
  • Save dalepgrant/df2e88583f49f16fc7abd7696203228b to your computer and use it in GitHub Desktop.
Save dalepgrant/df2e88583f49f16fc7abd7696203228b to your computer and use it in GitHub Desktop.
Update standard Github labels with emoji and add Code& defaults
[
{
"name": "automerge",
"oldName": "automerge",
"description": "Automatically merge PRs with this label",
"color": "2db767"
},
{
"name": "documentation πŸ“–",
"oldName": "documentation",
"description": null,
"color": "0075ca"
},
{
"name": "seo 🌱",
"oldName": "seo",
"description": "Specifically relates to SEO improvements",
"color": "f9e795"
},
{
"name": "blocker πŸ™…β€β™‚οΈ",
"oldName": "blocker",
"description": "This blocks another issue from being actioned",
"color": "b60205"
},
{
"name": "trivial πŸ€·β€β™‚οΈ",
"oldName": "trivial",
"description": null,
"color": "bfdadc"
},
{
"name": "quick win πŸ†",
"oldName": "quick win",
"description": null,
"color": "a4ace8"
},
{
"name": "discuss β˜•",
"oldName": "discuss",
"description": null,
"color": "c5def5"
},
{
"name": "bug πŸ›",
"oldName": "bug",
"description": "Something isn't working",
"color": "d73a4a"
},
{
"name": "dependencies πŸ€“",
"oldName": "dependencies",
"description": "Pull requests that update a dependency file",
"color": "0366d6"
},
{
"name": "duplicate πŸ‘«",
"oldName": "duplicate",
"description": "This issue or pull request already exists",
"color": "cfd3d7"
},
{
"name": "enhancement 🎁",
"oldName": "enhancement",
"description": "New feature or request",
"color": "a2eeef"
},
{
"name": "help wanted πŸ™‹β€β™‚οΈ",
"oldName": "help wanted",
"description": "Extra attention is needed",
"color": "008672"
},
{
"name": "P1 ⚑",
"oldName": "P1",
"description": "High priority",
"color": "e11d21"
},
{
"name": "P2 πŸƒβ€β™€οΈ",
"oldName": "P2",
"description": "Standard priority",
"color": "eb6420"
},
{
"name": "P3 πŸ–οΈ",
"oldName": "P3",
"description": "Low Priority",
"color": "fbca04"
},
{
"name": "question πŸ€”",
"oldName": "question",
"description": "Further information is requested",
"color": "d876e3"
},
{
"name": "wontfix ⚰️",
"oldName": "wontfix",
"description": "This will not be worked on",
"color": "ffffff"
},
{
"name": "code standards πŸ’…",
"oldName": "code standards",
"description": "This could probably be cleaner",
"color": "D9C483"
}
].forEach(function(label) {
addLabel(label)
})
function updateLabel (label) {
var flag = false;
[].slice.call(document.querySelectorAll(".js-labels-list-item"))
.forEach(function(element) {
// Remove emoji
let currentName = element.querySelector('.js-new-label-name-input').value
.replace(/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g, '')
.replace(/:.*:/, '')
.trim();
if (currentName === label.oldName) {
flag = true
element.querySelector('.js-edit-label').click()
element.querySelector('.js-new-label-name-input').value = label.name
element.querySelector('.js-new-label-description-input').value = label.description
element.querySelector('.js-new-label-color-input').value = '#' + label.color
element.querySelector('.btn-primary').click()
}
})
return flag
}
function addNewLabel (label) {
document.querySelector('.js-new-label-name-input').value = label.name
document.querySelector('.js-new-label-description-input').value = label.description
document.querySelector('.js-new-label-color-input').value = '#' + label.color
document.querySelector('.js-details-target ~ .btn-primary').disabled = false
document.querySelector('.js-details-target ~ .btn-primary').click()
}
function addLabel (label) {
if (!updateLabel(label)) addNewLabel(label)
}
@dalepgrant
Copy link
Author

Copy/paste this into browser console when viewing a repo's label page

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment