gitee

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GiteeHOSTURL = "https://gitee.com/api"
)

Variables

This section is empty.

Functions

func ParseHook

func ParseHook(eventType EventType, payload []byte) (event interface{}, err error)

Types

type AccessToken

type AccessToken struct {
	AccessToken  string `json:"access_token"`
	TokenType    string `json:"token_type"`
	ExpiresIn    int    `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
	Scope        string `json:"scope"`
	CreatedAt    int    `json:"created_at"`
}

func RefreshAccessToken

func RefreshAccessToken(refreshToken string) (*AccessToken, error)

type Branch

type Branch struct {
	Name   string       `json:"name"`
	Commit BranchCommit `json:"commit"`
}

type BranchAuthor

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

type BranchCommit

type BranchCommit struct {
	Sha    string                      `json:"sha"`
	URL    string                      `json:"url"`
	Commit BranchCommmitInternalCommit `json:"commit"`
}

type BranchCommitter

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

type BranchCommmitInternalCommit

type BranchCommmitInternalCommit struct {
	Author    BranchAuthor    `json:"author"`
	URL       string          `json:"url"`
	Message   string          `json:"message"`
	Tree      BranchTree      `json:"tree"`
	Committer BranchCommitter `json:"committer"`
}

type BranchTree

type BranchTree struct {
	Sha string `json:"sha"`
	URL string `json:"url"`
}

type Client

type Client struct {
	*gitee.APIClient
}

func NewClient

func NewClient(id int, accessToken, proxyAddr string, enableProxy bool) *Client

func (*Client) CreateHook

func (c *Client) CreateHook(accessToken, owner, repo string, hook *git.Hook) (*Hook, error)

func (*Client) DeleteHook

func (c *Client) DeleteHook(ctx context.Context, owner, repo string, id int64) error

func (*Client) GetAuthenticatedUser

func (c *Client) GetAuthenticatedUser(ctx context.Context) (gitee.User, error)

func (*Client) GetContents

func (c *Client) GetContents(ctx context.Context, owner, repo, sha string) (gitee.Blob, error)

func (*Client) GetPullRequest

func (c *Client) GetPullRequest(ctx context.Context, owner string, repo string, number int) (gitee.PullRequest, error)

func (*Client) GetReposOwnerRepoCompareBaseHead

func (c *Client) GetReposOwnerRepoCompareBaseHead(accessToken, owner string, repo string, base string, head string) (*Compare, error)

func (*Client) GetSingleBranch

func (c *Client) GetSingleBranch(accessToken, owner, repo, branch string) (*Branch, error)

func (*Client) GetSingleCommitOfProject

func (c *Client) GetSingleCommitOfProject(ctx context.Context, accessToken, owner, repo, commitSha string) (*RepoCommit, error)

func (*Client) GetTrees

func (c *Client) GetTrees(ctx context.Context, owner, repo, sha string, level int) (gitee.Tree, error)

"Recursive" Assign a value of 1 to get the directory recursively sha Can be a branch name (such as master), Commit, or the SHA value of the directory Tree

func (*Client) ListBranches

func (c *Client) ListBranches(ctx context.Context, owner, repo string, opts *gitee.GetV5ReposOwnerRepoBranchesOpts) ([]gitee.Branch, error)

func (*Client) ListCommits added in v1.11.0

func (*Client) ListFiles

func (c *Client) ListFiles(ctx context.Context, owner string, repo string, number int, opts *gitee.GetV5ReposOwnerRepoPullsNumberFilesOpts) ([]gitee.PullRequestFiles, error)

func (*Client) ListHooks

func (c *Client) ListHooks(ctx context.Context, owner, repo string, opts *gitee.GetV5ReposOwnerRepoHooksOpts) ([]gitee.Hook, error)

func (*Client) ListOrganizationsForAuthenticatedUser

func (c *Client) ListOrganizationsForAuthenticatedUser(ctx context.Context) ([]gitee.Group, error)

func (*Client) ListPullRequests

func (c *Client) ListPullRequests(ctx context.Context, owner string, repo string, opts *gitee.GetV5ReposOwnerRepoPullsOpts) ([]gitee.PullRequest, error)

func (*Client) ListRepositoriesForAuthenticatedUser

func (c *Client) ListRepositoriesForAuthenticatedUser(accessToken, keyword string, page, perPage int) ([]Project, error)

func (*Client) ListRepositoriesForOrg

func (c *Client) ListRepositoriesForOrg(accessToken, org string, page, perPage int) ([]Project, error)

func (*Client) ListTags

func (c *Client) ListTags(ctx context.Context, accessToken, owner string, repo string) ([]Tag, error)

func (*Client) UpdateHook

func (c *Client) UpdateHook(ctx context.Context, owner, repo string, id int64, hook *git.Hook) (gitee.Hook, error)

type Commit

type Commit struct {
	Sha  string    `json:"sha"`
	Date time.Time `json:"date"`
}

type Compare

type Compare struct {
	Commits []CompareCommit `json:"commits"`
	Files   []CompareFiles  `json:"files"`
}

type CompareAuthor

type CompareAuthor struct {
	ID                int    `json:"id"`
	Login             string `json:"login"`
	Name              string `json:"name"`
	AvatarURL         string `json:"avatar_url"`
	URL               string `json:"url"`
	HTMLURL           string `json:"html_url"`
	Remark            string `json:"remark"`
	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"`
}

