1
0

module.go 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package gitutil
  2. import (
  3. "github.com/gogs/git-module"
  4. )
  5. // ModuleStore is the interface for Git operations.
  6. type ModuleStore interface {
  7. // RemoteAdd adds a new remote to the repository in given path.
  8. RemoteAdd(repoPath, name, url string, opts ...git.RemoteAddOptions) error
  9. // DiffNameOnly returns a list of changed files between base and head revisions
  10. // of the repository in given path.
  11. DiffNameOnly(repoPath, base, head string, opts ...git.DiffNameOnlyOptions) ([]string, error)
  12. // Log returns a list of commits in the state of given revision of the
  13. // repository in given path. The returned list is in reverse chronological
  14. // order.
  15. Log(repoPath, rev string, opts ...git.LogOptions) ([]*git.Commit, error)
  16. // MergeBase returns merge base between base and head revisions of the
  17. // repository in given path.
  18. MergeBase(repoPath, base, head string, opts ...git.MergeBaseOptions) (string, error)
  19. // RemoteRemove removes a remote from the repository in given path.
  20. RemoteRemove(repoPath, name string, opts ...git.RemoteRemoveOptions) error
  21. // RepoTags returns a list of tags of the repository in given path.
  22. RepoTags(repoPath string, opts ...git.TagsOptions) ([]string, error)
  23. // PullRequestMeta gathers pull request metadata based on given head and base
  24. // information.
  25. PullRequestMeta(headPath, basePath, headBranch, baseBranch string) (*PullRequestMeta, error)
  26. // ListTagsAfter returns a list of tags "after" (exclusive) given tag.
  27. ListTagsAfter(repoPath, after string, limit int) (*TagsPage, error)
  28. }
  29. // module holds the real implementation.
  30. type module struct{}
  31. func (module) RemoteAdd(repoPath, name, url string, opts ...git.RemoteAddOptions) error {
  32. return git.RemoteAdd(repoPath, name, url, opts...)
  33. }
  34. func (module) DiffNameOnly(repoPath, base, head string, opts ...git.DiffNameOnlyOptions) ([]string, error) {
  35. return git.DiffNameOnly(repoPath, base, head, opts...)
  36. }
  37. func (module) Log(repoPath, rev string, opts ...git.LogOptions) ([]*git.Commit, error) {
  38. return git.Log(repoPath, rev, opts...)
  39. }
  40. func (module) MergeBase(repoPath, base, head string, opts ...git.MergeBaseOptions) (string, error) {
  41. return git.MergeBase(repoPath, base, head, opts...)
  42. }
  43. func (module) RemoteRemove(repoPath, name string, opts ...git.RemoteRemoveOptions) error {
  44. return git.RemoteRemove(repoPath, name, opts...)
  45. }
  46. func (module) RepoTags(repoPath string, opts ...git.TagsOptions) ([]string, error) {
  47. return git.RepoTags(repoPath, opts...)
  48. }
  49. // Module is a mockable interface for Git operations.
  50. var Module ModuleStore = module{}