github

package
v2.11.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2019 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GitHubHost  string = "github.com"
	OAuthAppURL string = "https://hub.github.com/"
)
View Source
const (
	PullRequestTemplate = "pull_request_template"
	IssueTemplate       = "issue_template"
)
View Source
const Scissors = "------------------------ >8 ------------------------"

Variables

View Source
var (
	GitHubHostEnv = os.Getenv("GITHUB_HOST")
)
View Source
var (
	OriginNamesInLookupOrder = []string{"upstream", "github", "origin"}
)
View Source
var UserAgent = "Hub " + version.Version

Functions

func CaptureCrash

func CaptureCrash()

func CheckWriteable

func CheckWriteable(filename string) error

CheckWriteable checks if config file is writeable. This should be called before asking for credentials and only if current operation needs to update the file. See issue #1314 for details.

func DefaultGitHubHost

func DefaultGitHubHost() string

func FormatError

func FormatError(action string, err error) (ee error)

func IsHttpsProtocol

func IsHttpsProtocol() bool

func ReadTemplate

func ReadTemplate(kind, workdir string) (body string, err error)

func SanitizeProjectName

func SanitizeProjectName(name string) string

Types

type AuthorizationEntry

type AuthorizationEntry struct {
	Token string `json:"token"`
}

type Branch

type Branch struct {
	Repo *GitHubRepo
	Name string
}

func (*Branch) IsMaster

func (b *Branch) IsMaster() bool

func (*Branch) IsRemote

func (b *Branch) IsRemote() bool

func (*Branch) LongName

func (b *Branch) LongName() string

func (*Branch) PushTarget

func (b *Branch) PushTarget(owner string, preferUpstream bool) (branch *Branch)

func (*Branch) RemoteName

func (b *Branch) RemoteName() string

func (*Branch) ShortName

func (b *Branch) ShortName() string

func (*Branch) Upstream

func (b *Branch) Upstream() (u *Branch, err error)

type CIStatus

type CIStatus struct {
	State     string `json:"state"`
	Context   string `json:"context"`
	TargetUrl string `json:"target_url"`
}

type CIStatusResponse

type CIStatusResponse struct {
	State    string     `json:"state"`
	Statuses []CIStatus `json:"statuses"`
}

type CheckRun

type CheckRun struct {
	Status     string `json:"status"`
	Conclusion string `json:"conclusion"`
	Name       string `json:"name"`
	HtmlUrl    string `json:"html_url"`
}

type CheckRunsResponse

type CheckRunsResponse struct {
	CheckRuns []CheckRun `json:"check_runs"`
}

type Client

type Client struct {
	Host *Host
}

func NewClient

func NewClient(h string) *Client

func NewClientWithHost

func NewClientWithHost(host *Host) *Client

func (*Client) CommitPatch

func (client *Client) CommitPatch(project *Project, sha string) (patch io.ReadCloser, err error)

func (*Client) CreateIssue

func (client *Client) CreateIssue(project *Project, params interface{}) (issue *Issue, err error)

func (*Client) CreatePullRequest

func (client *Client) CreatePullRequest(project *Project, params map[string]interface{}) (pr *PullRequest, err error)

func (*Client) CreateRelease

func (client *Client) CreateRelease(project *Project, releaseParams *Release) (release *Release, err error)

func (*Client) CreateRepository

func (client *Client) CreateRepository(project *Project, description, homepage string, isPrivate bool) (repo *Repository, err error)

func (*Client) CurrentUser

func (client *Client) CurrentUser() (user *User, err error)

func (*Client) DeleteRelease

func (client *Client) DeleteRelease(release *Release) (err error)

func (*Client) DeleteReleaseAsset

func (client *Client) DeleteReleaseAsset(asset *ReleaseAsset) (err error)

func (*Client) DeleteRepository

func (client *Client) DeleteRepository(project *Project) error

func (*Client) DownloadReleaseAsset

func (client *Client) DownloadReleaseAsset(url string) (asset io.ReadCloser, err error)