type CompareCommit

type CompareCommit struct {
	URL         string             `json:"url"`
	Sha         string             `json:"sha"`
	HTMLURL     string             `json:"html_url"`
	CommentsURL string             `json:"comments_url"`
	Commit      CompareInnerCommit `json:"commit"`
	Author      CompareAuthor      `json:"author"`
	Committer   CompareCommitter   `json:"committer"`
	Parents     []CompareParents   `json:"parents"`
}

type CompareCommitter

type CompareCommitter struct {
	ID                int    `json:"id"`
	Login             string `json:"login"`
	Name              string `json:"name"`
	AvatarURL         string `json:"avatar_url"`
	URL               string `json:"url"`
	HTMLURL           string `json:"html_url"`
	Remark            string `json:"remark"`
	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"`
}

type CompareFiles

type CompareFiles struct {
	Sha        string `json:"sha"`
	Filename   string `json:"filename"`
	Status     string `json:"status"`
	Additions  int    `json:"additions"`
	Deletions  int    `json:"deletions"`
	Changes    int    `json:"changes"`
	BlobURL    string `json:"blob_url"`
	RawURL     string `json:"raw_url"`
	ContentURL string `json:"content_url"`
	Patch      string `json:"patch"`
}

type CompareInnerCommit

type CompareInnerCommit struct {
	Author    RepoCommitAuthor `json:"author"`
	Committer RepoCommitAuthor `json:"committer"`
	Message   string           `json:"message"`
	Tree      CompareTree      `json:"tree"`
}

type CompareParents

type CompareParents struct {
	Sha string `json:"sha"`
	URL string `json:"url"`
}

type CompareTree

type CompareTree struct {
	Sha string `json:"sha"`
	URL string `json:"url"`
}

type EventEnterprise

type EventEnterprise struct {
	Name string `json:"name"`
	URL  string `json:"url"`
}

type EventRepo

type EventRepo struct {
	ID                int         `json:"id"`
	Name              string      `json:"name"`
	Path              string      `json:"path"`
	FullName          string      `json:"full_name"`
	Owner             EventUser   `json:"owner"`
	Private           bool        `json:"private"`
	HTMLURL           string      `json:"html_url"`
	URL               string      `json:"url"`
	Description       string      `json:"description"`
	Fork              bool        `json:"fork"`
	CreatedAt         time.Time   `json:"created_at"`
	UpdatedAt         time.Time   `json:"updated_at"`
	PushedAt          time.Time   `json:"pushed_at"`
	GitURL            string      `json:"git_url"`
	SSHURL            string      `json:"ssh_url"`
	CloneURL          string      `json:"clone_url"`
	SvnURL            string      `json:"svn_url"`
	GitHTTPURL        string      `json:"git_http_url"`
	GitSSHURL         string      `json:"git_ssh_url"`
	GitSvnURL         string      `json:"git_svn_url"`
	Homepage          interface{} `json:"homepage"`
	StargazersCount   int         `json:"stargazers_count"`
	WatchersCount     int         `json:"watchers_count"`
	ForksCount        int         `json:"forks_count"`
	Language          string      `json:"language"`
	HasIssues         bool        `json:"has_issues"`
	HasWiki           bool        `json:"has_wiki"`
	HasPages          bool        `json:"has_pages"`
	License           interface{} `json:"license"`
	OpenIssuesCount   int         `json:"open_issues_count"`
	DefaultBranch     string      `json:"default_branch"`
	Namespace         string      `json:"namespace"`
	NameWithNamespace string      `json:"name_with_namespace"`
	PathWithNamespace string      `json:"path_with_namespace"`
}

type EventType

type EventType string

