gogh

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrProjectNotFound is the error will be raised when a project is not found.
	ErrProjectNotFound = errors.New("project not found")
	// ErrProjectAlreadyExists is the error will be raised when a project already exists.
	ErrProjectAlreadyExists = errors.New("project already exists")
)
View Source
var (
	ErrTooShallowPath = errors.New("too shallow path")
	ErrTooDeepPath    = errors.New("too deep path")
)

Functions

func FindOrNewProject added in v0.5.8

func FindOrNewProject(ev Env, spec *RepoSpec) (*Project, *Repo, error)

FindOrNewProject will find a project (local repository) that matches exactly or create new one.

func FindOrNewProjectInPrimary added in v1.0.0

func FindOrNewProjectInPrimary(ev Env, spec *RepoSpec) (*Project, *Repo, error)

FindOrNewProjectInPrimary will find a project (local repository) that matches exactly or create new one.

func FindProject added in v0.4.0

func FindProject(ev Env, spec *RepoSpec) (*Project, *Repo, error)

FindProject will find a project (local repository) that matches exactly.

func FindProjectInPrimary added in v1.0.0

func FindProjectInPrimary(ev Env, spec *RepoSpec) (*Project, *Repo, error)

FindProjectInPrimary will find a project (local repository) that matches exactly.

func FindProjectPath added in v0.4.0

func FindProjectPath(ev Env, spec *RepoSpec) (string, error)

FindProjectPath willl get a project (local repository) path from remote repository URL

func PrimaryRoot added in v1.5.0

func PrimaryRoot(ev Env) string

func Query added in v0.3.0

func Query(ev Env, query string, walk Walker, callback WalkFunc) error

Query searches projects (local repositories) with specified walker

func ValidateHost added in v0.5.8

func ValidateHost(ev Env, host string) error

func ValidateName added in v0.5.6

func ValidateName(name string) error

func ValidateOwner added in v0.5.6

func ValidateOwner(owner string) error

func Walk added in v0.1.0

func Walk(ev Env, callback WalkFunc) error

Walk thorugh projects (local repositories) in gogh.root directories

func WalkInPrimary added in v0.2.0

func WalkInPrimary(ev Env, callback WalkFunc) error

WalkInPrimary thorugh projects (local repositories) in the first gogh.root directory

Types

type DefaultSpec added in v1.5.4

type DefaultSpec interface {
	GithubHost() string
	GithubUser() string
}

DefaultSpec descripts default properties

type Env added in v1.5.0

type Env interface {
	GithubHost() string
	GithubUser() string
	Hooks() []string
	Roots() []string
}

Env is an interface generated for "github.com/kyoh86/gogh/env.Access".

type ErrorInvalidName added in v1.5.5

type ErrorInvalidName string

func (ErrorInvalidName) Error added in v1.5.5

func (e ErrorInvalidName) Error() string

type ErrorInvalidOwner added in v1.5.5

type ErrorInvalidOwner string

func (ErrorInvalidOwner) Error added in v1.5.5

func (e ErrorInvalidOwner) Error() string

type ErrorUnsupportedHost added in v1.5.5

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

func (*ErrorUnsupportedHost) Error added in v1.5.5

func (e *ErrorUnsupportedHost) Error() string

type FormatWalkFunc added in v1.7.0

type FormatWalkFunc func(project *Project, formatted string) error

FormatWalkFunc is the function to accept projects and formatted string in the ProjectListFormatter.Walk

type Project added in v0.4.0

type Project struct {
	FullPath  string
	RelPath   string
	PathParts []string
	Exists    bool
}

Project repository specifier

func NewProject added in v0.4.0

func NewProject(ev Env, spec *RepoSpec) (*Project, error)

NewProject creates a project (local repository)

func ParseProject added in v1.1.0

func ParseProject(ev Env, root string, fullPath string) (*Project, error)

func (*Project) IsInPrimaryRoot added in v0.4.0

func (p *Project) IsInPrimaryRoot(ev Env) bool

IsInPrimaryRoot check which the repository is in primary root directory for gogh