func (*Client) EditRelease

func (client *Client) EditRelease(release *Release, releaseParams map[string]interface{}) (updatedRelease *Release, err error)

func (*Client) FetchCIStatus

func (client *Client) FetchCIStatus(project *Project, sha string) (status *CIStatusResponse, err error)

func (*Client) FetchComments

func (client *Client) FetchComments(project *Project, number string) (comments []Comment, err error)

func (*Client) FetchIssue

func (client *Client) FetchIssue(project *Project, number string) (issue *Issue, err error)

func (*Client) FetchIssues

func (client *Client) FetchIssues(project *Project, filterParams map[string]interface{}, limit int, filter func(*Issue) bool) (issues []Issue, err error)

func (*Client) FetchLabels

func (client *Client) FetchLabels(project *Project) (labels []IssueLabel, err error)

func (*Client) FetchMilestones

func (client *Client) FetchMilestones(project *Project) (milestones []Milestone, err error)

func (*Client) FetchPullRequests

func (client *Client) FetchPullRequests(project *Project, filterParams map[string]interface{}, limit int, filter func(*PullRequest) bool) (pulls []PullRequest, err error)

func (*Client) FetchRelease

func (client *Client) FetchRelease(project *Project, tagName string) (*Release, error)

func (*Client) FetchReleases

func (client *Client) FetchReleases(project *Project, limit int, filter func(*Release) bool) (releases []Release, err error)

func (*Client) FindOrCreateToken

func (client *Client) FindOrCreateToken(user, password, twoFactorCode string) (token string, err error)

func (*Client) ForkRepository

func (client *Client) ForkRepository(project *Project, params map[string]interface{}) (repo *Repository, err error)

func (*Client) GenericAPIRequest

func (client *Client) GenericAPIRequest(method, path string, data interface{}, headers map[string]string, ttl int) (*simpleResponse, error)

func (*Client) GistPatch

func (client *Client) GistPatch(id string) (patch io.ReadCloser, err error)

func (*Client) PullRequest

func (client *Client) PullRequest(project *Project, id string) (pr *PullRequest, err error)

func (*Client) PullRequestPatch

func (client *Client) PullRequestPatch(project *Project, id string) (patch io.ReadCloser, err error)

func (*Client) Repository

func (client *Client) Repository(project *Project) (repo *Repository, err error)

func (*Client) RequestReview

func (client *Client) RequestReview(project *Project, prNumber int, params map[string]interface{}) (err error)

func (*Client) UpdateIssue

func (client *Client) UpdateIssue(project *Project, issueNumber int, params map[string]interface{}) (err error)

func (*Client) UploadReleaseAsset

func (client *Client) UploadReleaseAsset(release *Release, filename, label string) (asset *ReleaseAsset, err error)

type Comment

type Comment struct {
	Id        int       `json:"id"`
	Body      string    `json:"body"`
	User      *User     `json:"user"`
	CreatedAt time.Time `json:"created_at"`
}

type Config

type Config struct {
	Hosts []*Host `toml:"hosts"`
}

func CreateTestConfigs

func CreateTestConfigs(user, token string) *Config

Public for testing purpose

func CurrentConfig

func CurrentConfig() *Config

func (*Config) DefaultHost

func (c *Config) DefaultHost() (host *Host, err error)

func (*Config) DefaultHostNoPrompt

func (c *Config) DefaultHostNoPrompt() (*Host, error)

func (*Config) DetectToken

func (c *Config) DetectToken() string

func (*Config) Find

func (c *Config) Find(host string) *Host

func (*Config) PromptForHost

func (c *Config) PromptForHost(host string) (h *Host, err error)

func (*Config) PromptForOTP

func (c *Config) PromptForOTP() string

func (*Config) PromptForPassword

func (c *Config) PromptForPassword(host, user string) (pass string)

func (*Config) PromptForUser

func (c *Config) PromptForUser(host string) (user string)

type Editor