EventType represents a gitee event type.

const (
	EventTypeMergeRequest EventType = "Merge Request Hook"
	EventTypePush         EventType = "Push Hook"
	EventTypeTagPush      EventType = "Tag Push Hook"
)

List of available event types.

func HookEventType

func HookEventType(r *http.Request) EventType

HookEventType returns the event type for the given request.

type EventUser

type EventUser struct {
	Login     string `json:"login"`
	AvatarURL string `json:"avatar_url"`
	HTMLURL   string `json:"html_url"`
	Type      string `json:"type"`
	SiteAdmin bool   `json:"site_admin"`
	ID        int    `json:"id"`
	Name      string `json:"name"`
	Email     string `json:"email"`
	Username  string `json:"username"`
	UserName  string `json:"user_name"`
	URL       string `json:"url"`
}

type Hook

type Hook struct {
	ID                  int       `json:"id"`
	URL                 string    `json:"url"`
	CreatedAt           time.Time `json:"created_at"`
	Password            string    `json:"password"`
	ProjectID           int       `json:"project_id"`
	Result              string    `json:"result"`
	ResultCode          int       `json:"result_code"`
	PushEvents          bool      `json:"push_events"`
	TagPushEvents       bool      `json:"tag_push_events"`
	IssuesEvents        bool      `json:"issues_events"`
	NoteEvents          bool      `json:"note_events"`
	MergeRequestsEvents bool      `json:"merge_requests_events"`
}

type Project

type Project struct {
	ID            int    `json:"id"`
	Name          string `json:"name"`
	DefaultBranch string `json:"default_branch,omitempty"`
}

type PullRequestEvent

type PullRequestEvent struct {
	Action         string                       `json:"action"`
	ActionDesc     string                       `json:"action_desc"`
	Project        PullRequestEventProject      `json:"project"`
	PullRequest    *PullRequestEventPullRequest `json:"pull_request"`
	Number         int                          `json:"number"`
	Iid            int                          `json:"iid"`
	Title          string                       `json:"title"`
	Body           interface{}                  `json:"body"`
	Languages      []string                     `json:"languages"`
	State          string                       `json:"state"`
	MergeStatus    string                       `json:"merge_status"`
	MergeCommitSha string                       `json:"merge_commit_sha"`
	URL            string                       `json:"url"`
	SourceBranch   string                       `json:"source_branch"`
	TargetBranch   string                       `json:"target_branch"`
	Repository     PullRequestEventRepository   `json:"repository"`
	Author         EventUser                    `json:"author"`
	UpdatedBy      EventUser                    `json:"updated_by"`
	Sender         EventUser                    `json:"sender"`
	TargetUser     EventUser                    `json:"target_user"`
	Enterprise     EventEnterprise              `json:"enterprise"`
	HookName       string                       `json:"hook_name"`
	HookID         int                          `json:"hook_id"`
	HookURL        string                       `json:"hook_url"`
	Password       string                       `json:"password"`
	Timestamp      interface{}                  `json:"timestamp"`
	Sign           string                       `json:"sign"`
}

type PullRequestEventBase

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

type PullRequestEventProject

type PullRequestEventProject struct {
	ID                int         `json:"id"`
	Language          interface{} `json:"language"`
	License           interface{} `json:"license"`
	Name              string      `json:"name"`
	NameWithNamespace string      `json:"name_with_namespace"`
	Namespace         string      `json:"namespace"`
	OpenIssuesCount   int         `json:"open_issues_count"`
	Path              string      `json:"path"`
	PathWithNamespace string      `json:"path_with_namespace"`
	Private           bool        `json:"private"`
	PushedAt          time.Time   `json:"pushed_at"`
	SSHURL            string      `json:"ssh_url"`
	StargazersCount   int         `json:"stargazers_count"`
	SvnURL            string      `json:"svn_url"`
	UpdatedAt         time.Time   `json:"updated_at"`
	URL               string      `json:"url"`
	WatchersCount     int         `json:"watchers_count"`
}

type PullRequestEventPullRequest

