Documentation ¶
Index ¶
- Constants
- Variables
- type Author
- type Client
- func (c Client) Commits(project string, repo string, co CommitOptions) (CommitList, error)
- func (c Client) PullRequest(project string, repo string, id int) (PullRequest, error)
- func (c Client) PullRequests(project string, repo string) (PullRequests, error)
- func (c Client) RawRequest(url string) ([]byte, int, error)
- func (c Client) Repository(project string, repo string) (Repository, error)
- func (c Client) Status(sha string) (StatusList, error)
- func (c Client) Timeout() int
- func (c Client) Useragent() string
- type Commit
- type CommitList
- type CommitOptions
- type GitRef
- type Link
- type Links
- type Project
- type PullRequest
- func (pr PullRequest) ApprovalStatus(showEmojis bool) string
- func (pr PullRequest) IsApproved() bool
- func (pr PullRequest) IsWorkInProgress() bool
- func (pr PullRequest) OpenSince() string
- func (pr PullRequest) RepoSlug() string
- func (pr PullRequest) ReviewedBy() string
- func (pr PullRequest) String() string
- type PullRequests
- type Repository
- type RepositoryLinks
- type Status
- type StatusList
- type User
Constants ¶
const ( // PullRequestReviewStatusNeedsWork is the status for a pull request review // when the pull request needs more work before it can be merged. PullRequestReviewStatusNeedsWork = "NEEDS_WORK" // PullRequestReviewStatusApproved is the status for an approved pull request review PullRequestReviewStatusApproved = "APPROVED" // PullRequestReviewStatusUnapproved is the status for an unapproved pull request review PullRequestReviewStatusUnapproved = "UNAPPROVED" PullRequestUserRoleAuthor = "AUTHOR" PullRequestUserRoleReviewer = "REVIEWER" )
const ( // StatusSuccess represents the success status StatusSuccess = "SUCCESSFUL" // StatusFailed represents the failed status StatusFailed = "FAILED" // StatusRunning represents the running status StatusInProgress = "INPROGRESS" // StatusUnknown represents the unknown status StatusUnknown = "UNKNOWN" )
Variables ¶
var APIPaths = map[string]string{
"base": "https://%s/rest/api/1.0/%s",
"repo": "projects/%s/repos/%s",
"repoCommits": "projects/%s/repos/%s/commits",
"browse": "projects/%s/repos/%s/browse/%s",
"pullRequests": "projects/%s/repos/%s/pull-requests",
"pullRequest": "projects/%s/repos/%s/pull-requests/%s",
}
var StatusPaths = map[string]string{
"base": "https://%s/rest/build-status/1.0/%s",
"status": "commits/%s",
}
Functions ¶
This section is empty.
Types ¶
type Author ¶
type Author struct { User User `json:"user"` Role string `json:"role"` HasApproved bool `json:"approved"` Status string `json:"status"` }
Author is the creator of a Pull Request
type Client ¶
Client is a Bitbucket client that is used for storing server configuration, authentiation and to run the actual Bitbucket requests.
func (Client) Commits ¶
func (c Client) Commits(project string, repo string, co CommitOptions) (CommitList, error)
Commits returns a list of Commits for a given repo in a given project
func (Client) PullRequest ¶
PullRequest returns a single PullRequest in a given repo in a given project.
func (Client) PullRequests ¶
func (c Client) PullRequests(project string, repo string) (PullRequests, error)
PullRequests returns a list of PullRequests for a given repo in a given project. @TODO add support for pagination when there are lots of pull requests? @TODO add support for ofset when there are lots of pull requests
func (Client) RawRequest ¶
RawRequest does a API request and returns content as a string. This is just a helper method used by other Client functions. https://docs.atlassian.com/bitbucket-server/rest/5.16.0/bitbucket-rest.html
func (Client) Repository ¶
func (c Client) Repository(project string, repo string) (Repository, error)
Repository returns a single Repo in a given project.
func (Client) Status ¶
func (c Client) Status(sha string) (StatusList, error)
Status returns a status for a given commit
type Commit ¶
type Commit struct { ID string `json:"id"` DisplayID string `json:"displayId"` Author User `json:"author"` AuthorTimestamp int64 `json:"authorTimestamp"` Committer User `json:"committer"` CommitterTimestamp int64 `json:"committerTimestamp"` Message string `json:"message"` Parents []struct { ID string `json:"id"` DisplayID string `json:"displayId"` } `json:"parents"` Properties struct { JIRAIssueKeys []string `json:"jira-key"` } `json:"properties"` }
Commit is a commit in a branch
func (Commit) JIRAIssueKeys ¶
JIRAIssueKeys returns the JIRA issue key from the commit
type CommitList ¶
type CommitList struct { Size int `json:"size"` IsLastPage bool `json:"isLastPage"` Start int `json:"start"` Limit int `json:"limit"` NextPageStart int `json:"nextPageStart"` Values []Commit `json:"values"` }
CommitList is a list of commits
type CommitOptions ¶
type CommitOptions struct { FollowRenames bool `url:"followRenames,omitempty"` IngoreMissing bool `url:"ignoreMissing,omitempty"` // if present, controls how merge commits should be filtered. Can be either exclude, // to exclude merge commits, include, to include both merge commits and non-merge // commits or only, to only return merge commits. Merges string `url:"merges,omitempty"` Path string `url:"path,omitempty"` Since string `url:"since,omitempty"` Until string `url:"until,omitempty"` WithCounts bool `url:"withCounts,omitempty"` Limit int `url:"limit,omitempty"` Start int `url:"start,omitempty"` }
CommitOptions is the options for a commit
func (CommitOptions) ToQueryString ¶
func (co CommitOptions) ToQueryString() string
ToQueryString returns the CommitOptions as a query string
type GitRef ¶
type GitRef struct { ID string `json:"id"` DisplayID string `json:"displayId"` LatestCommit string `json:"latestCommit"` Repository Repository `json:"repository"` }
GitRef is the git reference of a Pull Request
type Project ¶
type Project struct { Key string `json:"key"` ID int `json:"id"` Name string `json:"name"` Description string `json:"description"` }
Project is the project reference of a Pull Request
type PullRequest ¶
type PullRequest struct { ID int `json:"id"` Title string `json:"title"` Description string `json:"description,omitempty"` State string `json:"state"` IsOpen bool `json:"open"` IsClosed bool `json:"closed"` CreatedDate int64 `json:"createdDate"` UpdatedDate int64 `json:"updatedDate"` FromRef GitRef `json:"fromRef"` ToRef GitRef `json:"toRef"` Author Author `json:"author"` Reviewers []Author `json:"reviewers"` Links struct { Self []struct { Href string `json:"href"` } `json:"self"` } `json:"links"` }
PullRequest is a single Pull Request
func (PullRequest) ApprovalStatus ¶
func (pr PullRequest) ApprovalStatus(showEmojis bool) string
ApprovalStatus returns a human readable approval status
func (PullRequest) IsApproved ¶
func (pr PullRequest) IsApproved() bool
IsApproved return if the pull request is approved by reviewers
func (PullRequest) IsWorkInProgress ¶
func (pr PullRequest) IsWorkInProgress() bool
IsWorkInProgress returns true if the Pull Request is Work In Progress
func (PullRequest) OpenSince ¶
func (pr PullRequest) OpenSince() string
OpenSince returns how long the Pull Request has been open in human readable format.
func (PullRequest) RepoSlug ¶
func (pr PullRequest) RepoSlug() string
RepoSlug returns the combind string of repo and project
func (PullRequest) ReviewedBy ¶
func (pr PullRequest) ReviewedBy() string
ReviewedBy returns a list of reviewers as a string
func (PullRequest) String ¶
func (pr PullRequest) String() string
String returns the Pull Request as a string
type PullRequests ¶
type PullRequests struct { Size int `json:"size"` Limit int `json:"limit"` IsLastPage bool `json:"isLastPage"` List []PullRequest `json:"values"` }
PullRequests is a list of Pull Requests
type Repository ¶
type Repository struct { Slug string `json:"slug"` ID int `json:"id"` Name string `json:"name"` Description string `json:"description"` Project Project `json:"project"` Links RepositoryLinks `json:"links"` }
Repository is the repository reference of a Pull Request
type RepositoryLinks ¶
RepositoryLinks are links to the repository
type Status ¶
type Status struct { State string `json:"state"` Key string `json:"key"` Name string `json:"name"` URL string `json:"url"` Description string `json:"description"` DateAdded int `json:"dateAdded"` }
Status represents a Bitbucket commit status
type StatusList ¶
type StatusList struct { Size int `json:"size"` Limit int `json:"limit"` IsLastPage bool `json:"isLastPage"` Start int `json:"start"` Values []Status `json:"values"` }
StatusList is a list of Status
func (StatusList) State ¶
func (s StatusList) State() string
State returns the aggregated state of all statuses in the list