type Editor struct {
	Program string
	Topic   string
	File    string
	Message string
	CS      string
	// contains filtered or unexported fields
}

func NewEditor

func NewEditor(filename, topic, message string) (editor *Editor, err error)

func (*Editor) AddCommentedSection

func (e *Editor) AddCommentedSection(text string)

func (*Editor) DeleteFile

func (e *Editor) DeleteFile() error

func (*Editor) EditContent

func (e *Editor) EditContent() (content string, err error)

type Gist

type Gist struct {
	Files map[string]GistFile `json:"files"`
}

type GistFile

type GistFile struct {
	RawUrl string `json:"raw_url"`
}

type GitHubRepo

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

func LocalRepo

func LocalRepo() (repo *GitHubRepo, err error)

func (*GitHubRepo) CurrentBranch

func (r *GitHubRepo) CurrentBranch() (branch *Branch, err error)

func (*GitHubRepo) CurrentProject

func (r *GitHubRepo) CurrentProject() (project *Project, err error)

func (*GitHubRepo) DefaultBranch

func (r *GitHubRepo) DefaultBranch(remote *Remote) *Branch

func (*GitHubRepo) MainProject

func (r *GitHubRepo) MainProject() (*Project, error)

func (*GitHubRepo) MainRemote

func (r *GitHubRepo) MainRemote() (*Remote, error)

func (*GitHubRepo) MasterBranch

func (r *GitHubRepo) MasterBranch() *Branch

func (*GitHubRepo) RemoteBranchAndProject

func (r *GitHubRepo) RemoteBranchAndProject(owner string, preferUpstream bool) (branch *Branch, project *Project, err error)

func (*GitHubRepo) RemoteByName

func (r *GitHubRepo) RemoteByName(name string) (*Remote, error)

func (*GitHubRepo) RemoteForProject

func (r *GitHubRepo) RemoteForProject(project *Project) (*Remote, error)

func (*GitHubRepo) RemoteForRepo

func (r *GitHubRepo) RemoteForRepo(repo *Repository) (*Remote, error)

func (*GitHubRepo) UpstreamProject

func (r *GitHubRepo) UpstreamProject() (project *Project, err error)

type GithubHostError

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

func (*GithubHostError) Error

func (e *GithubHostError) Error() string

type Host

type Host struct {
	Host        string `toml:"host"`
	User        string `toml:"user"`
	AccessToken string `toml:"access_token"`
	Protocol    string `toml:"protocol"`
	UnixSocket  string `toml:"unix_socket,omitempty"`
}

type Issue

type Issue struct {
	Number int    `json:"number"`
	State  string `json:"state"`
	Title  string `json:"title"`
	Body   string `json:"body"`
	User   *User  `json:"user"`

	PullRequest *PullRequest     `json:"pull_request"`
	Head        *PullRequestSpec `json:"head"`
	Base        *PullRequestSpec `json:"base"`

	MergeCommitSha      string `json:"merge_commit_sha"`
	MaintainerCanModify bool   `json:"maintainer_can_modify"`
	Draft               bool   `json:"draft"`

	Comments  int          `json:"comments"`
	Labels    []IssueLabel `json:"labels"`
	Assignees []User       `json:"assignees"`
	Milestone *Milestone   `json:"milestone"`
	CreatedAt time.Time    `json:"created_at"`
	UpdatedAt time.Time    `json:"updated_at"`
	MergedAt  time.Time    `json:"merged_at"`

	RequestedReviewers []User `json:"requested_reviewers"`
	RequestedTeams     []Team `json:"requested_teams"`

	ApiUrl  string `json:"url"`
	HtmlUrl string `json:"html_url"`

	ClosedBy *User `json:"closed_by"`
}

type IssueLabel

type IssueLabel struct {
	Name  string `json:"name"`
	Color string `json:"color"`
}

type MessageBuilder

type MessageBuilder struct {
	Title    string
	Filename string
	Message  string
	Edit     bool
	// contains filtered or unexported fields
}

func (*MessageBuilder) AddCommentedSection

