Documentation
¶
Overview ¶
Package engine contains interfaces for different git providers.
Index ¶
- type Github
- func (g *Github) Compare(ctx context.Context, fromSHA, toSHA string) (git.CommitsComparison, error)
- func (g *Github) GetLastCommitOfBranch(ctx context.Context, branchName string) (string, error)
- func (g *Github) ListPRsOfCommit(ctx context.Context, sha string) ([]git.PullRequest, error)
- func (g *Github) ListTags(ctx context.Context) ([]git.Tag, error)
- type GithubParams
- type Gitlab
- func (g *Gitlab) Compare(ctx context.Context, fromSHA, toSHA string) (git.CommitsComparison, error)
- func (g *Gitlab) GetLastCommitOfBranch(ctx context.Context, branchName string) (string, error)
- func (g *Gitlab) ListPRsOfCommit(ctx context.Context, sha string) ([]git.PullRequest, error)
- func (g *Gitlab) ListTags(ctx context.Context) ([]git.Tag, error)
- type Interface
- type InterfaceMock
- func (mock *InterfaceMock) Compare(ctx context.Context, fromSHA string, toSHA string) (git.CommitsComparison, error)
- func (mock *InterfaceMock) CompareCalls() []struct{ ... }
- func (mock *InterfaceMock) GetLastCommitOfBranch(ctx context.Context, branch string) (string, error)
- func (mock *InterfaceMock) GetLastCommitOfBranchCalls() []struct{ ... }
- func (mock *InterfaceMock) ListPRsOfCommit(ctx context.Context, sha string) ([]git.PullRequest, error)
- func (mock *InterfaceMock) ListPRsOfCommitCalls() []struct{ ... }
- func (mock *InterfaceMock) ListTags(ctx context.Context) ([]git.Tag, error)
- func (mock *InterfaceMock) ListTagsCalls() []struct{ ... }
- type Unsupported
- func (Unsupported) Compare(context.Context, string, string) (git.CommitsComparison, error)
- func (Unsupported) GetLastCommitOfBranch(context.Context, string) (string, error)
- func (Unsupported) ListPRsOfCommit(context.Context, string) ([]git.PullRequest, error)
- func (Unsupported) ListTags(context.Context) ([]git.Tag, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Github ¶
type Github struct {
// contains filtered or unexported fields
}
Github implements Repository with github API below it.
func NewGithub ¶
func NewGithub(ctx context.Context, params GithubParams) (*Github, error)
NewGithub makes new instance of Github.
func (*Github) GetLastCommitOfBranch ¶
GetLastCommitOfBranch returns the SHA or alias of the last commit in the branch.
func (*Github) ListPRsOfCommit ¶
ListPRsOfCommit returns pull requests associated with commit by the given SHA.
type GithubParams ¶ added in v0.7.0
type GithubParams struct {
Owner string
Name string
BasicAuthUsername string
BasicAuthPassword string
HTTPClient http.Client
}
GithubParams contains parameters for github engine.
type Gitlab ¶
type Gitlab struct {
// contains filtered or unexported fields
}
Gitlab implements Repository with gitlab API below it.
func NewGitlab ¶
func NewGitlab(ctx context.Context, token, baseURL, projectID string, httpCl http.Client) (*Gitlab, error)
NewGitlab creates a new Gitlab engine.
func (*Gitlab) GetLastCommitOfBranch ¶
GetLastCommitOfBranch returns the SHA or alias of the last commit in the branch.
func (*Gitlab) ListPRsOfCommit ¶
ListPRsOfCommit returns pull requests associated with commit by the given SHA.
type Interface ¶
type Interface interface {
// Compare returns comparison between two commits,
// given by their SHA.
Compare(ctx context.Context, fromSHA, toSHA string) (git.CommitsComparison, error)
// ListPRsOfCommit returns pull/merge requests
// associated with the commit, given by its SHA.
ListPRsOfCommit(ctx context.Context, sha string) ([]git.PullRequest, error)
// ListTags returns tags of the repository in descending order of creation.
ListTags(ctx context.Context) ([]git.Tag, error)
// GetLastCommitOfBranch returns the SHA or alias of the last commit in the branch.
GetLastCommitOfBranch(ctx context.Context, branch string) (string, error)
}
Interface defines methods to retrieve information about repository.
type InterfaceMock ¶ added in v0.7.0
type InterfaceMock struct {
// CompareFunc mocks the Compare method.
CompareFunc func(ctx context.Context, fromSHA string, toSHA string) (git.CommitsComparison, error)
// GetLastCommitOfBranchFunc mocks the GetLastCommitOfBranch method.
GetLastCommitOfBranchFunc func(ctx context.Context, branch string) (string, error)
// ListPRsOfCommitFunc mocks the ListPRsOfCommit method.
ListPRsOfCommitFunc func(ctx context.Context, sha string) ([]git.PullRequest, error)
// ListTagsFunc mocks the ListTags method.
ListTagsFunc func(ctx context.Context) ([]git.Tag, error)
// contains filtered or unexported fields
}
InterfaceMock is a mock implementation of Interface.
func TestSomethingThatUsesInterface(t *testing.T) {
// make and configure a mocked Interface
mockedInterface := &InterfaceMock{
CompareFunc: func(ctx context.Context, fromSHA string, toSHA string) (git.CommitsComparison, error) {
panic("mock out the Compare method")
},
GetLastCommitOfBranchFunc: func(ctx context.Context, branch string) (string, error) {
panic("mock out the GetLastCommitOfBranch method")
},
ListPRsOfCommitFunc: func(ctx context.Context, sha string) ([]git.PullRequest, error) {
panic("mock out the ListPRsOfCommit method")
},
ListTagsFunc: func(ctx context.Context) ([]git.Tag, error) {
panic("mock out the ListTags method")
},
}
// use mockedInterface in code that requires Interface
// and then make assertions.
}
func (*InterfaceMock) Compare ¶ added in v0.7.0
func (mock *InterfaceMock) Compare(ctx context.Context, fromSHA string, toSHA string) (git.CommitsComparison, error)
Compare calls CompareFunc.
func (*InterfaceMock) CompareCalls ¶ added in v0.7.0
func (mock *InterfaceMock) CompareCalls() []struct { Ctx context.Context FromSHA string ToSHA string }
CompareCalls gets all the calls that were made to Compare. Check the length with:
len(mockedInterface.CompareCalls())
func (*InterfaceMock) GetLastCommitOfBranch ¶ added in v0.7.0
func (mock *InterfaceMock) GetLastCommitOfBranch(ctx context.Context, branch string) (string, error)
GetLastCommitOfBranch calls GetLastCommitOfBranchFunc.
func (*InterfaceMock) GetLastCommitOfBranchCalls ¶ added in v0.7.0
func (mock *InterfaceMock) GetLastCommitOfBranchCalls() []struct { Ctx context.Context Branch string }
GetLastCommitOfBranchCalls gets all the calls that were made to GetLastCommitOfBranch. Check the length with:
len(mockedInterface.GetLastCommitOfBranchCalls())
func (*InterfaceMock) ListPRsOfCommit ¶ added in v0.7.0
func (mock *InterfaceMock) ListPRsOfCommit(ctx context.Context, sha string) ([]git.PullRequest, error)
ListPRsOfCommit calls ListPRsOfCommitFunc.
func (*InterfaceMock) ListPRsOfCommitCalls ¶ added in v0.7.0
func (mock *InterfaceMock) ListPRsOfCommitCalls() []struct { Ctx context.Context Sha string }
ListPRsOfCommitCalls gets all the calls that were made to ListPRsOfCommit. Check the length with:
len(mockedInterface.ListPRsOfCommitCalls())
func (*InterfaceMock) ListTagsCalls ¶ added in v0.7.0
func (mock *InterfaceMock) ListTagsCalls() []struct { Ctx context.Context }
ListTagsCalls gets all the calls that were made to ListTags. Check the length with:
len(mockedInterface.ListTagsCalls())
type Unsupported ¶ added in v0.9.0
type Unsupported struct{}
Unsupported is a git engine implementation that returns an error for each method.
func (Unsupported) Compare ¶ added in v0.9.0
func (Unsupported) Compare(context.Context, string, string) (git.CommitsComparison, error)
Compare returns an error.
func (Unsupported) GetLastCommitOfBranch ¶ added in v0.9.0
GetLastCommitOfBranch returns an error.
func (Unsupported) ListPRsOfCommit ¶ added in v0.9.0
func (Unsupported) ListPRsOfCommit(context.Context, string) ([]git.PullRequest, error)
ListPRsOfCommit returns an error.