Loading tools/setup-labels +29 −12 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ ## ## $ tools/setup-label wking swc-modular-shell CURL_FLAGS="--silent --fail" if test $# -lt 2 then echo "Missing parameters." Loading @@ -28,8 +30,9 @@ fi OWNER=$1 REPO=$2 GITHUB_URL=https://github.com/${OWNER}/${REPO} LABELS=(getting-started working-in-progress discussion) COLORS=(fbca04 f7c6c7 5319e7) LABELS=(bug defer discussion duplicate enhancement filed-by-newcomer getting-started help-wanted left-as-was suitable-for-newcomer work-in-progress) COLORS=(FF0000 66FF00 0000FF 98FB98 E0115F FFFF00 808000 89CFF0 568203 FCE883 545AA7) LABELS_TO_DELETE=(help%20wanted invalid question wontfix) # Test if repository exists curl -s --head ${GITHUB_URL} | head -n 1 | grep -q "HTTP/1.[01] [23].." Loading @@ -46,22 +49,36 @@ read USERNAME echo "Your GitHub password:" read -s PASSWORD # Delete labels for INDEX in $(seq 0 $((${#LABELS_TO_DELETE[*]} - 1))) do # Try to delete label curl ${CURL_FLAGS} -X DELETE \ -u ${USERNAME}:${PASSWORD} \ "https://api.github.com/repos/${OWNER}/${REPO}/labels/${LABELS_TO_DELETE[${INDEX}]}" > /dev/null done # Create labels for INDEX in $(seq 1 ${#LABELS[*]}) for INDEX in $(seq 0 $((${#LABELS[*]} - 1))) do curl -s -f -X POST \ # Try create new label curl ${CURL_FLAGS} -X POST \ -u ${USERNAME}:${PASSWORD} \ -d "{\"name\":\"${LABELS[${INDEX}]}\",\"color\":\"${COLORS[${INDEX}]}\"}" \ "https://api.github.com/repos/${OWNER}/${REPO}/labels" > /dev/null if test $? -ne 0 then echo "Failed when trying to create the label ${LABELS[${INDEX}]}." echo "Probably the label ${LABELS[${INDEX}]} already exists." echo "Please check at ${GITHUB_URL}/labels or run" echo echo " $ curl -X POST -u ${USERNAME} -d \"{\"name\":\"${LABELS[${INDEX}]}\",\"color\":\"${COLORS[${INDEX}]}\"}\" \"https://api.github.com/repos/${OWNER}/${REPO}/labels\"" echo echo "to get more information of the error. If you find a bug" echo "report it at https://github.com/swcarpentry/lesson-template/." # Try to fix label color curl ${CURL_FLAGS} -X PATCH \ -u ${USERNAME}:${PASSWORD} \ -d "{\"name\":\"${LABELS[${INDEX}]}\",\"color\":\"${COLORS[${INDEX}]}\"}" \ "https://api.github.com/repos/${OWNER}/${REPO}/labels/${LABELS[${INDEX}]}" > /dev/null if test $? -ne 0 then echo "Failed when trying to create and update the label ${LABELS[${INDEX}]}." echo "Please check at ${GITHUB_URL}/labels" echo "" echo "If you find a bug report it at" echo "https://github.com/swcarpentry/lesson-template/." fi fi done Loading
tools/setup-labels +29 −12 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ ## ## $ tools/setup-label wking swc-modular-shell CURL_FLAGS="--silent --fail" if test $# -lt 2 then echo "Missing parameters." Loading @@ -28,8 +30,9 @@ fi OWNER=$1 REPO=$2 GITHUB_URL=https://github.com/${OWNER}/${REPO} LABELS=(getting-started working-in-progress discussion) COLORS=(fbca04 f7c6c7 5319e7) LABELS=(bug defer discussion duplicate enhancement filed-by-newcomer getting-started help-wanted left-as-was suitable-for-newcomer work-in-progress) COLORS=(FF0000 66FF00 0000FF 98FB98 E0115F FFFF00 808000 89CFF0 568203 FCE883 545AA7) LABELS_TO_DELETE=(help%20wanted invalid question wontfix) # Test if repository exists curl -s --head ${GITHUB_URL} | head -n 1 | grep -q "HTTP/1.[01] [23].." Loading @@ -46,22 +49,36 @@ read USERNAME echo "Your GitHub password:" read -s PASSWORD # Delete labels for INDEX in $(seq 0 $((${#LABELS_TO_DELETE[*]} - 1))) do # Try to delete label curl ${CURL_FLAGS} -X DELETE \ -u ${USERNAME}:${PASSWORD} \ "https://api.github.com/repos/${OWNER}/${REPO}/labels/${LABELS_TO_DELETE[${INDEX}]}" > /dev/null done # Create labels for INDEX in $(seq 1 ${#LABELS[*]}) for INDEX in $(seq 0 $((${#LABELS[*]} - 1))) do curl -s -f -X POST \ # Try create new label curl ${CURL_FLAGS} -X POST \ -u ${USERNAME}:${PASSWORD} \ -d "{\"name\":\"${LABELS[${INDEX}]}\",\"color\":\"${COLORS[${INDEX}]}\"}" \ "https://api.github.com/repos/${OWNER}/${REPO}/labels" > /dev/null if test $? -ne 0 then echo "Failed when trying to create the label ${LABELS[${INDEX}]}." echo "Probably the label ${LABELS[${INDEX}]} already exists." echo "Please check at ${GITHUB_URL}/labels or run" echo echo " $ curl -X POST -u ${USERNAME} -d \"{\"name\":\"${LABELS[${INDEX}]}\",\"color\":\"${COLORS[${INDEX}]}\"}\" \"https://api.github.com/repos/${OWNER}/${REPO}/labels\"" echo echo "to get more information of the error. If you find a bug" echo "report it at https://github.com/swcarpentry/lesson-template/." # Try to fix label color curl ${CURL_FLAGS} -X PATCH \ -u ${USERNAME}:${PASSWORD} \ -d "{\"name\":\"${LABELS[${INDEX}]}\",\"color\":\"${COLORS[${INDEX}]}\"}" \ "https://api.github.com/repos/${OWNER}/${REPO}/labels/${LABELS[${INDEX}]}" > /dev/null if test $? -ne 0 then echo "Failed when trying to create and update the label ${LABELS[${INDEX}]}." echo "Please check at ${GITHUB_URL}/labels" echo "" echo "If you find a bug report it at" echo "https://github.com/swcarpentry/lesson-template/." fi fi done