stash

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

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) Branch

func (p *Push) Branch() string

Branch returns the branch of the push

func (*Push) ContainsFile

func (p *Push) ContainsFile(file string) bool

ContainsFile checks to see if a given file is in the push.

func (*Push) Files

func (p *Push) Files() []string

Files returns a slice containing filenames that were added/modified

func (*Push) IsMaster

func (p *Push) IsMaster() bool

IsMaster detects if the branch is master.

func (*Push) Name

func (p *Push) Name() string

Name returns the name of the provider to be used in configuration

func (*Push) Org

func (p *Push) Org() string

Org returns the name of the project.

func (*Push) Repo

func (p *Push) Repo() string

Repo returns the name of the repo.

func (*Push) SetCommitStatus

func (p *Push) SetCommitStatus(s git.Status)

SetCommitStatus sets a commit status

type StashConfig

type StashConfig struct {
	Username string
	Token    string
	Endpoint string
	Branch   string
	Logger   logrus.FieldLogger
}

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

Jump to

Keyboard shortcuts

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