Documentation
¶
Index ¶
- Constants
- func GetChangedLinesFromDiff(diffString string) (int, int, error)
- func GetPaginatedRequest(apiURL string, header map[string]string, newObj func() interface{}, ...) error
- func RequestHTTP(method string, uri string, header map[string]string, data interface{}) ([]byte, http.Header, error)
- type Base
- type Branch
- type Change
- type Client
- type Comment
- type Commit
- type CommitStatus
- type CommitStatusState
- type Diff
- type EventType
- type Head
- type Issue
- type IssueComment
- type IssueLabel
- type IssueType
- type LinkHeader
- type LinkHeaderEntry
- type MergeMethod
- type PullRequest
- type PullRequestAction
- type PullRequestReviewState
- type PullRequestState
- type Push
- type Repository
- type UnauthorizedError
- type User
- type Webhook
- type WebhookEntry
Constants ¶
const ( IssueTypeIssue = IssueType("issue") IssueTypePullRequest = IssueType("pull_request") )
IssueType constants
const ( CommitStatusStateSuccess = CommitStatusState("success") CommitStatusStateFailure = CommitStatusState("failure") CommitStatusStateError = CommitStatusState("error") CommitStatusStatePending = CommitStatusState("pending") )
CommitStatusStates
const ( MergeMethodSquash = MergeMethod("squash") MergeMethodMerge = MergeMethod("merge") )
MergeMethod types
const ( EventTypePullRequest = EventType("pull_request") EventTypePush = EventType("push") EventTypeIssueComment = EventType("issue_comment") EventTypePullRequestReview = EventType("pull_request_review") EventTypePullRequestReviewComment = EventType("pull_request_review_comment") )
Event Types
const ( PullRequestStateOpen = PullRequestState("open") PullRequestStateClosed = PullRequestState("closed") )
Pull Request states
const ( PullRequestActionReOpen = PullRequestAction("reopened") PullRequestActionOpen = PullRequestAction("opened") PullRequestActionClose = PullRequestAction("closed") PullRequestActionSynchronize = PullRequestAction("synchronize") PullRequestActionLabeled = PullRequestAction("labeled") PullRequestActionUnlabeled = PullRequestAction("unlabeled") )
Pull Request actions
const ( PullRequestReviewStateApproved = PullRequestReviewState("approved") PullRequestReviewStateUnapproved = PullRequestReviewState("changes_requested") )
Pull Request review state
const (
FakeSha = "0000000000000000000000000000000000000000"
)
FakeSha is a fake SHA for a commit
Variables ¶
This section is empty.
Functions ¶
func GetChangedLinesFromDiff ¶
GetChangedLinesFromDiff parses a diffString and returns the number of changed lines (additions / deletions)
Types ¶
type Change ¶
type Change struct {
Filename string
OldFilename string
Additions int
Deletions int
Changes int // Changes should be equal to the addition of Additions and Deletions
}
Change is a diff of a changed file
type Client ¶
type Client interface {
Init() error
ListWebhook() ([]WebhookEntry, error)
RegisterWebhook(url string) error
DeleteWebhook(id int) error
ParseWebhook(http.Header, []byte) (*Webhook, error)
ListCommitStatuses(ref string) ([]CommitStatus, error)
SetCommitStatus(sha string, status CommitStatus) error
GetUserInfo(user string) (*User, error)
CanUserWriteToRepo(user User) (bool, error)
RegisterComment(issueType IssueType, issueNo int, body string) error
ListPullRequests(onlyOpen bool) ([]PullRequest, error)
GetPullRequest(id int) (*PullRequest, error)
MergePullRequest(id int, sha string, method MergeMethod, message string) error
GetPullRequestDiff(id int) (*Diff, error)
ListPullRequestCommits(id int) ([]Commit, error)
SetLabel(issueType IssueType, id int, label string) error
DeleteLabel(issueType IssueType, id int, label string) error
GetBranch(branch string) (*Branch, error)
}
Client is a git client interface
type CommitStatus ¶
type CommitStatus struct {
Context string
State CommitStatusState
Description string
TargetURL string
}
CommitStatus is a commit status body
type Diff ¶
type Diff struct {
Changes []Change
}
Diff is a diff between commits or of a pull-request
type Issue ¶
type Issue struct {
PullRequest *PullRequest
}
Issue is an issue related to the Comment
type IssueComment ¶
type IssueComment struct {
Comment Comment
Issue Issue
Author User
ReviewState PullRequestReviewState
}
IssueComment is a common structure for issue comment
type LinkHeader ¶
type LinkHeader []LinkHeaderEntry
LinkHeader is a header list for "Link"
func ParseLinkHeader ¶
func ParseLinkHeader(h string) LinkHeader
ParseLinkHeader parses url, rel from the header "Link"
func (LinkHeader) Find ¶
func (l LinkHeader) Find(rel string) *LinkHeaderEntry
Find finds a rel from the LinkHeader
type LinkHeaderEntry ¶
LinkHeaderEntry is an entry for a LinkHeader
type PullRequest ¶
type PullRequest struct {
ID int
Title string
State PullRequestState
Action PullRequestAction
Author User
URL string
Base Base
Head Head
Labels []IssueLabel
Mergeable bool
// LabelChanged
LabelChanged []IssueLabel
}
PullRequest is a common structure for pull request events
type PullRequestAction ¶
type PullRequestAction string
PullRequestAction is an action of the pull request event
type PullRequestReviewState ¶
type PullRequestReviewState string
PullRequestReviewState is a state of the pr's review
type PullRequestState ¶
type PullRequestState string
PullRequestState is a state of the pull request
type Repository ¶
Repository is a repository of the git
type UnauthorizedError ¶
type UnauthorizedError struct {
}
UnauthorizedError is an error struct for git clients
func (*UnauthorizedError) Error ¶
func (e *UnauthorizedError) Error() string
Error returns error string
type Webhook ¶
type Webhook struct {
EventType EventType
Repo Repository
Sender User
Push *Push
PullRequest *PullRequest
IssueComment *IssueComment
}
Webhook is a common structure for git webhooks github-specific or gitlab-specific webhook bodies are converted to this structure before being consumed
type WebhookEntry ¶
WebhookEntry is a body of registered webhook list