github

package
v0.0.0-...-4e1735e Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package github is a small subset wrapper for the GitHub API. See https://docs.github.com/en/rest?apiVersion=2022-11-28

Index

Constants

View Source
const (
	BaseUri = "https://%s/repos/%s/%s"

	GenBranchName = "auto-update-changelog"
)
View Source
const (
	EnvMergeType = "PARAM_MERGE_TYPE"
	EnvToken     = "GH_TOKEN"
	EnvServer    = "PARAM_GH_SERVER"
)

Variables

This section is empty.

Functions

func KnownSshKeys

func KnownSshKeys(client *http.Client) (string, error)

func NewRequest

func NewRequest(uri, method, token string) (*http.Request, error)

Types

type Anchor

type Anchor struct {
	Href string `json:"href"`
}

type Arthor

type Arthor struct {
	Login             string `json:"login"`
	Id                int    `json:"id"`
	NodeId            string `json:"node_id"`
	AvatarUrl         string `json:"avatar_url"`
	GravatarId        string `json:"gravatar_id"`
	Url               string `json:"url"`
	HtmlUrl           string `json:"html_url"`
	FollowersUrl      string `json:"followers_url"`
	FollowingUrl      string `json:"following_url"`
	GistsUrl          string `json:"gists_url"`
	StarredUrl        string `json:"starred_url"`
	SubscriptionsUrl  string `json:"subscriptions_url"`
	OrganizationsUrl  string `json:"organizations_url"`
	ReposUrl          string `json:"repos_url"`
	EventsUrl         string `json:"events_url"`
	ReceivedEventsUrl string `json:"received_events_url"`
	Type              string `json:"type"`
	SiteAdmin         bool   `json:"site_admin"`
}

type Asset

type Asset struct {
	Url                string    `json:"url"`
	BrowserDownloadUrl string    `json:"browser_download_url"`
	Id                 int       `json:"id"`
	NodeId             string    `json:"node_id"`
	Name               string    `json:"name"`
	Label              string    `json:"label"`
	State              string    `json:"state"`
	ContentType        string    `json:"content_type"`
	Size               int       `json:"size"`
	DownloadCount      int       `json:"download_count"`
	CreatedAt          time.Time `json:"created_at"`
	UpdatedAt          time.Time `json:"updated_at"`
	Uploader           Uploader  `json:"uploader"`
}

type Author

type Author struct {
	Name  string    `json:"name"`
	Email string    `json:"email"`
	Date  time.Time `json:"date"`
}

type Client

type Client struct {
	Client        HttpClient
	Domain        string
	MergeMethod   string
	Org           string
	RepositoryUri string
	Repository    string
	Token         string
	Username      string
	Host          string
}

func NewClient

func NewClient(repositoryUri, token, host string, client HttpClient) *Client

func (*Client) DoesBranchExistRemotely

func (gh *Client) DoesBranchExistRemotely(branch string) bool

func (*Client) MergePullRequest

func (gh *Client) MergePullRequest(prNumber int, mergeMethod string) (*PullRequestMergeResponse, error)

MergePullRequest Merge a pull request.

func (*Client) OpenPullRequest

func (gh *Client) OpenPullRequest(base, branch, title, summary string) (*PullRequest, error)

OpenPullRequest Opens a pull request against the base branch. gh pr create --base "${PARAM_MAIN_TRUNK_BRANCH}" --head "${GEN_BRANCH_NAME}" --fill

func (*Client) PublishChangelog

func (gh *Client) PublishChangelog(wd, branch, header, msgBody string, files []string) error

PublishChangelog Stage, commit, and push local changes, then make a pull request and merge it containing: 1. the git-chglog command config files if they are missing or first run. 2. the CHANGELOG.md if it contains changes.

func (*Client) Send

func (gh *Client) Send(uri, method string, body io.Reader) (*http.Response, error)

func (*Client) TagAndRelease

func (gh *Client) TagAndRelease(branch, tag string) (*ReleasesResponse, error)

type Commit

type Commit struct {
	Author       Author       `json:"author"`
	Committer    Author       `json:"committer"`
	Message      string       `json:"message"`
	Tree         Tree         `json:"tree"`
	Url          string       `json:"url"`
	CommentCount int          `json:"comment_count"`
	Verification Verification `json:"verification"`
}

type CommitDetail

type CommitDetail struct {
	Sha         string         `json:"sha"`
	NodeId      string         `json:"node_id"`
	Commit      Commit         `json:"commit"`
	Url         string         `json:"url"`
	HtmlUrl     string         `json:"html_url"`
	CommentsUrl string         `json:"comments_url"`
	Author      Profile        `json:"author"`
	Committer   Profile        `json:"committer"`
	Parents     []ParentCommit `json:"parents"`
}

type HttpClient

