Skip to content

Instantly share code, notes, and snippets.

@marchershey
Forked from Isaddo/import-github-labels.js
Last active April 6, 2020 13:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marchershey/490fafe634bbf57161116c2ec82afc6c to your computer and use it in GitHub Desktop.
Save marchershey/490fafe634bbf57161116c2ec82afc6c to your computer and use it in GitHub Desktop.
import github labels via console command
[
{
"name": "-priority:critical",
"description": "An issue with critical priority",
"color": "ee0701"
},
{
"name": "-priority:high",
"description": "An issue with high priority",
"color": "f7f700"
},
{
"name": "-scope:bug",
"description": "Issues related to bugs or errors",
"color": "ee0701"
},
{
"name": "-scope:performance",
"description": "Issues related to the performance of the app",
"color": "7add90"
},
{
"name": "-scope:question",
"description": "Issues related to general question about the app",
"color": "9eaeff"
},
{
"name": "-scope:refactoring",
"description": "Changes in the way the code works internally without changing the output produced",
"color": "ffc69e"
},
{
"name": "-scope:request",
"description": "Issues related to requests of an improvement/enhancement or new feature",
"color": "b0e3fc"
},
{
"name": "-scope:security",
"description": "Issues related to vulnerabilities or the security of the app",
"color": "f9d57a"
},
{
"name": "abandoned",
"description": "The issue has been abandoned per stated in the comments",
"color": "eeeeee"
},
{
"name": "blocked",
"description": "The issue has been blocked or held due to outside our control.",
"color": "eeeeee"
},
{
"name": "completed",
"description": "The issue/feature has been completed and shipped",
"color": "32c955"
},
{
"name": "confirmed",
"description": "The issue was reviewed and has been confirm to have the problem stated and a PR should be created",
"color": "f4c722"
},
{
"name": "duplicate",
"description": "The issues has already been addressed and/or resolved or is awaiting resolution.",
"color": "eeeeee"
},
{
"name": "inprogress",
"description": "The issue/new feature is currently being resolved/added",
"color": "f4c722"
},
{
"name": "investigating",
"description": "The issue is being investigated",
"color": "eeeeee"
},
{
"name": "nmi",
"description": "The issue needs more info from the user (nmi = needs more info)",
"color": "eeeeee"
},
{
"name": "notabug",
"description": "The issue is not a bug as reported or not reproducible",
"color": "eeeeee"
},
{
"name": "onhold",
"description": "The issue/new feature has been put on hold per stated in the comments",
"color": "eeeeee"
},
{
"name": "stale",
"description": "The issue is old and hasn't had activity in a while",
"color": "eeeeee"
},
{
"name": "wontfix",
"description": "The issue will not be fixed or otherwise handled",
"color": "eeeeee"
}
].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( '.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( '.js-edit-label-cancel ~ .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 )
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment