Documentation
¶
Index ¶
- func InferSubmoduleURL(baseURL string, mod *git.Submodule) string
- func IsErrNoMergeBase(err error) bool
- func IsErrRevisionNotExist(err error) bool
- func IsErrSubmoduleNotExist(err error) bool
- func NewError(err error) error
- func SetMockModuleStore(t *testing.T, mock ModuleStore)
- type Diff
- type DiffFile
- type DiffSection
- type Error
- type MockModuleStore
- func (m *MockModuleStore) ListTagsAfter(repoPath, after string, limit int) (*TagsPage, error)
- func (m *MockModuleStore) PullRequestMeta(headPath, basePath, headBranch, baseBranch string) (*PullRequestMeta, error)
- func (m *MockModuleStore) RepoAddRemote(repoPath, name, url string, opts ...git.AddRemoteOptions) error
- func (m *MockModuleStore) RepoDiffNameOnly(repoPath, base, head string, opts ...git.DiffNameOnlyOptions) ([]string, error)
- func (m *MockModuleStore) RepoLog(repoPath, rev string, opts ...git.LogOptions) ([]*git.Commit, error)
- func (m *MockModuleStore) RepoMergeBase(repoPath, base, head string, opts ...git.MergeBaseOptions) (string, error)
- func (m *MockModuleStore) RepoRemoveRemote(repoPath, name string, opts ...git.RemoveRemoteOptions) error
- func (m *MockModuleStore) RepoTags(repoPath string, opts ...git.TagsOptions) ([]string, error)
- type ModuleStore
- type PullRequestMeta
- type TagsPage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InferSubmoduleURL ¶
InferSubmoduleURL returns the inferred external URL of the submodule at best effort. The `baseURL` should be the URL of the current repository. If the submodule URL looks like a relative path, it assumes that the submodule is another repository on the same Gogs instance by appending it to the `baseURL` with the commit.
func IsErrNoMergeBase ¶
IsErrNoMergeBase returns true if the error is git.ErrNoMergeBase.
func IsErrRevisionNotExist ¶
IsErrRevisionNotExist returns true if the error is git.ErrRevisionNotExist.
func IsErrSubmoduleNotExist ¶
IsErrSubmoduleNotExist returns true if the error is git.ErrSubmoduleNotExist.
func SetMockModuleStore ¶
func SetMockModuleStore(t *testing.T, mock ModuleStore)
Types ¶
type Diff ¶
type Diff struct {
*git.Diff
Files []*DiffFile
}
Diff is a wrapper to git.Diff with helper methods.
func NewDiff ¶
func NewDiff(oldDiff *git.Diff) *Diff
NewDiff returns a new wrapper of given git.Diff.
type DiffFile ¶
type DiffFile struct {
*git.DiffFile
Sections []*DiffSection
}
DiffFile is a wrapper to git.DiffFile with helper methods.
func (*DiffFile) HighlightClass ¶
HighlightClass returns the detected highlight class for the file.
type DiffSection ¶
type DiffSection struct {
*git.DiffSection
// contains filtered or unexported fields
}
DiffSection is a wrapper to git.DiffSection with helper methods.
func (*DiffSection) ComputedInlineDiffFor ¶
func (s *DiffSection) ComputedInlineDiffFor(line *git.DiffLine) template.HTML
ComputedInlineDiffFor computes inline diff for the given line.
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error is a wrapper of a Git error, which handles not found.
type MockModuleStore ¶
type MockModuleStore struct {
// contains filtered or unexported fields
}
func (*MockModuleStore) ListTagsAfter ¶
func (m *MockModuleStore) ListTagsAfter(repoPath, after string, limit int) (*TagsPage, error)
func (*MockModuleStore) PullRequestMeta ¶
func (m *MockModuleStore) PullRequestMeta(headPath, basePath, headBranch, baseBranch string) (*PullRequestMeta, error)
func (*MockModuleStore) RepoAddRemote ¶
func (m *MockModuleStore) RepoAddRemote(repoPath, name, url string, opts ...git.AddRemoteOptions) error
func (*MockModuleStore) RepoDiffNameOnly ¶
func (m *MockModuleStore) RepoDiffNameOnly(repoPath, base, head string, opts ...git.DiffNameOnlyOptions) ([]string, error)
func (*MockModuleStore) RepoLog ¶
func (m *MockModuleStore) RepoLog(repoPath, rev string, opts ...git.LogOptions) ([]*git.Commit, error)
func (*MockModuleStore) RepoMergeBase ¶
func (m *MockModuleStore) RepoMergeBase(repoPath, base, head string, opts ...git.MergeBaseOptions) (string, error)
func (*MockModuleStore) RepoRemoveRemote ¶
func (m *MockModuleStore) RepoRemoveRemote(repoPath, name string, opts ...git.RemoveRemoteOptions) error
type ModuleStore ¶
type ModuleStore interface {
// AddRemote adds a new remote to the repository in given path.
RepoAddRemote(repoPath, name, url string, opts ...git.AddRemoteOptions) error
// RepoDiffNameOnly returns a list of changed files between base and head revisions
// of the repository in given path.
RepoDiffNameOnly(repoPath, base, head string, opts ...git.DiffNameOnlyOptions) ([]string, error)
// RepoLog returns a list of commits in the state of given revision of the repository
// in given path. The returned list is in reverse chronological order.
RepoLog(repoPath, rev string, opts ...git.LogOptions) ([]*git.Commit, error)
// RepoMergeBase returns merge base between base and head revisions of the repository
// in given path.
RepoMergeBase(repoPath, base, head string, opts ...git.MergeBaseOptions) (string, error)
// RepoRemoveRemote removes a remote from the repository in given path.
RepoRemoveRemote(repoPath, name string, opts ...git.RemoveRemoteOptions) error
// RepoTags returns a list of tags of the repository in given path.
RepoTags(repoPath string, opts ...git.TagsOptions) ([]string, error)
// GetPullRequestMeta gathers pull request metadata based on given head and base information.
PullRequestMeta(headPath, basePath, headBranch, baseBranch string) (*PullRequestMeta, error)
// ListTagsAfter returns a list of tags "after" (exclusive) given tag.
ListTagsAfter(repoPath, after string, limit int) (*TagsPage, error)
}
ModuleStore is the interface for Git operations.
NOTE: All methods are sorted in alphabetical order.
var Module ModuleStore = module{}
Module is a mockable interface for Git operations.
type PullRequestMeta ¶
type PullRequestMeta struct {
// The merge base of the pull request.
MergeBase string
// The commits that are requested to be merged.
Commits []*git.Commit
// The number of files changed.
NumFiles int
}
PullRequestMeta contains metadata for a pull request.
type TagsPage ¶
type TagsPage struct {
// List of tags in the current page.
Tags []string
// Whether the results include the latest tag.
HasLatest bool
// When results do not include the latest tag, an indicator of 'after' to go back.
PreviousAfter string
// Whether there are more tags in the next page.
HasNext bool
}
TagsPage contains a list of tags and pagination information.