type HttpClient interface {
	Do(req *http.Request) (*http.Response, error)
}

type Label

type Label struct {
	Id          int    `json:"id"`
	NodeId      string `json:"node_id"`
	Url         string `json:"url"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Color       string `json:"color"`
	Default     bool   `json:"default"`
}

type License

type License struct {
	Key    string `json:"key"`
	Name   string `json:"name"`
	Url    string `json:"url"`
	SpdxId string `json:"spdx_id"`
	NodeId string `json:"node_id"`
}
type Link struct {
	Self string `json:"self"`
	Html string `json:"html"`
}
type Links struct {
	Self           Anchor `json:"self"`
	Html           Anchor `json:"html"`
	Issue          Anchor `json:"issue"`
	Comments       Anchor `json:"comments"`
	ReviewComments Anchor `json:"review_comments"`
	ReviewComment  Anchor `json:"review_comment"`
	Commits        Anchor `json:"commits"`
	Statuses       Anchor `json:"statuses"`
}

type Meta

type Meta struct {
	SshKeys []string `json:"ssh_keys"`
}

type Milestone

type Milestone struct {
	Url          string    `json:"url"`
	HtmlUrl      string    `json:"html_url"`
	LabelsUrl    string    `json:"labels_url"`
	Id           int       `json:"id"`
	NodeId       string    `json:"node_id"`
	Number       int       `json:"number"`
	State        string    `json:"state"`
	Title        string    `json:"title"`
	Description  string    `json:"description"`
	Creator      Profile   `json:"creator"`
	OpenIssues   int       `json:"open_issues"`
	ClosedIssues int       `json:"closed_issues"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
	ClosedAt     time.Time `json:"closed_at"`
	DueOn        time.Time `json:"due_on"`
}

type ParentCommit

type ParentCommit struct {
	Sha     string `json:"sha"`
	Url     string `json:"url"`
	HtmlUrl string `json:"html_url"`
}

type Permissions

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

type Profile

type Profile struct {
	Login             string `json:"login"`
	Id                int    `json:"id"`
	NodeId            string `json:"node_id"`
	AvatarUrl         string `json:"avatar_url"`
	GravatarId        string `json:"gravatar_id"`
	Url               string `json:"url"`
	HtmlUrl           string `json:"html_url"`
	FollowersUrl      string `json:"followers_url"`
	FollowingUrl      string `json:"following_url"`
	GistsUrl          string `json:"gists_url"`
	StarredUrl        string `json:"starred_url"`
	SubscriptionsUrl  string `json:"subscriptions_url"`
	OrganizationsUrl  string `json:"organizations_url"`
	ReposUrl          string `json:"repos_url"`
	EventsUrl         string `json:"events_url"`
	ReceivedEventsUrl string `json:"received_events_url"`
	Type              string `json:"type"`
	SiteAdmin         bool   `json:"site_admin"`
}

type Protection

type Protection struct {
	Enabled              bool                 `json:"enabled"`
	RequiredStatusChecks RequiredStatusChecks `json:"required_status_checks"`
}

type PullRequest

type PullRequest struct {
	Url                 string      `json:"url"`
	Id                  int         `json:"id"`
	NodeId              string      `json:"node_id"`
	HtmlUrl             string      `json:"html_url"`
	DiffUrl             string      `json:"diff_url"`
	PatchUrl            string      `json:"patch_url"`
	IssueUrl            string      `json:"issue_url"`
	CommitsUrl          string      `json:"commits_url"`
	ReviewCommentsUrl   string      `json:"review_comments_url"`
	ReviewCommentUrl    string      `json:"review_comment_url"`
	CommentsUrl         string      `json:"comments_url"`
	StatusesUrl         string      `json:"statuses_url"`
	Number              int         `json:"number"`
	State               string      `json:"state"`
	Locked              bool        `json:"locked"`
	Title               string      `json:"title"`
	User                Profile     `json:"user"`
	Body                string      `json:"body"`
	Labels              []Label     `json:"labels"`
	Milestone           Milestone   `json:"milestone"`
	ActiveLockReason    string      `json:"active_lock_reason"`
	CreatedAt           time.Time   `json:"created_at"`
	UpdatedAt           time.Time   `json:"updated_at"`
	ClosedAt            time.Time   `json:"closed_at"`
	MergedAt            time.Time   `json:"merged_at"`
	MergeCommitSha      string      `json:"merge_commit_sha"`
	Assignee            Profile     `json:"assignee"`
	Assignees           []Profile   `json:"assignees"`
	RequestedReviewers  []Profile   `json:"requested_reviewers"`
	RequestedTeams      []Team      `json:"requested_teams"`
	Head                Ref         `json:"head"`
	Base                Ref         `json:"base"`
	Links               Links       `json:"_links"`
	AuthorAssociation   string      `json:"author_association"`
	AutoMerge           interface{} `json:"auto_merge"`
	Draft               bool        `json:"draft"`
	Merged              bool        `json:"merged"`
	Mergeable           bool        `json:"mergeable"`
	Rebaseable          bool        `json:"rebaseable"`
	MergeableState      string      `json:"mergeable_state"`
	MergedBy            Profile     `json:"merged_by"`
	Comments            int         `json:"comments"`
	ReviewComments      int         `json:"review_comments"`
	MaintainerCanModify bool        `json:"maintainer_can_modify"`
	Commits             int         `json:"commits"`
	Additions           int         `json:"additions"`
	Deletions           int         `json:"deletions"`
	ChangedFiles        int         `json:"changed_files"`
}

