ghlabels

package module
v0.0.0-...-05f9f62 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 27, 2016 License: MIT Imports: 8 Imported by: 0

README

gh-labeler

gh-labeler is a Golang package which lets you programmatically define more useful labels for your Github issues, on a per-repository basis.

Installation

Installing gh-labeler is as simple as running go get like so:

$ go get github.com/moogar0880/gh-labeler/cmd/ghlabels

Docker Image

You can also pull down and run the publicly available docker image:

$ docker run --rm moogar0880/ghlabeler -token ${MY_ACCESS_TOKEN}

Configuration

Before you can start using this tool, you need a personal Github Access Token with proper repository permissions.

Usage

To run ghlabels once it's installed (assuming ${GOPATH}/bin is on your $PATH) you can run

$ ghlabels -h
Define more useful labels for your Github issues.

Usage:
  ghlabels [OPTIONS] COMMAND [arg...] [flags]

Flags:
  -f, --file string    Specify Config File to Load (default "labels.json")
  -r, --remove         Remove labels that are not present in the config file
  -t, --token string   The Github Access Token to use
  -v, --version        Print version information and quit

Extended Usage

As of 0.2.0, you may now specify a list of repositories to apply the label configuration to. You may list out multiple repositories like so:

{
  "owner": "moogar0880",
  "repos": [
    "gh-labeler",
    "PyTrakt"
  ],
  "labels": [
    {
      "name": "bug",
      "color": "ee0701"
    }
  ]
}

Default Labels

To help get you started, the default Github Issues have been defined in the provided default.json.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Host   string          `json:"host"`
	Owner  string          `json:"owner"`
	Repo   string          `json:"repo"`
	Repos  []string        `json:"repos"`
	Labels []*github.Label `json:"labels"`
}

Config holds the labeler configuration

func LoadConfig

func LoadConfig(fp string) *Config

LoadConfig loads a JSON file from the provided file path

type GHLabeler

type GHLabeler struct {
	Client *github.Client
	Config *Config
}

GHLabeler is a wrapper around a github.Client used to interact with the Github label

func NewLabeler

func NewLabeler(token string, c *Config) *GHLabeler

NewLabeler returns a new GHLabeler instance

func (*GHLabeler) CreateMissing

func (l *GHLabeler) CreateMissing(existing Labels, repo string)

CreateMissing creates any github issue labels that don't already exist

func (*GHLabeler) GetLabels

func (l *GHLabeler) GetLabels(repo string) Labels

GetLabels returns the list of existing labels from a specified gh repository

func (*GHLabeler) RemoveAbsent

func (l *GHLabeler) RemoveAbsent(existing Labels, repo string)

RemoveAbsent removes any labels that exist on github that aren't present in the local config file

func (*GHLabeler) SetLabels

func (l *GHLabeler) SetLabels(existing Labels, repo string, removeAbsent bool)

SetLabels orchestrates setting the desired state of the provided repository's github issue labels

func (*GHLabeler) UpdateExisting

func (l *GHLabeler) UpdateExisting(existing Labels, repo string)

UpdateExisting labels in github if a label color has been changed

type Labels

type Labels []*github.Label

Labels is a type alias for a slice of github label pointers

Directories

Path Synopsis
cmd
ghlabels command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL