Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIDiff ¶
type APIDiff struct {
Destination struct {
Path string `json:"toString"`
} `json:"path"`
}
APIDiff is a diff returned by the Stash API
type APIResponse ¶
type APIResponse struct {
PagedAPIResponse
Diffs []APIDiff `json:"values"`
}
APIResponse is the response from Stash API
type FileContentsResponse ¶
type FileContentsResponse struct {
PagedAPIResponse
Lines []map[string]string `json:"lines"`
}
FileContentsResponse contains response from Stash when you fetch a file
type FileService ¶
type FileService struct {
StashEndpoint string
StashToken string
StashUsername string
Logger logrus.FieldLogger
// contains filtered or unexported fields
}
FileService is for working with repositories
func (*FileService) DecodeURL ¶
func (f *FileService) DecodeURL(url string) (org, repo, path, branch string)
DecodeURL takes a url and returns the org, repo, path and branch
func (*FileService) Download ¶
func (f *FileService) Download(org, repo, path, branch string) (string, error)
Download downloads a file from Stash. Stash's API returns the file's contents as a paginated list of lines
func (*FileService) EncodeURL ¶
func (f *FileService) EncodeURL(org, repo, path, branch string) string
EncodeURL returns the git url for a given org, repo, path and branch
type PagedAPIResponse ¶
type PagedAPIResponse struct {
IsLastPage bool `json:"isLastPage"`
Start int `json:"start"`
NextPageStart int `json:"nextPageStart"`
}
PagedAPIResponse contains the fields needed for paged Stash APIs, described here: https://docs.atlassian.com/bitbucket-server/rest/5.8.0/bitbucket-rest.html#paging-params
type Push ¶
type Push struct {
Payload WebhookPayload
ChangedFiles []string
StashEndpoint string
StashUsername string
StashToken string
Logger logrus.FieldLogger
}
Push contains data about a push full of commits
func NewPush ¶
func NewPush(payload WebhookPayload, cfg StashConfig) (*Push, error)
NewPush creates a new Push
func (*Push) ContainsFile ¶
ContainsFile checks to see if a given file is in the push.
func (*Push) SetCommitStatus ¶
SetCommitStatus sets a commit status
type StashConfig ¶
type WebhookChange ¶
type WebhookChange struct {
RefID string `json:"refId"`
FromHash string `json:"fromHash"`
ToHash string `json:"toHash"`
}
WebhookChange is a change object from the webhook
func (*WebhookChange) Branch ¶
func (c *WebhookChange) Branch() string
Find the branch in the webhook payload
func (*WebhookChange) IsMaster ¶
func (c *WebhookChange) IsMaster() bool
IsMaster detects if a change was on master
type WebhookPayload ¶
type WebhookPayload struct {
EventKey string `json:"eventKey,omitempty"`
Repository struct {
Slug string `json:"slug"`
Project struct {
Key string `json:"key"`
} `json:"project"`
} `json:"repository"`
// bitbucket and old stash use different keys for `changes` but
// the structure is the same
BBSChanges []WebhookChange `json:"changes"`
StashChanges []WebhookChange `json:"refChanges"`
IsOldStash bool
}
WebhookPayload is the payload from the webhook