type PullRequestBody

type PullRequestBody struct {
	Base  string `json:"base"`
	Body  string `json:"body,omitempty"`
	Title string `json:"title"`
	Head  string `json:"head"`
}

type PullRequestMergeBody

type PullRequestMergeBody struct {
	CommitTitle   string `json:"commit_title,omitempty"`
	CommitMessage string `json:"commit_message,omitempty"`
	MergeMethod   string `json:"merge_method"`
	PullNumber    int    `json:"pull_number"`
}

type PullRequestMergeResponse

type PullRequestMergeResponse struct {
	Sha     string `json:"sha"`
	Merged  bool   `json:"merged"`
	Message string `json:"message"`
}

type Ref

type Ref struct {
	Label string  `json:"label"`
	Ref   string  `json:"ref"`
	Sha   string  `json:"sha"`
	User  Profile `json:"user"`
	Repo  Repo    `json:"repo"`
}

type Release

type Release struct {
	Body         string `json:"body"`
	Name         string `json:"name"`
	TagName      string `json:"tag_name"`
	TargetCommit string `json:"target_commitish"`
}

type ReleasesResponse

type ReleasesResponse struct {
	Url             string    `json:"url"`
	HtmlUrl         string    `json:"html_url"`
	AssetsUrl       string    `json:"assets_url"`
	UploadUrl       string    `json:"upload_url"`
	TarballUrl      string    `json:"tarball_url"`
	ZipballUrl      string    `json:"zipball_url"`
	DiscussionUrl   string    `json:"discussion_url"`
	Id              int       `json:"id"`
	NodeId          string    `json:"node_id"`
	TagName         string    `json:"tag_name"`
	TargetCommitish string    `json:"target_commitish"`
	Name            string    `json:"name"`
	Body            string    `json:"body"`
	Draft           bool      `json:"draft"`
	Prerelease      bool      `json:"prerelease"`
	CreatedAt       time.Time `json:"created_at"`
	PublishedAt     time.Time `json:"published_at"`
	Author          Arthor    `json:"author"`
	Assets          []Asset   `json:"assets"`
}

type Repo

