Documentation ¶
Index ¶
- Constants
- Variables
- func AccessTokenForHost(h string) string
- func ExitCodeFromStatus(status string) (c int)
- func FindStringSubmatchMap(r *regexp.Regexp, s string) map[string]string
- func GlyphFromStatus(status string) (g string)
- func IsCommit(sha string) bool
- func JobIsFinished(p *Project, ID int) (bool, error)
- func JobsStatus(jobs []*Job) (s string)
- func Lint(p *Project, c string) ([]string, error)
- func NewClient(h string) (*gitlab.Client, error)
- func OidForRef(revision string) (string, error)
- func RefForSymbolicRef(symbol string) (string, error)
- func RemoteForHEAD() (string, error)
- func RemoteForRef(ref string) (string, error)
- func RevParseAbbrev(rev string) (string, error)
- func StreamIssues(project *Project, opts *IssuesStreamOpts, r IssuesReader, w IssuesWriter, ...) (int, error)
- func StreamProjects(host string, opts StreamProjectsOpts, projChan chan *gitlab.Project) error
- func SummarizeCommitStatuses(statuses []*gitlab.CommitStatus) (s string)
- func SummarizeJobsByStage(jobs []*g.Job) map[string]string
- func UrlForRemote(remote string) (string, error)
- type Client
- type Commit
- type CommitReader
- type Host
- type Issue
- type IssueReader
- type IssueWriter
- type IssuesReader
- type IssuesReaderWriter
- type IssuesStreamOpts
- type IssuesWriter
- type Job
- type Pipeline
- type PipelineStage
- type Project
- func NewProjectForRepository(repo *Repository) (*Project, error)
- func NewProjectFromContext() (*Project, error)
- func NewProjectFromOptions(host string, projectID string) (*Project, error)
- func NewProjectFromRemote(remoteURL string) (*Project, error)
- func NewProjectFromURL(url *url.URL) (*Project, error)
- type Repository
- func (r *Repository) Checkout(ref string) error
- func (r *Repository) ConfigGet(option string) string
- func (r *Repository) ConfigGetAll(option string) (lines []string)
- func (r *Repository) Fetch(ref string) error
- func (r *Repository) GetProject() (*Project, error)
- func (r *Repository) RefExist(ref string) bool
- type RepositoryOption
- type StreamProjectsOpts
- type TraceReader
Constants ¶
const IssueType = "issue"
Variables ¶
var ( ErrServerNotConfigured = errors.New("No configuration for this server") ErrParseProjectPath = errors.New("Unable to parse project path") )
var ( ErrNoRepository = errors.New("Not a git repository (or any of the parent directories)") ErrNoUpstream = errors.New("No upstream for this repository") ErrDetachedHead = errors.New("No branch detected: detached HEAD") )
var (
ErrNoPipelines = errors.New("No pipelines found for this commit on this ref")
)
var UserAgent = "jramsay/Lab 0.0.1"
TODO Use LDFLags to set the version
Functions ¶
func AccessTokenForHost ¶
AccessTokenForHost returns the access token for the host from the git-lab config file
func ExitCodeFromStatus ¶
func FindStringSubmatchMap ¶
func GlyphFromStatus ¶
func IsCommit ¶
IsCommit returns true if the provided sha references a commit, and returns false for all other input.
func JobsStatus ¶
func NewClient ¶
NewClient does not return a Client from this package, but a go-gitlab.Client to make it confusing
func RefForSymbolicRef ¶
RefForSymbolicRef returns the ref for the provided symbolic ref, typically HEAD.
func RemoteForHEAD ¶
RemoteForHEAD returns the short remote name for the current local branch.
func RemoteForRef ¶
RemoteForRef returns the short remote name for the local ref provided in the format of `refs/heads/feature-branch`.
func RevParseAbbrev ¶
func StreamIssues ¶
func StreamIssues(project *Project, opts *IssuesStreamOpts, r IssuesReader, w IssuesWriter, progress chan int) (int, error)
func StreamProjects ¶
func StreamProjects(host string, opts StreamProjectsOpts, projChan chan *gitlab.Project) error
Stream projects will list the projects from the GitLab API and stream these through the channel, allowing for pagination request not slowing down the data processing pipeline
func SummarizeCommitStatuses ¶
func SummarizeCommitStatuses(statuses []*gitlab.CommitStatus) (s string)
func UrlForRemote ¶
Types ¶
type IssueWriter ¶
type IssuesReader ¶
type IssuesReader interface { GetIssuesStream(p *Project, opts *IssuesStreamOpts, readChan chan *Issue) error CountIssues(p *Project, opts *IssuesStreamOpts) int }
type IssuesReaderWriter ¶
type IssuesReaderWriter interface { IssuesWriter IssuesReader }
type IssuesStreamOpts ¶
type IssuesWriter ¶
type Job ¶
func FetchPipelineJobsByCommit ¶
func FetchPipelineJobsByCommit(p *Project, r *Repository) ([]Job, error)
type Pipeline ¶
type Pipeline struct { ID int Status string URL string Jobs []*Job Stages []*PipelineStage }
func FetchLastPipelineByCommit ¶
func FetchLastPipelineByCommit(p *Project, r *Repository) (*Pipeline, error)
type PipelineStage ¶
func (*PipelineStage) StatusDescription ¶
func (s *PipelineStage) StatusDescription() string
type Project ¶
type Project struct { Name string Namespace string Host string AccessToken string // contains filtered or unexported fields }
func NewProjectForRepository ¶
func NewProjectForRepository(repo *Repository) (*Project, error)
func NewProjectFromContext ¶
func NewProjectFromOptions ¶
Returns a new Project from the supplied host and project id. The project id must be a human readable string (gitlab-org/gitaly) to match the web url and clone url. WARNING: client will not be set! A refactor is coming!!!
func NewProjectFromRemote ¶
type Repository ¶
type Repository struct { Remote string Branch string HEAD string *git.Repository // contains filtered or unexported fields }
Repository allows for interaction with a Git repository. Retrieving data from the repository is done by shelling out to the `git` command. Which means `git` must be correctly installed and can be found in $PATH.
func NewRepository ¶
func NewRepository(opts ...RepositoryOption) *Repository
NewRepository creates a Repository, without analyzing the context its being constructed in.
func (*Repository) ConfigGet ¶
func (r *Repository) ConfigGet(option string) string
func (*Repository) ConfigGetAll ¶
func (r *Repository) ConfigGetAll(option string) (lines []string)
func (*Repository) Fetch ¶
func (r *Repository) Fetch(ref string) error
func (*Repository) GetProject ¶
func (r *Repository) GetProject() (*Project, error)
GetProject will determine the GitLab project associated based on the current checkout. It does so by detecting the upstream tracking branch of the current HEAD. ErrNoUpstream will be returned as error, when there's no upstream set.
func (*Repository) RefExist ¶
func (r *Repository) RefExist(ref string) bool
type RepositoryOption ¶
type RepositoryOption func(*Repository)
func WithBranch ¶
func WithBranch(ref string) RepositoryOption
WithBranch overrides the branch to be used, instead of loading from context It does not modify the local git repository
func WithHEAD ¶
func WithHEAD(commitID string) RepositoryOption
WithHEAD overrides sets the value HEAD would dereference to, for the repository struct to the passed value It does not modify the git repository
func WithRemote ¶
func WithRemote(remote string) RepositoryOption
WithRemote sets the remote to use for the requests to the name passed
type StreamProjectsOpts ¶
type TraceReader ¶
type TraceReader struct {
// contains filtered or unexported fields
}
func NewTraceReader ¶
func NewTraceReader(p *Project, ID int) *TraceReader
func (*TraceReader) Error ¶
func (t *TraceReader) Error() string