github

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const GITHUB_API_URL = "https://api.github.com"

Variables

View Source
var ReLinkNext = regexp.MustCompile(`<([^>]+)>; rel="next"`)

ReLinkNext is used to check the Link header

<https://api.github.com/repositories/194783954/releases?per_page=1&page=2>; rel=\"next\"
View Source
var ReMultipleSlashes = regexp.MustCompile("/+")
View Source
var ReOwnerName = regexp.MustCompile(`^[A-Za-z0-9-]+$`)
View Source
var ReRepoName = regexp.MustCompile(`^[\w-][\w.-]*$`)
View Source
var ReUploadURLSuffix = regexp.MustCompile("/assets[^/]*$")

Functions

This section is empty.

Types

type Asset

type Asset struct {
	ID                 int    `json:"id"`
	Name               string `json:"name"`
	Label              string `json:"label"`
	ContentType        string `json:"content_type"`
	Size               int    `json:"size"`
	URL                string `json:"url"`
	BrowserDownloadURL string `json:"browser_download_url"`
	DownloadCount      int    `json:"download_count"`
	CreatedAt          string `json:"created_at"`
	UpdatedAt          string `json:"updated_at"`
	Uploader           Author `json:"uploader"`
}

type Author

type Author struct {
	Login     string `json:"login"`
	ID        int    `json:"id"`
	AvatarURL string `json:"avatar_url"`
	HtmlURL   string `json:"html_url"`
	Type      string `json:"type"`
	SiteAdmin bool   `json:"site_admin"`
}

type Branch

type Branch struct {
	Name      string `json:"name"`
	Protected bool   `json:"protected"`
}

type Client

type Client struct {
	Header http.Header
	Body   io.Reader
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, repo string) (*Client, error)

func (*Client) CompareTwoCommit added in v0.5.0

func (c *Client) CompareTwoCommit(base, head string, page, perPage int) (*CompareTwoCommit, error)

func (*Client) CreateRelease

func (c *Client) CreateRelease(tagName, targetCommitish, name, body string, draft, prerelease bool) (*Release, error)

func (*Client) Delete

func (c *Client) Delete(endpoint string) (*http.Response, error)

func (*Client) DeleteRelease

func (c *Client) DeleteRelease(id int) error

func (*Client) DeleteTag

func (c *Client) DeleteTag(tag string) error

func (*Client) DownloadAsset

func (c *Client) DownloadAsset(id int, pathname string) error

func (*Client) FetchBranch

func (c *Client) FetchBranch(page, perPage int, fn FetchBranchCallback) error

func (*Client) FetchCommitRef

func (c *Client) FetchCommitRef(sha string, page, perPage int, fn FetchCommitRefCallback) error

func (*Client) FetchRelease

func (c *Client) FetchRelease(page, perPage int, fn FetchReleaseCallback) error

func (*Client) Get

func (c *Client) Get(endpoint string) (*http.Response, error)

func (*Client) GetBranch

func (c *Client) GetBranch(name string) (*Branch, error)

func (*Client) GetRelease

func (c *Client) GetRelease(id int) (*Release, error)

func (*Client) GetReleaseByTagName

func (c *Client) GetReleaseByTagName(tag string) (*Release, error)

func (*Client) GetReleaseLatest

func (c *Client) GetReleaseLatest() (*Release, error)

func (*Client) ListBranches

func (c *Client) ListBranches(page, perPage int) (*ListBranches, error)

func (*Client) ListBranchesOfCommit

func (c *Client) ListBranchesOfCommit(sha string, branchesPerPage, commitsPerPage int) ([]*Branch, error)

func (*Client) ListCommitRefs

func (c *Client) ListCommitRefs(sha string, page, perPage int) (*ListCommitRefs, error)

func (*Client) ListReleases

func (c *Client) ListReleases(page, perPage int) (*ListReleases, error)

func (*Client) Post

func (c *Client) Post(endpoint string) (*http.Response, error)

func (*Client) PostUpload

func (c *Client) PostUpload(endpoint string, body io.Reader, size int64, mime string) (*http.Response, error)

func (*Client) SetToken

func (c *Client) SetToken(token string)

func (*Client) SetURL

func (c *Client) SetURL(s string) error

type Commit

type Commit struct {
	URL          string       `json:"url"`
	CommitAuthor CommitAuthor `json:"author"`
	Committer    CommitAuthor `json:"committer"`
	Message      string       `json:"message"`
}

type CommitAuthor

type CommitAuthor struct {
	Name  string `json:"name"`
	Email string `json:"email"`
	Date  string `json:"date"`
}

type CommitRef

type CommitRef struct {
	URL       string `json:"url"`
	SHA       string `json:"sha"`
	HtmlURL   string `json:"html_url"`
	Commit    Commit `json:"commit"`
	Author    Author `json:"author"`
	Committer Author `json:"committer"`
}

type CompareTwoCommit added in v0.5.0

type CompareTwoCommit struct {
	HtmlURL         string       `json:"html_url`
	BaseCommit      CommitRef    `json:"base_commit"`
	MergeBaseCommit CommitRef    `json:"merge_base_commit"`
	Status          string       `json:"status"`
	AheadBy         int          `json:"ahead_by"`
	BehindBy        int          `json:"behind_by"`
	TotalCommits    int          `json:"total_commits"`
	Commits         []*CommitRef `json:"commits"`
	NextPage        int
}

type FetchBranchCallback

type FetchBranchCallback func(v *Branch, page int) error

type FetchCommitRefCallback

type FetchCommitRefCallback func(v *CommitRef, page int) error

type FetchReleaseCallback

type FetchReleaseCallback func(v *Release, page int) error

type ListBranches

type ListBranches struct {
	NextPage int
	Branches []*Branch
}

type ListCommitRefs

type ListCommitRefs struct {
	NextPage   int
	CommitRefs []*CommitRef
}

type ListReleases

type ListReleases struct {
	NextPage int
	Releases []*Release
}

type Release

type Release struct {
	ID              int     `json:"id"`
	Draft           bool    `json:"draft"`
	PreRelease      bool    `json:"prerelease"`
	Name            string  `json:"name"`
	Body            string  `json:"body"`
	TagName         string  `json:"tag_name"`
	TargetCommitish string  `json:"target_commitish"`
	HtmlURL         string  `json:"html_url,omitempty"`
	UploadURL       string  `json:"upload_url,omitempty"`
	CreatedAt       string  `json:"created_at,omitempty"`
	PublishedAt     string  `json:"published_at,omitempty"`
	Author          Author  `json:"author,omitempty"`
	Assets          []Asset `json:"assets,omitempty"`
}

func (*Release) UploadAsset

func (r *Release) UploadAsset(c *Client, name string, body io.Reader, size int64, mime string) error

Jump to

Keyboard shortcuts

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