func (*Project) Subpaths added in v0.4.0

func (p *Project) Subpaths() []string

Subpaths returns lists of tail parts of relative path from the root directory (shortest first) for example, {"gogh", "kyoh86/gogh", "github.com/kyoh86/gogh"} for $root/github.com/kyoh86/gogh.

type ProjectListFormatter added in v0.4.0

type ProjectListFormatter interface {
	Add(*Project)
	Len() int
	PrintAll(io.Writer, string) error
	Walk(FormatWalkFunc) error
}

ProjectListFormatter holds project list to print them.

func CustomFormatter added in v1.3.0

func CustomFormatter(format string) (ProjectListFormatter, error)

func FullPathFormatter added in v0.2.0

func FullPathFormatter() ProjectListFormatter

FullPathFormatter prints each full-path of the project.

func RelPathFormatter added in v0.2.0

func RelPathFormatter() ProjectListFormatter

RelPathFormatter prints each relative-path of the project

func ShortFormatter added in v0.2.0

func ShortFormatter() ProjectListFormatter

ShortFormatter prints each project as short as possible.

func SpecFormatter added in v1.8.0

func SpecFormatter() ProjectListFormatter

SpecFormatter prints each relative-path of the project

func URLFormatter added in v0.5.7

func URLFormatter() ProjectListFormatter

URLFormatter prints each project as url.

type Repo added in v0.4.0

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

Repo specifies a repository in the GitHub

func ParseRepo added in v0.4.0

func ParseRepo(df DefaultSpec, rawRepo string) (*Repo, error)

ParseRepo parses a repo-name for a repository in the GitHub

func (*Repo) FullName added in v0.5.5

func (r *Repo) FullName() string

FullName returns a repository identifier that is formed like {Owner/Name}

func (*Repo) Match added in v1.0.4

func (r *Repo) Match(p *Project) bool

Match with project.

func (*Repo) Name added in v0.4.0

func (r *Repo) Name() string

Name returns a name of the repository

func (*Repo) Owner added in v0.4.0

func (r *Repo) Owner() string

Owner returns a user name of an owner of the repository

func (*Repo) RelPath added in v0.4.0

func (r *Repo) RelPath() string

RelPath get relative path from root directory

func (Repo) String added in v0.4.0

func (r Repo) String() string

func (*Repo) URL added in v0.4.0

func (r *Repo) URL(ssh bool) *url.URL

URL will get a URL for a repository

type RepoSpec added in v0.1.0

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

RepoSpec specifies a repository in the GitHub

func ParseRepoSpec added in v1.8.0

func ParseRepoSpec(rawRepo string) (*RepoSpec, error)

Parse text as RepoSpec

func (*RepoSpec) Set added in v0.1.0

func (r *RepoSpec) Set(rawRepo string) error

Set text as RepoSpec

func (RepoSpec) String added in v0.1.0

func (r RepoSpec) String() string

func (*RepoSpec) Validate added in v1.5.4

func (r *RepoSpec) Validate(df DefaultSpec) (*Repo, error)

type RepoSpecs added in v0.2.0

type RepoSpecs []RepoSpec

RepoSpecs is array of RepoSpec

func (RepoSpecs) IsCumulative added in v0.2.0

func (specs RepoSpecs) IsCumulative() bool

func (*RepoSpecs) Set added in v0.2.0

func (specs *RepoSpecs) Set(value string) error

Set will add a text to RepoSpecs as a RepoSpec

func (RepoSpecs) String added in v0.2.0

func (specs RepoSpecs) String() string

func (RepoSpecs) Validate added in v1.5.0

func (specs RepoSpecs) Validate(df DefaultSpec) ([]Repo, error)

Repos will get repositories with GitHub host and user

type WalkFunc added in v0.2.0

type WalkFunc func(*Project) error

WalkFunc is the type of the function called for each repository visited by Walk / WalkInPrimary

type Walker added in v0.2.0

type Walker func(Env, WalkFunc) error

Walker is the type of the function to visit each repository

Jump to

Keyboard shortcuts

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