engine

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package engine contains interfaces for different git providers.

Index

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

func (g *Github) Compare(ctx context.Context, fromSHA, toSHA string) (git.CommitsComparison, error)

Compare two commits by their SHA.

func (*Github) GetLastCommitOfBranch

func (g *Github) GetLastCommitOfBranch(ctx context.Context, branchName string) (string, error)

GetLastCommitOfBranch returns the SHA or alias of the last commit in the branch.

func (*Github) ListPRsOfCommit

func (g *Github) ListPRsOfCommit(ctx context.Context, sha string) ([]git.PullRequest, error)

ListPRsOfCommit returns pull requests associated with commit by the given SHA.

func (*Github) ListTags

func (g *Github) ListTags(ctx context.Context) ([]git.Tag, error)

ListTags returns all tags of the repository.

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

func (g *Gitlab) Compare(ctx context.Context, fromSHA, toSHA string) (git.CommitsComparison, error)

Compare two commits by their SHA.

func (*Gitlab) GetLastCommitOfBranch

func (g *Gitlab) GetLastCommitOfBranch(ctx context.Context, branchName string) (string, error)

GetLastCommitOfBranch returns the SHA or alias of the last commit in the branch.

func (*Gitlab) ListPRsOfCommit

func (g *Gitlab) ListPRsOfCommit(ctx context.Context, sha string) ([]git.PullRequest, error)

ListPRsOfCommit returns pull requests associated with commit by the given SHA.

func (*Gitlab) ListTags

func (g *Gitlab) ListTags(ctx context.Context) ([]git.Tag, error)

ListTags returns all tags of the repository.

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) ListTags added in v0.7.0

func (mock *InterfaceMock) ListTags(ctx context.Context) ([]git.Tag, error)

ListTags calls ListTagsFunc.

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

Compare returns an error.

func (Unsupported) GetLastCommitOfBranch added in v0.9.0

func (Unsupported) GetLastCommitOfBranch(context.Context, string) (string, error)

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.

func (Unsupported) ListTags added in v0.9.0

func (Unsupported) ListTags(context.Context) ([]git.Tag, error)

ListTags returns an error.

Jump to

Keyboard shortcuts

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