giteeclient

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2024 License: Apache-2.0 Imports: 15 Imported by: 20

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenResponseWithReference

func GenResponseWithReference(e *sdk.NoteEvent, reply string) string

GenResponseWithReference generates response with reference to the original comment.

func SortBotComments

func SortBotComments(c []BotComment)

func ValidateWebhook

func ValidateWebhook(
	w http.ResponseWriter,
	r *http.Request,
	tokenGenerator func() string,
) (eventType string, eventGUID string, payload []byte, status int, ok bool)

ValidateWebhook ensures that the provided request conforms to the format of a Gitee webhook and the payload can be validated with the provided hmac secret. It returns the event type, the event guid, the payload of the request, whether the webhook is valid or not, and finally the resultant HTTP status code

Types

type BotComment

type BotComment struct {
	CommentID int32
	Body      string
	CreatedAt time.Time
}

func FindBotComment

func FindBotComment(
	allComments []sdk.PullRequestComments,
	botName string, isTargetComment func(string) bool,
) []BotComment

func (BotComment) IsAvailable

func (c BotComment) IsAvailable() bool

type Client

type Client interface {
	CreatePullRequest(org, repo, title, body, head, base string, canModify bool) (sdk.PullRequest, error)
	GetPullRequests(org, repo string, opts ListPullRequestOpt) ([]sdk.PullRequest, error)
	UpdatePullRequest(org, repo string, number int32, param sdk.PullRequestUpdateParam) (sdk.PullRequest, error)

	ListCollaborators(org, repo string) ([]sdk.ProjectMember, error)
	IsCollaborator(owner, repo, login string) (bool, error)
	IsMember(org, login string) (bool, error)
	RemoveRepoMember(org, repo, login string) error
	AddRepoMember(org, repo, login, permission string) error

	GetRef(org, repo, ref string) (string, error)
	GetPullRequestChanges(org, repo string, number int32) ([]sdk.PullRequestFiles, error)
	GetPRLabels(org, repo string, number int32) ([]sdk.Label, error)
	ListPRComments(org, repo string, number int32) ([]sdk.PullRequestComments, error)
	ListPrIssues(org, repo string, number int32) ([]sdk.Issue, error)
	DeletePRComment(org, repo string, ID int32) error
	CreatePRComment(org, repo string, number int32, comment string) error
	UpdatePRComment(org, repo string, commentID int32, comment string) error
	AddPRLabel(org, repo string, number int32, label string) error
	AddMultiPRLabel(org, repo string, number int32, label []string) error
	RemovePRLabel(org, repo string, number int32, label string) error
	RemovePRLabels(org, repo string, number int32, labels []string) error
	ReplacePRAllLabels(owner, repo string, number int32, labels []string) error
	ListPROperationLogs(org, repo string, number int32) ([]sdk.OperateLog, error)

	ClosePR(org, repo string, number int32) error
	AssignPR(owner, repo string, number int32, logins []string) error
	UnassignPR(owner, repo string, number int32, logins []string) error
	GetPRCommits(org, repo string, number int32) ([]sdk.PullRequestCommits, error)

	GetGiteePullRequest(org, repo string, number int32) (sdk.PullRequest, error)
	GetPRCommit(org, repo, SHA string) (sdk.RepoCommit, error)
	MergePR(owner, repo string, number int32, opt sdk.PullRequestMergePutParam) error

	GetRepos(org string) ([]sdk.Project, error)
	CreateRepo(org string, repo sdk.RepositoryPostParam) error
	UpdateRepo(org, repo string, info sdk.RepoPatchParam) error
	GetRepo(org, repo string) (sdk.Project, error)
	GetGiteeRepo(org, repo string) (sdk.Project, error)

	SetRepoReviewer(org, repo string, reviewer sdk.SetRepoReviewer) error
	CreateRepoLabel(org, repo, label, color string) error
	GetRepoLabels(owner, repo string) ([]sdk.Label, error)

	AssignGiteeIssue(org, repo string, number string, login string) error
	UnassignGiteeIssue(org, repo string, number string, login string) error
	RemoveIssueAssignee(org, repo string, number string) error
	CreateIssueComment(org, repo string, number string, comment string) error
	UpdateIssueComment(org, repo string, commentID int32, comment string) error
	ListIssueComments(org, repo, number string) ([]sdk.Note, error)
	GetIssueLabels(org, repo, number string) ([]sdk.Label, error)
	RemoveIssueLabel(org, repo, number, label string) error
	RemoveIssueLabels(org, repo, number string, label []string) error
	AddIssueLabel(org, repo, number, label string) error
	AddMultiIssueLabel(org, repo, number string, label []string) error
	CloseIssue(owner, repo string, number string) error
	ReopenIssue(owner, repo string, number string) error
	UpdateIssue(owner, number string, param sdk.IssueUpdateParam) (sdk.Issue, error)
	GetIssue(org, repo, number string) (sdk.Issue, error)
	HasLinkPullRequests(owner, repo, number string) (bool, error)
	GetIssueOperateLogs(owner, repo, number string) ([]sdk.OperateLog, error)

	AddProjectLabels(org, repo string, label []string) error
	UpdateProjectLabels(org, repo string, label []string) error

	CreateBranch(org, repo, branch, parentBranch string) error
	GetRepoAllBranch(org, repo string) ([]sdk.Branch, error)
	SetProtectionBranch(org, repo, branch string) error
	CancelProtectionBranch(org, repo, branch string) error

	CreateFile(org, repo, branch, path, content, commitMsg string) (sdk.CommitContent, error)
	GetPathContent(org, repo, path, ref string) (sdk.Content, error)
	GetDirectoryTree(org, repo, sha string, recursive int32) (sdk.Tree, error)

	GetBot() (sdk.User, error)
	GetUserPermissionsOfRepo(org, repo, login string) (sdk.ProjectMemberPermission, error)
	GetEnterprisesMember(enterprise, login string) (sdk.EnterpriseMember, error)

	CreateIssue(org, repo, title, body string) (sdk.Issue, error)
	PatchFile(owner, repo, path, branch, content, sha, message string) error
}

Client interface for Gitee API

func NewClient

func NewClient(getToken func() []byte) Client

type ErrorForbidden

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

func (ErrorForbidden) Error

func (e ErrorForbidden) Error() string

type ListPullRequestOpt

type ListPullRequestOpt struct {
	State           string
	Head            string
	Base            string
	Sort            string
	Direction       string
	MilestoneNumber int32
	Labels          []string
}

Jump to

Keyboard shortcuts

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