host

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2024 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFileNotFound        = errors.New("file not found")
	ErrPullRequestNotFound = errors.New("pull request not found")
)

Functions

func CreatePullRequestCommentWithIdentifier

func CreatePullRequestCommentWithIdentifier(body string, identifier string, pr interface{}, repo Repository) error

func DeletePullRequestCommentByIdentifier

func DeletePullRequestCommentByIdentifier(identifier string, pr interface{}, repo Repository) error

Types

type GitHubHost

type GitHubHost struct {
	// contains filtered or unexported fields
}

func NewGitHubHost

func NewGitHubHost(address, token string, cacheDisabled bool) (*GitHubHost, error)

func (*GitHubHost) AuthenticatedUser added in v0.10.0

func (g *GitHubHost) AuthenticatedUser() (*UserInfo, error)

func (*GitHubHost) CreateFromName

func (g *GitHubHost) CreateFromName(name string) (Repository, error)

func (*GitHubHost) ListRepositories

func (g *GitHubHost) ListRepositories(since *time.Time, result chan []Repository, errChan chan error)

func (*GitHubHost) ListRepositoriesWithOpenPullRequests

func (g *GitHubHost) ListRepositoriesWithOpenPullRequests(result chan []Repository, errChan chan error)

func (*GitHubHost) Name added in v0.10.0

func (g *GitHubHost) Name() string

type GitHubRepository

type GitHubRepository struct {
	// contains filtered or unexported fields
}

func (*GitHubRepository) BaseBranch

func (g *GitHubRepository) BaseBranch() string

func (*GitHubRepository) CanMergePullRequest

func (g *GitHubRepository) CanMergePullRequest(pr interface{}) (bool, error)

func (*GitHubRepository) CloneUrlHttp

func (g *GitHubRepository) CloneUrlHttp() string

func (*GitHubRepository) CloneUrlSsh

func (g *GitHubRepository) CloneUrlSsh() string

func (*GitHubRepository) ClosePullRequest

func (g *GitHubRepository) ClosePullRequest(msg string, pr interface{}) error

func (*GitHubRepository) CreatePullRequest

func (g *GitHubRepository) CreatePullRequest(branch string, data PullRequestData) error

func (*GitHubRepository) CreatePullRequestComment

func (g *GitHubRepository) CreatePullRequestComment(body string, pr interface{}) error

func (*GitHubRepository) DeleteBranch

func (g *GitHubRepository) DeleteBranch(pr interface{}) error

func (*GitHubRepository) DeletePullRequestComment

func (g *GitHubRepository) DeletePullRequestComment(comment PullRequestComment, pr interface{}) error

func (*GitHubRepository) FindPullRequest

func (g *GitHubRepository) FindPullRequest(branch string) (any, error)

func (*GitHubRepository) FullName

func (g *GitHubRepository) FullName() string

func (*GitHubRepository) GetFile

func (g *GitHubRepository) GetFile(fileName string) (string, error)

func (*GitHubRepository) GetPullRequestBody

func (g *GitHubRepository) GetPullRequestBody(pr interface{}) string

func (*GitHubRepository) GetPullRequestCreationTime

func (g *GitHubRepository) GetPullRequestCreationTime(pr interface{}) time.Time

func (*GitHubRepository) HasFile

func (g *GitHubRepository) HasFile(p string) (bool, error)

func (*GitHubRepository) HasSuccessfulPullRequestBuild

func (g *GitHubRepository) HasSuccessfulPullRequestBuild(pr interface{}) (bool, error)

func (*GitHubRepository) Host

func (g *GitHubRepository) Host() HostDetail

func (*GitHubRepository) IsPullRequestClosed

func (g *GitHubRepository) IsPullRequestClosed(pr interface{}) bool

func (*GitHubRepository) IsPullRequestMerged

func (g *GitHubRepository) IsPullRequestMerged(pr interface{}) bool

func (*GitHubRepository) IsPullRequestOpen

func (g *GitHubRepository) IsPullRequestOpen(pr interface{}) bool

func (*GitHubRepository) ListPullRequestComments

func (g *GitHubRepository) ListPullRequestComments(pr interface{}) ([]PullRequestComment, error)

func (*GitHubRepository) MergePullRequest

