Captain Codeman Captain Codeman

Creating labels for GitHub issue system

Simple script to automate creation

Contents

Introduction

I liked the ideas for Managing your backlog with GitHub Issues and the type of labels used but creating them was harder than it should have been because of the unicode characters and custom colors and so using them consistently on multiple projects would mean repeating the same work each time (unless there is a ‘copy labels’ button that I haven’t noticed!).

So, I decided to write a little script to automate the process. It creates a slightly different set of labels as shown below but could be easily adapted to your own needs:

You need to add curl to your path or put it in the same folder as the script which prompts you for your GitHub Profile, Password and Project name.

The actual script (save as a cmd file):

@echo off
SETLOCAL
echo This script creates issue labels for a GitHub repository
echo.
echo Please specify the GitHub Profile containing the Repository, e.g.:
echo https://github.com/MyProfile/MyCoolProject
echo                    ~~~~~~~~~
set /P username= "  Enter Profile   : "
echo.
echo Please specify the GitHub password for that profile:
set /P password= "  Enter Password  : "
echo.
echo Please specify the GitHub Repository, e.g.:
echo https://github.com/MyProfile/MyCoolProject
echo                              ~~~~~~~~~~~~~
echo.
set /P repository= "  Enter Repository: "
echo.
echo Creating labels ...
curl -k -u "%username%:%password%" -d "{\"name\":\"Feature\",\"color\":\"2d9e11\"}" https://api.github.com/repos/%username%/%repository%/labels
curl -k -u "%username%:%password%" -d "{\"name\":\"Bug\",\"color\":\"e10c02\"}" https://api.github.com/repos/%username%/%repository%/labels
curl -k -u "%username%:%password%" -d "{\"name\":\"Rejected\",\"color\":\"000000\"}" https://api.github.com/repos/%username%/%repository%/labels
curl -k -u "%username%:%password%" -d "{\"name\":\"Idea\",\"color\":\"e102d8\"}" https://api.github.com/repos/%username%/%repository%/labels
curl -k -u "%username%:%password%" -d "{\"name\":\"Task\",\"color\":\"0b02e1\"}" https://api.github.com/repos/%username%/%repository%/labels
curl -k -u "%username%:%password%" -d "{\"name\":\"\u2605\",\"color\":\"fffdd6\"}" https://api.github.com/repos/%username%/%repository%/labels
curl -k -u "%username%:%password%" -d "{\"name\":\"\u2605\u2605\",\"color\":\"fff875\"}" https://api.github.com/repos/%username%/%repository%/labels
curl -k -u "%username%:%password%" -d "{\"name\":\"\u2605\u2605\u2605\",\"color\":\"fff200\"}" https://api.github.com/repos/%username%/%repository%/labels
echo.
echo Current labels ...
curl -k -u "%username%:%password%" https://api.github.com/repos/%username%/%repository%/labels
ENDLOCAL
pause

Feb 2013: Script updated to work with latest Curl for Windows that I tried on Windows 8