func (b *MessageBuilder) AddCommentedSection(section string)

func (*MessageBuilder) Cleanup

func (b *MessageBuilder) Cleanup()

func (*MessageBuilder) Extract

func (b *MessageBuilder) Extract() (title, body string, err error)

type Milestone

type Milestone struct {
	Number int    `json:"number"`
	Title  string `json:"title"`
}

type Project

type Project struct {
	Name     string
	Owner    string
	Host     string
	Protocol string
}

func NewProject

func NewProject(owner, name, host string) *Project

func NewProjectFromRepo

func NewProjectFromRepo(repo *Repository) (p *Project, err error)

func NewProjectFromURL

func NewProjectFromURL(url *url.URL) (p *Project, err error)

func (*Project) GitURL

func (p *Project) GitURL(name, owner string, isSSH bool) (url string)

func (*Project) SameAs

func (p *Project) SameAs(other *Project) bool

func (Project) String

func (p Project) String() string

func (*Project) WebURL

func (p *Project) WebURL(name, owner, path string) string

type PullRequest

type PullRequest Issue

func (*PullRequest) HasRequestedReviewer

func (pr *PullRequest) HasRequestedReviewer(name string) bool

func (*PullRequest) HasRequestedTeam

func (pr *PullRequest) HasRequestedTeam(name string) bool

func (*PullRequest) IsSameRepo

func (pr *PullRequest) IsSameRepo() bool

type PullRequestSpec

type PullRequestSpec struct {
	Label string      `json:"label"`
	Ref   string      `json:"ref"`
	Sha   string      `json:"sha"`
	Repo  *Repository `json:"repo"`
}

type Release

type Release struct {
	Name            string         `json:"name"`
	TagName         string         `json:"tag_name"`
	TargetCommitish string         `json:"target_commitish"`
	Body            string         `json:"body"`
	Draft           bool           `json:"draft"`
	Prerelease      bool           `json:"prerelease"`
	Assets          []ReleaseAsset `json:"assets"`
	TarballUrl      string         `json:"tarball_url"`
	ZipballUrl      string         `json:"zipball_url"`
	HtmlUrl         string         `json:"html_url"`
	UploadUrl       string         `json:"upload_url"`
	ApiUrl          string         `json:"url"`
	CreatedAt       time.Time      `json:"created_at"`
	PublishedAt     time.Time      `json:"published_at"`
}

type ReleaseAsset

type ReleaseAsset struct {
	Name        string `json:"name"`
	Label       string `json:"label"`
	DownloadUrl string `json:"browser_download_url"`
	ApiUrl      string `json:"url"`
}

type Remote

type Remote struct {
	Name    string
	URL     *url.URL
	PushURL *url.URL
}

func Remotes

func Remotes() (remotes []Remote, err error)

func (*Remote) Project

func (remote *Remote) Project() (*Project, error)

func (*Remote) String

func (remote *Remote) String() string

type Repository

type Repository struct {
	Name          string                 `json:"name"`
	FullName      string                 `json:"full_name"`
	Parent        *Repository            `json:"parent"`
	Owner         *User                  `json:"owner"`
	Private       bool                   `json:"private"`
	HasWiki       bool                   `json:"has_wiki"`
	Permissions   *RepositoryPermissions `json:"permissions"`
	HtmlUrl       string                 `json:"html_url"`
	DefaultBranch string                 `json:"default_branch"`
}

type RepositoryPermissions

type RepositoryPermissions struct {
	Admin bool `json:"admin"`
	Push  bool `json:"push"`
	Pull  bool `json:"pull"`
}

type Team

type Team struct {
	Name string `json:"name"`
	Slug string `json:"slug"`
}

type URL

type URL struct {
	url.URL
	*Project
}

func ParseURL

func ParseURL(rawurl string) (*URL, error)

func (URL) ProjectPath

func (url URL) ProjectPath() (projectPath string)

type User

type User struct {
	Login string `json:"login"`
}

Jump to

Keyboard shortcuts

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