type PullRequestEventPullRequest struct {
	ID             int                   `json:"id"`
	Number         int                   `json:"number"`
	State          string                `json:"state"`
	HTMLURL        string                `json:"html_url"`
	DiffURL        string                `json:"diff_url"`
	PatchURL       string                `json:"patch_url"`
	Title          string                `json:"title"`
	Body           interface{}           `json:"body"`
	Languages      []string              `json:"languages"`
	CreatedAt      time.Time             `json:"created_at"`
	UpdatedAt      time.Time             `json:"updated_at"`
	ClosedAt       interface{}           `json:"closed_at"`
	MergedAt       interface{}           `json:"merged_at"`
	MergeCommitSha string                `json:"merge_commit_sha"`
	User           EventUser             `json:"user"`
	Head           *PullRequestEventBase `json:"head"`
	Base           PullRequestEventBase  `json:"base"`
	Merged         bool                  `json:"merged"`
	Mergeable      interface{}           `json:"mergeable"`
	MergeStatus    string                `json:"merge_status"`
	Comments       int                   `json:"comments"`
	Commits        int                   `json:"commits"`
	Additions      int                   `json:"additions"`
	Deletions      int                   `json:"deletions"`
	ChangedFiles   int                   `json:"changed_files"`
}

type PullRequestEventRepository

type PullRequestEventRepository struct {
	ID                int         `json:"id"`
	Name              string      `json:"name"`
	Path              string      `json:"path"`
	FullName          string      `json:"full_name"`
	Owner             EventUser   `json:"owner"`
	Private           bool        `json:"private"`
	HTMLURL           string      `json:"html_url"`
	URL               string      `json:"url"`
	Description       string      `json:"description"`
	Fork              bool        `json:"fork"`
	CreatedAt         time.Time   `json:"created_at"`
	UpdatedAt         time.Time   `json:"updated_at"`
	PushedAt          time.Time   `json:"pushed_at"`
	GitURL            string      `json:"git_url"`
	SSHURL            string      `json:"ssh_url"`
	CloneURL          string      `json:"clone_url"`
	SvnURL            string      `json:"svn_url"`
	GitHTTPURL        string      `json:"git_http_url"`
	GitSSHURL         string      `json:"git_ssh_url"`
	GitSvnURL         string      `json:"git_svn_url"`
	Homepage          interface{} `json:"homepage"`
	StargazersCount   int         `json:"stargazers_count"`
	WatchersCount     int         `json:"watchers_count"`
	ForksCount        int         `json:"forks_count"`
	Language          string      `json:"language"`
	HasIssues         bool        `json:"has_issues"`
	HasWiki           bool        `json:"has_wiki"`
	HasPages          bool        `json:"has_pages"`
	License           interface{} `json:"license"`
	OpenIssuesCount   int         `json:"open_issues_count"`
	DefaultBranch     string      `json:"default_branch"`
	Namespace         string      `json:"namespace"`
	NameWithNamespace string      `json:"name_with_namespace"`
	PathWithNamespace string      `json:"path_with_namespace"`
}

type PushEvent

type PushEvent struct {
	Ref                string            `json:"ref"`
	Before             string            `json:"before"`
	After              string            `json:"after"`
	Created            bool              `json:"created"`
	Deleted            bool              `json:"deleted"`
	Compare            string            `json:"compare"`
	Commits            []PushEventCommit `json:"commits"`
	TotalCommitsCount  int               `json:"total_commits_count"`
	CommitsMoreThanTen bool              `json:"commits_more_than_ten"`
	Repository         EventRepo         `json:"repository"`
	UserID             int               `json:"user_id"`
	UserName           string            `json:"user_name"`
	Pusher             EventUser         `json:"pusher"`
	Enterprise         EventEnterprise   `json:"enterprise"`
	HookName           string            `json:"hook_name"`
	HookID             int               `json:"hook_id"`
	HookURL            string            `json:"hook_url"`
	Password           string            `json:"password"`
	Timestamp          interface{}       `json:"timestamp"`
	Sign               string            `json:"sign"`
}

type PushEventCommit

type PushEventCommit struct {
	ID        string    `json:"id"`
	TreeID    string    `json:"tree_id"`
	ParentIds []string  `json:"parent_ids"`
	Distinct  bool      `json:"distinct"`
	Message   string    `json:"message"`
	Timestamp time.Time `json:"timestamp"`
	URL       string    `json:"url"`
	Author    EventUser `json:"author"`
	Committer EventUser `json:"committer"`
	Added     []string  `json:"added,omitempty"`
	Removed   []string  `json:"removed,omitempty"`
	Modified  []string  `json:"modified,omitempty"`
}

type RepoCommit

type RepoCommit struct {
	URL    string                `json:"url"`
	Sha    string                `json:"sha"`
	Commit RepoCommitInnerCommit `json:"commit"`
}

type RepoCommitAuthor

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

type RepoCommitInnerCommit

type RepoCommitInnerCommit struct {
	Author    RepoCommitAuthor `json:"author"`
	Committer RepoCommitAuthor `json:"committer"`
	Message   string           `json:"message"`
}

