Skip to content

Instantly share code, notes, and snippets.

@onury
Forked from Isaddo/import-github-labels.js
Last active November 14, 2017 22:30
Show Gist options
  • Save onury/ce8b8c92def8085a63e977d2e7b6a565 to your computer and use it in GitHub Desktop.
Save onury/ce8b8c92def8085a63e977d2e7b6a565 to your computer and use it in GitHub Desktop.

Revisions

  1. onury revised this gist Nov 14, 2017. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion import-github-labels.js
    Original file line number Diff line number Diff line change
    @@ -59,6 +59,10 @@
    "name": "todo",
    "color": "fbca04"
    },
    {
    "name": "documentation",
    "color": "7f7eac"
    },
    {
    "name": "feature",
    "color": "1d76db"
    @@ -93,7 +97,7 @@
    },
    {
    "name": "wontfix",
    "color": "ffffff"
    "color": "f1f5f4"
    },
    {
    "name": "gui",
  2. onury revised this gist Nov 14, 2017. 1 changed file with 44 additions and 4 deletions.
    48 changes: 44 additions & 4 deletions import-github-labels.js
    Original file line number Diff line number Diff line change
    @@ -47,6 +47,10 @@
    "name": "stability",
    "color": "d93f0b"
    },
    {
    "name": "security",
    "color": "5f688f"
    },
    {
    "name": "warning",
    "color": "fbca04"
    @@ -69,19 +73,19 @@
    },
    {
    "name": "duplicate",
    "color": "D3E0ED"
    "color": "d3e0ed"
    },
    {
    "name": "enhancement",
    "color": "3d91c8"
    },
    {
    "name": "help wanted",
    "color": "128A0C"
    "color": "1c948b"
    },
    {
    "name": "invalid",
    "color": "E0EAF2"
    "color": "e0eaf2"
    },
    {
    "name": "question",
    @@ -93,11 +97,47 @@
    },
    {
    "name": "gui",
    "color": "9C60DF"
    "color": "9c60df"
    },
    {
    "name": "ux",
    "color": "5319e7"
    },
    {
    "name": "windows",
    "color": "1caed7"
    },
    {
    "name": "mac",
    "color": "39b36f"
    },
    {
    "name": "chrome",
    "color": "4eaa65"
    },
    {
    "name": "safari",
    "color": "4e99aa"
    },
    {
    "name": "firefox",
    "color": "b87a69"
    },
    {
    "name": "edge",
    "color": "4e99dc"
    },
    {
    "name": "ie",
    "color": "4e90ca"
    },
    {
    "name": "simulator",
    "color": "64ddea"
    },
    {
    "name": "device",
    "color": "f29f1a"
    }
    ].forEach(function(label) {
    addLabel(label)
  3. onury revised this gist Nov 14, 2017. 1 changed file with 87 additions and 11 deletions.
    98 changes: 87 additions & 11 deletions import-github-labels.js
    Original file line number Diff line number Diff line change
    @@ -12,16 +12,92 @@

    [
    {
    "name": "bugfix",
    "color": "eb6420"
    "name": "⬇",
    "color": "e8bc74"
    },
    {
    "name": "⬆",
    "color": "d6e900"
    },
    {
    "name": "★",
    "color": "eeef00"
    },
    {
    "name": "dev",
    "color": "5c89a6"
    },
    {
    "name": "revision",
    "color": "e2674a"
    },
    {
    "name": "critical",
    "color": "d64068"
    },
    {
    "name": "vendor-bug",
    "color": "b60205"
    },
    {
    "name": "performance",
    "color": "5d78f4"
    },
    {
    "name": "stability",
    "color": "d93f0b"
    },
    {
    "name": "warning",
    "color": "fbca04"
    },
    {
    "name": "todo",
    "color": "fbca04"
    },
    {
    "name": "feature",
    "color": "0e8a16"
    "color": "1d76db"
    },
    {
    "name": "typescript",
    "color": "aa6fce"
    },
    {
    "name": "bug",
    "color": "ee0701"
    },
    {
    "name": "duplicate",
    "color": "D3E0ED"
    },
    {
    "name": "enhancement",
    "color": "3d91c8"
    },
    {
    "name": "help wanted",
    "color": "128A0C"
    },
    {
    "name": "invalid",
    "color": "E0EAF2"
    },
    {
    "name": "question",
    "color": "cc317c"
    },
    {
    "name": "wontfix",
    "color": "ffffff"
    },
    {
    "name": "gui",
    "color": "9C60DF"
    },
    {
    "name": "hotfix",
    "color": "e11d21"
    "name": "ux",
    "color": "5319e7"
    }
    ].forEach(function(label) {
    addLabel(label)
    @@ -34,18 +110,18 @@ function updateLabel (label) {
    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()
    element.querySelector('.js-new-label-name-input').value = label.name
    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('.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()
    document.querySelector('.js-new-label-name-input').value = label.name
    document.querySelector('.js-new-label-color-input').value = '#' + label.color
    document.querySelector('.js-details-target ~ .btn-primary').click()
    }

    function addLabel (label) {
  4. @Isaddo Isaddo revised this gist May 6, 2016. No changes.
  5. @Isaddo Isaddo renamed this gist May 6, 2016. 1 changed file with 13 additions and 9 deletions.
    22 changes: 13 additions & 9 deletions add-github-labels.js → import-github-labels.js
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,16 @@
    /*
    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": "pending",
    "color": "bfdadc"
    },
    {
    "name": "waiting",
    "color": "bfd4f2"
    },
    {
    "name": "bugfix",
    "color": "eb6420"
    @@ -18,7 +22,7 @@
    {
    "name": "hotfix",
    "color": "e11d21"
    },
    }
    ].forEach(function(label) {
    addLabel(label)
    })
  6. @Isaddo Isaddo created this gist May 6, 2016.
    49 changes: 49 additions & 0 deletions add-github-labels.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,49 @@
    [
    {
    "name": "pending",
    "color": "bfdadc"
    },
    {
    "name": "waiting",
    "color": "bfd4f2"
    },
    {
    "name": "bugfix",
    "color": "eb6420"
    },
    {
    "name": "feature",
    "color": "0e8a16"
    },
    {
    "name": "hotfix",
    "color": "e11d21"
    },
    ].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)
    }