brainhackorg / global2022

Github repo for the brainhack 2022 website and event
https://brainhack.org/global2022/
MIT License
3 stars 6 forks source link

import issue labels from 2021 #6

Closed Remi-Gau closed 1 year ago

Remi-Gau commented 2 years ago

get all labels from last year:

curl  https://api.github.com/repos/brainhackorg/global2021/labels
Remi-Gau commented 2 years ago
labels_export = [
  {
    "name": "Flag: desc wanted",
    "description": "This issue needs more context",
    "color": "d93f0b"
  }
]

labels_export.forEach(function(label) {
  addLabel(label)
})

function updateLabel (label) {
  var flag = false;
  [].slice.call(document.querySelectorAll(".js-labels-list-item"))
  .forEach(function(element) {
    if (element.querySelector('.js-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-color-input').value = '#' + label.color
      element.querySelector('.js-new-label-description-input').value = label.description
      element.querySelector('.js-edit-label-cancel ~ .btn-primary').disabled = false
      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-color-input').value = '#' + label.color
  document.querySelector('.js-new-label-description-input').value = label.description
  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)
}
Remi-Gau commented 1 year ago

This did not work. Need to reimport.

Remi-Gau commented 1 year ago

need to use query parameters to grab all labels:

curl  "https://api.github.com/repos/brainhackorg/global2021/labels?per_page=100&page=1"

https://docs.github.com/en/rest/issues/labels#list-labels-for-a-repository