func (g *GitHubRepository) MergePullRequest(deleteBranch bool, pr interface{}) error

func (*GitHubRepository) Name

func (g *GitHubRepository) Name() string

func (*GitHubRepository) Owner

func (g *GitHubRepository) Owner() string

func (*GitHubRepository) PullRequest added in v0.2.0

func (g *GitHubRepository) PullRequest(pr any) *PullRequest

func (*GitHubRepository) UpdatePullRequest

func (g *GitHubRepository) UpdatePullRequest(data PullRequestData, pr interface{}) error

func (*GitHubRepository) WebUrl

func (g *GitHubRepository) WebUrl() string

type GitLabHost

type GitLabHost struct {
	// contains filtered or unexported fields
}

func NewGitLabHost

func NewGitLabHost(addr, token string) (*GitLabHost, error)

func (*GitLabHost) AuthenticatedUser added in v0.10.0

func (g *GitLabHost) AuthenticatedUser() (*UserInfo, error)

func (*GitLabHost) CreateFromName

func (g *GitLabHost) CreateFromName(name string) (Repository, error)

func (*GitLabHost) ListRepositories

func (g *GitLabHost) ListRepositories(since *time.Time, result chan []Repository, errChan chan error)

func (*GitLabHost) ListRepositoriesWithOpenPullRequests

func (g *GitLabHost) ListRepositoriesWithOpenPullRequests(result chan []Repository, errChan chan error)

func (*GitLabHost) Name added in v0.10.0

func (g *GitLabHost) Name() string

type GitLabRepository

type GitLabRepository struct {
	// contains filtered or unexported fields
}

func (*GitLabRepository) BaseBranch

func (g *GitLabRepository) BaseBranch() string

func (*GitLabRepository) CanMergePullRequest

func (g *GitLabRepository) CanMergePullRequest(pr interface{}) (bool, error)

func (*GitLabRepository) CloneUrlHttp

func (g *GitLabRepository) CloneUrlHttp() string

func (*GitLabRepository) CloneUrlSsh

func (g *GitLabRepository) CloneUrlSsh() string

func (*GitLabRepository) ClosePullRequest

func (g *GitLabRepository) ClosePullRequest(msg string, pr interface{}) error

func (*GitLabRepository) CreatePullRequest

func (g *GitLabRepository) CreatePullRequest(branch string, data PullRequestData) error

func (*GitLabRepository) CreatePullRequestComment

func (g *GitLabRepository) CreatePullRequestComment(body string, pr interface{}) error

func (*GitLabRepository) DeleteBranch

func (g *GitLabRepository) DeleteBranch(pr interface{}) error

func (*GitLabRepository) DeletePullRequestComment

func (g *GitLabRepository) DeletePullRequestComment(comment PullRequestComment, pr interface{}) error

func (*GitLabRepository) FindPullRequest

func (g *GitLabRepository) FindPullRequest(branch string) (any, error)

func (*GitLabRepository) FullName

func (g *GitLabRepository) FullName() string

func (*GitLabRepository) GetFile

func (g *GitLabRepository) GetFile(fileName string) (string, error)

func (*GitLabRepository) GetPullRequestBody

func (g *GitLabRepository) GetPullRequestBody(pr interface{}) string

func (*GitLabRepository) GetPullRequestCreationTime

func (g *GitLabRepository) GetPullRequestCreationTime(pr interface{}) time.Time

func (*GitLabRepository) HasFile

func (g *GitLabRepository) HasFile(p string) (bool, error)

func (*GitLabRepository) HasSuccessfulPullRequestBuild

func (g *GitLabRepository) HasSuccessfulPullRequestBuild(pr interface{}) (bool, error)

func (*GitLabRepository) Host

func (g *GitLabRepository) Host() HostDetail

func (*GitLabRepository) IsPullRequestClosed

func (g *GitLabRepository) IsPullRequestClosed(pr interface{}) bool

func (*GitLabRepository) IsPullRequestMerged

func (g *GitLabRepository) IsPullRequestMerged(pr interface{}) bool

func (*GitLabRepository) IsPullRequestOpen

func (g *GitLabRepository) IsPullRequestOpen(pr interface{}) bool

