github

package
v0.0.0-...-0b82c43 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2016 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is used for making requests to GitHub

func (*Client) AccessToken

func (gc *Client) AccessToken() string

AccessToken returns the client's access token

func (*Client) CreateBranch

func (gc *Client) CreateBranch(owner, repo, branchName, baseRef string) (string, error)

CreateBranch creates a new branch of the repository from a commit as baseRef

func (*Client) CreateFile

func (gc *Client) CreateFile(owner, repo, path, message, branch string, content []byte) (*scm.RepositoryContent, error)

CreateFile commits a new file to a repository

func (*Client) CreateHook

func (gc *Client) CreateHook(owner, repo, callback string, events []string) error

CreateHook creates a webhook

func (*Client) CreateKey

func (gc *Client) CreateKey(owner, repo, key, title string) error

CreateKey creates repository deploy keys

func (*Client) CreatePullRequest

func (gc *Client) CreatePullRequest(owner, repo, baseRef, headRef, title string) error

CreatePullRequest starts a pull request of the changes from headRef to baseRef

func (*Client) CreateStatus

func (gc *Client) CreateStatus(owner, repo, ref string, stageID int, stageName, state string) error

func (*Client) GetContents

func (gc *Client) GetContents(owner, repo, path, ref string) (*scm.RepositoryContent, bool)

GetContents gets the metadata and content of a file from the given commit or branch

func (*Client) GetDirectoryContent

func (gc *Client) GetDirectoryContent(owner, repo, path, ref string) ([]interface{}, bool)

GetDirectoryContents gets the metadata and the contents a directory

func (*Client) GetFileContent

func (gc *Client) GetFileContent(owner, repo, path, ref string) ([]byte, bool)

GetFileContent fetches a file from the given commit or branch

func (*Client) GetHead

func (gc *Client) GetHead(owner, repo, branch string) (string, error)

GetHead gets the HEAD ref of a branch

func (*Client) GetRepository

func (gc *Client) GetRepository(owner, name string) (*scm.Repository, bool)

GetRepository fetches repository details from GitHub

func (*Client) HookExists

func (gc *Client) HookExists(owner, repo, url string) bool

HookExists checks whether a webhook with the given callback already exists

func (*Client) ListRepositories

func (gc *Client) ListRepositories(user string) (repos []*scm.Repository, err error)

ListRepositories lists the repositories accessible by the current user

func (*Client) Name

func (gc *Client) Name() string

Name returns the client's remote source name

func (*Client) ParseHook

func (gc *Client) ParseHook(body []byte, event string) (*scm.Hook, error)

ParseHook parses the contents of a webhook to build useful data

func (*Client) SetAccessToken

func (gc *Client) SetAccessToken(token string)

SetAccessToken sets the client's access token

func (*Client) UpdateFile

func (gc *Client) UpdateFile(owner, repo, path, blob, message, branch string, content []byte) (*scm.RepositoryContent, error)

UpdateFile commits diff of a file content from the given blob

type PushHook

type PushHook struct {
	Ref     string `json:"ref"`
	Deleted bool   `json:"deleted"`

	Head struct {
		ID        string `json:"id"`
		URL       string `json:"url"`
		Message   string `json:"message"`
		Timestamp string `json:"timestamp"`

		Author struct {
			Name     string `json:"name"`
			Email    string `json:"name"`
			Username string `json:"username"`
		} `json:"author"`

		Committer struct {
			Name     string `json:"name"`
			Email    string `json:"name"`
			Username string `json:"username"`
		} `json:"committer"`
	} `json:"head_commit"`

	Sender struct {
		Login  string `json:"login"`
		Avatar string `json:"avatar_url"`
	} `json:"sender"`

	Repo struct {
		Owner struct {
			Login string `json:"login"`
			Name  string `json:"name"`
		} `json:"owner"`

		Name          string `json:"name"`
		FullName      string `json:"full_name"`
		Language      string `json:"language"`
		Private       bool   `json:"private"`
		HTMLURL       string `json:"html_url"`
		CloneURL      string `json:"clone_url"`
		DefaultBranch string `json:"default_branch"`
	} `json:"repository"`
}

PushHook (taken from drone) is used to make github webhooks easily accessible

Jump to

Keyboard shortcuts

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