type Tag

type Tag struct {
	Name    string `json:"name"`
	Message string `json:"message"`
	Commit  Commit `json:"commit"`
}

type TagPushEvent

type TagPushEvent struct {
	Ref                string                 `json:"ref"`
	Before             string                 `json:"before"`
	After              string                 `json:"after"`
	Created            bool                   `json:"created"`
	Deleted            bool                   `json:"deleted"`
	Compare            string                 `json:"compare"`
	Commits            []TagPushEventCommit   `json:"commits"`
	HeadCommit         TagPushEventHeadCommit `json:"head_commit"`
	TotalCommitsCount  int                    `json:"total_commits_count"`
	CommitsMoreThanTen bool                   `json:"commits_more_than_ten"`
	Repository         EventRepo              `json:"repository"`
	Project            TagPushEventProject    `json:"project"`
	UserID             int                    `json:"user_id"`
	UserName           string                 `json:"user_name"`
	User               EventUser              `json:"user"`
	Pusher             EventUser              `json:"pusher"`
	Sender             EventUser              `json:"sender"`
	Enterprise         EventEnterprise        `json:"enterprise"`
	HookName           string                 `json:"hook_name"`
	HookID             int                    `json:"hook_id"`
	HookURL            string                 `json:"hook_url"`
	Password           string                 `json:"password"`
	Timestamp          interface{}            `json:"timestamp"`
	Sign               string                 `json:"sign"`
}

type TagPushEventCommit

type TagPushEventCommit struct {
	ID        string      `json:"id"`
	TreeID    string      `json:"tree_id"`
	ParentIds []string    `json:"parent_ids"`
	Distinct  bool        `json:"distinct"`
	Message   string      `json:"message"`
	Timestamp time.Time   `json:"timestamp"`
	URL       string      `json:"url"`
	Author    EventUser   `json:"author"`
	Committer EventUser   `json:"committer"`
	Added     interface{} `json:"added"`
	Removed   interface{} `json:"removed"`
	Modified  []string    `json:"modified"`
}

type TagPushEventHeadCommit

type TagPushEventHeadCommit struct {
	ID        string      `json:"id"`
	TreeID    string      `json:"tree_id"`
	ParentIds []string    `json:"parent_ids"`
	Distinct  bool        `json:"distinct"`
	Message   string      `json:"message"`
	Timestamp time.Time   `json:"timestamp"`
	URL       string      `json:"url"`
	Author    EventUser   `json:"author"`
	Committer EventUser   `json:"committer"`
	Added     interface{} `json:"added"`
	Removed   interface{} `json:"removed"`
	Modified  []string    `json:"modified"`
}

type TagPushEventProject

type TagPushEventProject struct {
	ID                int         `json:"id"`
	Name              string      `json:"name"`
	Path              string      `json:"path"`
	FullName          string      `json:"full_name"`
	Owner             EventUser   `json:"owner"`
	Private           bool        `json:"private"`
	HTMLURL           string      `json:"html_url"`
	URL               string      `json:"url"`
	Description       string      `json:"description"`
	Fork              bool        `json:"fork"`
	CreatedAt         time.Time   `json:"created_at"`
	UpdatedAt         time.Time   `json:"updated_at"`
	PushedAt          time.Time   `json:"pushed_at"`
	GitURL            string      `json:"git_url"`
	SSHURL            string      `json:"ssh_url"`
	CloneURL          string      `json:"clone_url"`
	SvnURL            string      `json:"svn_url"`
	GitHTTPURL        string      `json:"git_http_url"`
	GitSSHURL         string      `json:"git_ssh_url"`
	GitSvnURL         string      `json:"git_svn_url"`
	Homepage          interface{} `json:"homepage"`
	StargazersCount   int         `json:"stargazers_count"`
	WatchersCount     int         `json:"watchers_count"`
	ForksCount        int         `json:"forks_count"`
	Language          string      `json:"language"`
	HasIssues         bool        `json:"has_issues"`
	HasWiki           bool        `json:"has_wiki"`
	HasPages          bool        `json:"has_pages"`
	License           interface{} `json:"license"`
	OpenIssuesCount   int         `json:"open_issues_count"`
	DefaultBranch     string      `json:"default_branch"`
	Namespace         string      `json:"namespace"`
	NameWithNamespace string      `json:"name_with_namespace"`
	PathWithNamespace string      `json:"path_with_namespace"`
}

Jump to

Keyboard shortcuts

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