type Repo struct {
	Id               int         `json:"id"`
	NodeId           string      `json:"node_id"`
	Name             string      `json:"name"`
	FullName         string      `json:"full_name"`
	Owner            Profile     `json:"owner"`
	Private          bool        `json:"private"`
	HtmlUrl          string      `json:"html_url"`
	Description      string      `json:"description"`
	Fork             bool        `json:"fork"`
	Url              string      `json:"url"`
	ArchiveUrl       string      `json:"archive_url"`
	AssigneesUrl     string      `json:"assignees_url"`
	BlobsUrl         string      `json:"blobs_url"`
	BranchesUrl      string      `json:"branches_url"`
	CollaboratorsUrl string      `json:"collaborators_url"`
	CommentsUrl      string      `json:"comments_url"`
	CommitsUrl       string      `json:"commits_url"`
	CompareUrl       string      `json:"compare_url"`
	ContentsUrl      string      `json:"contents_url"`
	ContributorsUrl  string      `json:"contributors_url"`
	DeploymentsUrl   string      `json:"deployments_url"`
	DownloadsUrl     string      `json:"downloads_url"`
	EventsUrl        string      `json:"events_url"`
	ForksUrl         string      `json:"forks_url"`
	GitCommitsUrl    string      `json:"git_commits_url"`
	GitRefsUrl       string      `json:"git_refs_url"`
	GitTagsUrl       string      `json:"git_tags_url"`
	GitUrl           string      `json:"git_url"`
	IssueCommentUrl  string      `json:"issue_comment_url"`
	IssueEventsUrl   string      `json:"issue_events_url"`
	IssuesUrl        string      `json:"issues_url"`
	KeysUrl          string      `json:"keys_url"`
	LabelsUrl        string      `json:"labels_url"`
	LanguagesUrl     string      `json:"languages_url"`
	MergesUrl        string      `json:"merges_url"`
	MilestonesUrl    string      `json:"milestones_url"`
	NotificationsUrl string      `json:"notifications_url"`
	PullsUrl         string      `json:"pulls_url"`
	ReleasesUrl      string      `json:"releases_url"`
	SshUrl           string      `json:"ssh_url"`
	StargazersUrl    string      `json:"stargazers_url"`
	StatusesUrl      string      `json:"statuses_url"`
	SubscribersUrl   string      `json:"subscribers_url"`
	SubscriptionUrl  string      `json:"subscription_url"`
	TagsUrl          string      `json:"tags_url"`
	TeamsUrl         string      `json:"teams_url"`
	TreesUrl         string      `json:"trees_url"`
	CloneUrl         string      `json:"clone_url"`
	MirrorUrl        string      `json:"mirror_url"`
	HooksUrl         string      `json:"hooks_url"`
	SvnUrl           string      `json:"svn_url"`
	Homepage         string      `json:"homepage"`
	Language         interface{} `json:"language"`
	ForksCount       int         `json:"forks_count"`
	StargazersCount  int         `json:"stargazers_count"`
	WatchersCount    int         `json:"watchers_count"`
	Size             int         `json:"size"`
	DefaultBranch    string      `json:"default_branch"`
	OpenIssuesCount  int         `json:"open_issues_count"`
	Topics           []string    `json:"topics"`
	HasIssues        bool        `json:"has_issues"`
	HasProjects      bool        `json:"has_projects"`
	HasWiki          bool        `json:"has_wiki"`
	HasPages         bool        `json:"has_pages"`
	HasDownloads     bool        `json:"has_downloads"`
	HasDiscussions   bool        `json:"has_discussions"`
	Archived         bool        `json:"archived"`
	Disabled         bool        `json:"disabled"`
	PushedAt         time.Time   `json:"pushed_at"`
	CreatedAt        time.Time   `json:"created_at"`
	UpdatedAt        time.Time   `json:"updated_at"`
	Permissions      Permissions `json:"permissions"`
	AllowRebaseMerge bool        `json:"allow_rebase_merge"`
	TempCloneToken   string      `json:"temp_clone_token"`
	AllowSquashMerge bool        `json:"allow_squash_merge"`
	AllowMergeCommit bool        `json:"allow_merge_commit"`
	AllowForking     bool        `json:"allow_forking"`
	Forks            int         `json:"forks"`
	OpenIssues       int         `json:"open_issues"`
	License          License     `json:"license"`
	Watchers         int         `json:"watchers"`
}

type RequiredStatusChecks

type RequiredStatusChecks struct {
	EnforcementLevel string        `json:"enforcement_level"`
	Contexts         []interface{} `json:"contexts"`
	Checks           []interface{} `json:"checks"`
}

type ResponseBranch

type ResponseBranch struct {
	Name          string       `json:"name"`
	Commit        CommitDetail `json:"commit"`
	Links         Link         `json:"_links"`
	Protected     bool         `json:"protected"`
	Protection    Protection   `json:"protection"`
	ProtectionUrl string       `json:"protection_url"`
}

type Team

type Team struct {
	Id                  int    `json:"id"`
	NodeId              string `json:"node_id"`
	Url                 string `json:"url"`
	HtmlUrl             string `json:"html_url"`
	Name                string `json:"name"`
	Slug                string `json:"slug"`
	Description         string `json:"description"`
	Privacy             string `json:"privacy"`
	NotificationSetting string `json:"notification_setting"`
	Permission          string `json:"permission"`
	MembersUrl          string `json:"members_url"`
	RepositoriesUrl     string `json:"repositories_url"`
}

type Tree

type Tree struct {
	Sha string `json:"sha"`
	Url string `json:"url"`
}

type Uploader

type Uploader struct {
	Login             string `json:"login"`
	Id                int    `json:"id"`
	NodeId            string `json:"node_id"`
	AvatarUrl         string `json:"avatar_url"`
	GravatarId        string `json:"gravatar_id"`
	Url               string `json:"url"`
	HtmlUrl           string `json:"html_url"`
	FollowersUrl      string `json:"followers_url"`
	FollowingUrl      string `json:"following_url"`
	GistsUrl          string `json:"gists_url"`
	StarredUrl        string `json:"starred_url"`
	SubscriptionsUrl  string `json:"subscriptions_url"`
	OrganizationsUrl  string `json:"organizations_url"`
	ReposUrl          string `json:"repos_url"`
	EventsUrl         string `json:"events_url"`
	ReceivedEventsUrl string `json:"received_events_url"`
	Type              string `json:"type"`
	SiteAdmin         bool   `json:"site_admin"`
}

type Verification

type Verification struct {
	Verified  bool        `json:"verified"`
	Reason    string      `json:"reason"`
	Signature interface{} `json:"signature"`
	Payload   interface{} `json:"payload"`
}

Jump to

Keyboard shortcuts

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