func (*GitLabRepository) ListPullRequestComments

func (g *GitLabRepository) ListPullRequestComments(pr interface{}) ([]PullRequestComment, error)

func (*GitLabRepository) MergePullRequest

func (g *GitLabRepository) MergePullRequest(deleteBranch bool, pr interface{}) error

func (*GitLabRepository) Name

func (g *GitLabRepository) Name() string

func (*GitLabRepository) Owner

func (g *GitLabRepository) Owner() string

func (*GitLabRepository) PullRequest added in v0.2.0

func (g *GitLabRepository) PullRequest(pr any) *PullRequest

func (*GitLabRepository) UpdatePullRequest

func (g *GitLabRepository) UpdatePullRequest(data PullRequestData, pr interface{}) error

func (*GitLabRepository) WebUrl

func (g *GitLabRepository) WebUrl() string

type Host

type Host interface {
	CreateFromName(name string) (Repository, error)
	ListRepositories(since *time.Time, result chan []Repository, errChan chan error)
	ListRepositoriesWithOpenPullRequests(result chan []Repository, errChan chan error)
}

type HostDetail added in v0.10.0

type HostDetail interface {
	AuthenticatedUser() (*UserInfo, error)
	Name() string
}

type PullRequest added in v0.2.0

type PullRequest struct {
	// CreatedAt is the time and date at which the pull request has been created.
	CreatedAt *time.Time
	// Number is the identifier of the pull request.
	Number int64
	// WebURL is the URL humans visit to view the pull request.
	WebURL string
}

PullRequest holds data on an existing pull request.

type PullRequestComment

type PullRequestComment struct {
	Body string
	ID   int64
}

type PullRequestData

type PullRequestData struct {
	Assignees      []string
	AutoMerge      bool
	AutoMergeAfter time.Duration
	Body           string
	Labels         []string
	MergeOnce      bool
	Reviewers      []string
	TaskName       string
	TemplateData   template.Data
	Title          string
}

func (PullRequestData) GetBody

func (prd PullRequestData) GetBody() (string, error)

type Repository

type Repository interface {
	BaseBranch() string
	CanMergePullRequest(pr interface{}) (bool, error)
	CloneUrlHttp() string
	CloneUrlSsh() string
	ClosePullRequest(msg string, pr interface{}) error
	CreatePullRequestComment(body string, pr interface{}) error
	CreatePullRequest(branch string, data PullRequestData) error
	DeleteBranch(pr interface{}) error
	DeletePullRequestComment(comment PullRequestComment, pr interface{}) error
	FindPullRequest(branch string) (any, error)
	FullName() string
	GetFile(fileName string) (string, error)
	GetPullRequestBody(pr interface{}) string
	GetPullRequestCreationTime(pr interface{}) time.Time
	HasFile(path string) (bool, error)
	HasSuccessfulPullRequestBuild(pr interface{}) (bool, error)
	Host() HostDetail
	IsPullRequestClosed(pr interface{}) bool
	IsPullRequestMerged(pr interface{}) bool
	IsPullRequestOpen(pr interface{}) bool
	ListPullRequestComments(pr interface{}) ([]PullRequestComment, error)
	MergePullRequest(deleteBranch bool, pr interface{}) error
	Name() string
	PullRequest(pr any) *PullRequest
	Owner() string
	UpdatePullRequest(data PullRequestData, pr interface{}) error
	WebUrl() string
}

func NewRepositoryProxy added in v0.14.0

func NewRepositoryProxy(wrapped Repository, cache *gocache.Cache) Repository

NewRepositoryProxy returns a new RepositoryProxy. If cache is nil, then it uses a default cache that keeps entries for 15 seconds and cleans up expired entries every 20 seconds.

type RepositoryProxy added in v0.14.0

type RepositoryProxy struct {
	Repository
	// contains filtered or unexported fields
}

RepositoryProxy caches return values of a Repository.

func (*RepositoryProxy) GetFile added in v0.14.0

func (rf *RepositoryProxy) GetFile(fileName string) (string, error)

GetFile caches the return value of Repository.GetFile.

type UserInfo added in v0.10.0

type UserInfo struct {
	Email string
	Name  string
}

Jump to

Keyboard shortcuts

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