-
-
Save jpike88/9bd4139b5c7bd15492f3db43a980e908 to your computer and use it in GitHub Desktop.
import github labels via console command
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
/* | |
Go on your labels page (https://github.com/user/repo/labels) | |
Edit the following label array | |
or | |
Use this snippet to export github labels (https://gist.github.com/MoOx/93c2853fee760f42d97f) | |
and replace it | |
Paste this script in your console | |
Press Enter!! | |
*/ | |
[ | |
{ | |
"name": "Needs Discussion", | |
"color": "006b75" | |
}, | |
{ | |
"name": "Rejected: Duplicate", | |
"color": "cccccc" | |
}, | |
{ | |
"name": "Rejected: Unable To Reproduce", | |
"color": "cccccc" | |
}, | |
{ | |
"name": "Type: Bug", | |
"color": "b60205" | |
}, | |
{ | |
"name": "Type: Chore", | |
"color": "fbca04" | |
}, | |
{ | |
"name": "Type: Enhancement", | |
"color": "0e8a16" | |
} | |
].forEach(function(label) { | |
addLabel(label) | |
}) | |
function updateLabel (label) { | |
var flag = false; | |
[].slice.call(document.querySelectorAll(".labels-list-item")) | |
.forEach(function(element) { | |
if (element.querySelector('.label-link').textContent.trim() === label.name) { | |
flag = true | |
element.querySelector('.js-edit-label').click() | |
element.querySelector('.label-edit-name').value = label.name | |
element.querySelector('.color-editor-input').value = '#' + label.color | |
element.querySelector('.new-label-actions .btn-primary').click() | |
} | |
}) | |
return flag | |
} | |
function addNewLabel (label) { | |
document.querySelector('.new-label input#label-').value = label.name | |
document.querySelector('.new-label input#edit-label-color-new').value = '#' + label.color | |
document.querySelector('.new-label-actions .btn-primary').click() | |
} | |
function addLabel (label) { | |
if (!updateLabel(label)) addNewLabel(label) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment