gordon

package module
v0.0.0-...-80414a5 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2015 License: MIT Imports: 23 Imported by: 0

README

Pulls

Pulls is a small cli application name to help you manage pull requests for your repository. It was created by Michael Crosby to improve the productivity of the Docker maintainers.

Gordon assumes that the git origin is the upstream repository where the Issues and Pull Requests are managed. This is not the workflow described in the GitHub fork a repository documentation.

Quick installation instructions:

  • Install Go 1.2+ from http://golang.org/
  • Install with go get -u github.com/docker/gordon/{pulls,issues}
  • Make sure your $PATH includes x/bin where x is each directory in your $GOPATH environment variable.
  • Call pulls --help and issues --help
  • Add your github token with pulls auth <UserName> --add <token>

Dockerfile container build:

If you don't have Go set up and want to try out Gordon, you can use the Dockerfile to build it, and then can either copy the 2 executables to your local Linux host:

  • Build: docker build -t gordon .
  • Copy: `docker run --name gore gordon true && docker cp gore:/go/bin/pulls . && docker cp gore:/go/bin/issues . && docker rm gore``

You could also run from inside the container:

  • Setup an alias: pulls() { docker run --rm -it -v $PWD:/src --workdir /src -e HOME=/src gordon pulls $@; }
  • Set the GitHub API token: pulls auth SvenDowideit --add 1373a7583d30623abcb2b233fe45090fe2e4a3e1a2
  • List open PR's: pulls

Documentation

Index

Constants

View Source
const (
	MaintainerFileName = "MAINTAINERS"
	NumWorkers         = 10
)
View Source
const Version = "1"

Variables

View Source
var (
	VerboseOutput      = false
	ErrNoUsernameKnown = errors.New("No Username known - you probably need to use the `auth` option to configure your GitHub token")
)
View Source
var Colorize bool

Functions

func DarkRed

func DarkRed(s string) string

func DarkYellow

func DarkYellow(s string) string

func DisplayCommentAdded

func DisplayCommentAdded(cmt gh.Comment)

func DisplayComments

func DisplayComments(comments []gh.Comment)

func DisplayContributors

func DisplayContributors(c *cli.Context, contributors []*gh.Contributor)

func DisplayIssue

func DisplayIssue(issue *gh.Issue, comments []gh.Comment)

func DisplayIssues

func DisplayIssues(c *cli.Context, v interface{}, notrunc bool)

Display Issues prints `issues` to standard output in a human-friendly tabulated format.

func DisplayPatch

func DisplayPatch(r io.Reader) error

func DisplayPullRequest

func DisplayPullRequest(pr *gh.PullRequest, status gh.CombinedStatus)

func DisplayPullRequests

func DisplayPullRequests(c *cli.Context, pulls []*gh.PullRequest, notrunc bool)

func DisplayReviewers

func DisplayReviewers(c *cli.Context, reviewers map[string][]string)

func Fatalf

func Fatalf(format string, args ...interface{})

func GenBranchName

func GenBranchName(text string) string

GenBranchName returns a generated branch name from a human-readable description.

For example this:

`GenBranchName("   Hey! let's do awesome stuff...")`

Will return this:

`"hey_let_s_do_awesome_stuff"`

func GetDefaultGitRemote

func GetDefaultGitRemote() string

func GetDirsForPR

func GetDirsForPR(src []byte, dir string) ([]string, error)

func GetFileExtensionsForPR

func GetFileExtensionsForPR(src []byte, ext string) ([]string, error)

func GetGitConfig

func GetGitConfig(name string) ([]byte, error)

func GetGordonOrigin

func GetGordonOrigin() (string, error)

func GetMaintainerManagerEmail

func GetMaintainerManagerEmail() (string, error)

func GetMaintainersFromRepo

func GetMaintainersFromRepo(repoPath string, withUsername bool) (map[string][]string, error)

GetMaintainersFromRepo returns the maintainers for a repo with the username as the key and the file's that they own as a slice in the value

func GetRemoteUrl

func GetRemoteUrl(remote string) (string, string, error)

func GetReviewersForPR

func GetReviewersForPR(patch []byte, withUsername bool) (map[string][]string, error)

func GetTopLevelGitRepo

func GetTopLevelGitRepo() (string, error)

func Git

func Git(args ...string) error

Execute git commands and output to Stdout and Stderr

func Green

func Green(s string) string

func HumanDuration

func HumanDuration(d time.Duration) string

HumanDuration returns a human-readable approximation of a duration This function is taken from the Docker project, and slightly modified to cap units at days. (eg. "About a minute", "4 hours ago", etc.) (c) 2013 Docker, inc. and the Docker authors (http://docker.io)

func PrintVerboseCommand

func PrintVerboseCommand(cmd *exec.Cmd)

func Red

func Red(s string) string

func ReviewPatch

func ReviewPatch(input []byte, maintainers map[string][]string) (map[string][]string, error)

ReviewPatch reads a git-formatted patch from `src`, and for each file affected by the patch it assign its Maintainers based on the current repository tree directories The list of Maintainers are generated when the MaintainerManager object is instantiated.

The result is a map where the keys are the paths of files affected by the patch, and the values are the maintainers assigned to review that partiular file.

There is no duplicate checks: the same maintainer may be present in multiple entries of the map, or even multiple times in the same entry if the MAINTAINERS file has duplicate lines.

func SaveConfig

func SaveConfig(config Config) error

func Yellow

func Yellow(s string) string

Types

type ByAdditions

type ByAdditions []ContributorStats

func (ByAdditions) Len

func (a ByAdditions) Len() int

func (ByAdditions) Less

func (a ByAdditions) Less(i, j int) bool

func (ByAdditions) Swap

func (a ByAdditions) Swap(i, j int)

type ByCommits

type ByCommits []ContributorStats

func (ByCommits) Len

func (a ByCommits) Len() int

func (ByCommits) Less

func (a ByCommits) Less(i, j int) bool

func (ByCommits) Swap

func (a ByCommits) Swap(i, j int)

type ByDeletions

type ByDeletions []ContributorStats

func (ByDeletions) Len

func (a ByDeletions) Len() int

func (ByDeletions) Less

func (a ByDeletions) Less(i, j int) bool

func (ByDeletions) Swap

func (a ByDeletions) Swap(i, j int)

type Config

type Config struct {
	Token    string
	UserName string
}

func LoadConfig

func LoadConfig() (*Config, error)

type ContributorStats

type ContributorStats struct {
	Name      string
	Additions int
	Deletions int
	Commits   int
}

type Maintainer

type Maintainer struct {
	Username string
	FullName string
	Email    string
	Target   string
	Active   bool
	Lead     bool
	Raw      string
}

type MaintainerFile

type MaintainerFile map[string][]*Maintainer

func LoadMaintainerFile

func LoadMaintainerFile(dir string) (MaintainerFile, error)

Currently not being used

func TopMostMaintainerFile

func TopMostMaintainerFile(dir string) (MaintainerFile, error)

Currently not being used

TopMostMaintainerFile moves up the directory tree looking for a MAINTAINERS file, parses the top-most file it finds, and returns its contents. This is used to find the top-level maintainer of a project for certain privileged reviews, such as authorizing changes to a MAINTAINERS file.

type MaintainerManager

type MaintainerManager struct {
	// contains filtered or unexported fields
}

Top level type that manages a repository

func NewMaintainerManager

func NewMaintainerManager(client *gh.Client, org, repo string) (*MaintainerManager, error)

func (*MaintainerManager) AddComment

func (m *MaintainerManager) AddComment(number, comment string) (gh.Comment, error)

Add a comment to an existing pull request

func (*MaintainerManager) Checkout

func (m *MaintainerManager) Checkout(pr *gh.PullRequest) error

Checkout the pull request into the working tree of the users repository.

It's up to the caller to decide what to do with the checked out branch - typically created a named branch with 'checkout -b'.

func (*MaintainerManager) Close

func (m *MaintainerManager) Close(number string) error

func (*MaintainerManager) CreatePullRequest

func (m *MaintainerManager) CreatePullRequest(base, head, title, body string) (*gh.PullRequest, error)

func (*MaintainerManager) GetComments

func (m *MaintainerManager) GetComments(number string) ([]gh.Comment, error)

Return all comments for an issue or pull request

func (*MaintainerManager) GetContributors

func (m *MaintainerManager) GetContributors() ([]*gh.Contributor, error)

Return contributors list

func (*MaintainerManager) GetFirstIssue

func (m *MaintainerManager) GetFirstIssue(state, sortBy string) (*gh.Issue, error)

func (*MaintainerManager) GetFirstPullRequest

func (m *MaintainerManager) GetFirstPullRequest(state, sortBy string) (*gh.PullRequest, error)

func (*MaintainerManager) GetFullPullRequests

func (m *MaintainerManager) GetFullPullRequests(prs []*gh.PullRequest, needFullPr, needComments bool) []*gh.PullRequest

func (*MaintainerManager) GetGithubUser

func (m *MaintainerManager) GetGithubUser() (*gh.User, error)

Get the user information from the authenticated user

func (*MaintainerManager) GetIssue

func (m *MaintainerManager) GetIssue(number string, comments bool) (*gh.Issue, []gh.Comment, error)

Return a single issue Return issue's comments if requested

func (*MaintainerManager) GetIssues

func (m *MaintainerManager) GetIssues(state, assignee string) ([]*gh.Issue, error)

GetIssues queries the GithubAPI for all issues matching the state `state` and the assignee `assignee`. See http://developer.github.com/v3/issues/#list-issues-for-a-repository

func (*MaintainerManager) GetIssuesFound

func (m *MaintainerManager) GetIssuesFound(query string) ([]*gh.SearchItem, error)

Return all issue found

func (*MaintainerManager) GetPullRequest

func (m *MaintainerManager) GetPullRequest(number string) (*gh.PullRequest, error)

Return a single pull request

func (*MaintainerManager) GetPullRequestFiles

func (m *MaintainerManager) GetPullRequestFiles(number string) ([]*gh.PullRequestFile, error)

Return all pull request Files

func (*MaintainerManager) GetPullRequests

func (m *MaintainerManager) GetPullRequests(state, sort string) ([]*gh.PullRequest, error)

Return all pull requests

func (*MaintainerManager) GetStatus

func (m *MaintainerManager) GetStatus(pr *gh.PullRequest) (gh.CombinedStatus, error)

GetStatus queries the GithubAPI for the current build status of a pull request See http://developer.github.com/v3/issues/#list-issues-for-a-repository

func (*MaintainerManager) MergePullRequest

func (m *MaintainerManager) MergePullRequest(number, comment string, force bool) (gh.Merge, error)

Merge a pull request If no LGTMs are in the comments require force to be true

func (*MaintainerManager) PatchIssue

func (m *MaintainerManager) PatchIssue(number string, issue *gh.Issue) (*gh.Issue, error)

Patch an issue

func (*MaintainerManager) PatchPullRequest

func (m *MaintainerManager) PatchPullRequest(number string, pr *gh.PullRequest) (*gh.PullRequest, error)

Patch a pull request

func (*MaintainerManager) Repository

func (m *MaintainerManager) Repository() (*gh.Repository, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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