Skip to content

Instantly share code, notes, and snippets.

@mathebox
Last active January 9, 2018 10:15

Revisions

  1. mathebox revised this gist Jan 9, 2018. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions labels.txt
    Original file line number Diff line number Diff line change
    @@ -15,3 +15,6 @@ bug,c5def5
    blocked,cccccc
    discussion,c2e0c6
    question,c2e0c6
    good first issue,777777
    PR: ready for merge,006b75
    PR: wip,bfdadc
  2. mathebox revised this gist Oct 12, 2016. No changes.
  3. mathebox revised this gist Oct 12, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gh-labels.sh
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@ REPO_USER=$(echo "$REPO" | cut -f1 -d /)
    REPO_NAME=$(echo "$REPO" | cut -f2 -d /)

    echo "=> Delete existing labels"
    LABELS_RESPONSE=$(curl -s --user "$USER:$PASS" --include --request GET "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels")
    LABELS_RESPONSE=$(curl -s --user "$USER:$PASS" --request GET "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels")
    LABELS=($(echo $LABELS_RESPONSE | tr '"' '\n' | grep -e 'https://api.github.com/'))
    for label in "${LABELS[@]}"
    do
  4. mathebox created this gist Oct 12, 2016.
    35 changes: 35 additions & 0 deletions gh-labels.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    #!/bin/bash

    echo -n "GitHub username: "
    read USER

    echo -n "GitHub password or token: "
    read -s PASS

    echo ""
    echo -n "GitHub Repo (e.g. foo/bar): "
    read REPO

    REPO_USER=$(echo "$REPO" | cut -f1 -d /)
    REPO_NAME=$(echo "$REPO" | cut -f2 -d /)

    echo "=> Delete existing labels"
    LABELS_RESPONSE=$(curl -s --user "$USER:$PASS" --include --request GET "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels")
    LABELS=($(echo $LABELS_RESPONSE | tr '"' '\n' | grep -e 'https://api.github.com/'))
    for label in "${LABELS[@]}"
    do
    curl -s --user "$USER:$PASS" --request DELETE "${label}"
    done

    echo "=> Create new labels"
    while read -r line || [[ -n "$line" ]]; do
    if [ ! -z "${line}" ]; then
    label_name=$(echo "$line" | cut -f1 -d ,)
    label_color=$(echo "$line" | cut -f2 -d ,)
    echo " - Create label '$label_name' with color #$label_color"
    data='{"name":"'$label_name'","color":"'$label_color'"}"'
    curl -s --user "$USER:$PASS" --request POST --data "$data" "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels" > /dev/null
    fi
    done < "$1"

    echo "=> Done"
    17 changes: 17 additions & 0 deletions labels.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    P0: critical,e11d21
    P1: urgent,f7c6c7
    P2: required,eb6420
    P3: important,fad8c7
    P4: nice to have,fef2c0
    design,c5def5
    feature,c5def5
    docs,c5def5
    infrastructure,c5def5
    refactoring,c5def5
    toolkit,c5def5
    new component,c5def5
    performance,c5def5
    bug,c5def5
    blocked,cccccc
    discussion,c2e0c6
    question,c2e0c6