repo

package
v0.0.0-...-5c2e7a1 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2022 License: EUPL-1.2 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrExists             = errors.New("repository already added")
	ErrNoFile             = errors.New("no file found")
	ErrBadCredentials     = errors.New("bad credentials")
	ErrUnexpectedResponse = errors.New("unexpected http response")
	ErrUncachedRepo       = errors.New("repository not cached")
)
View Source
var (
	// ErrCacheExists indicates a different repository whith the same cache folder already exists
	ErrCacheExists = errors.New("cache folder for new repository already exists")
)

Functions

func Add

func Add(url string) error

func GetModulePath

func GetModulePath(mod *model.Module) (string, error)

func InitCache

func InitCache(path string)

func New

func New(url string) error

func QueryGraphQL

func QueryGraphQL(url string, token string, q GraphQLQuery, res interface{}) error

QueryGraphQL runs a GraphQL with the given parameters

Types

type Commit

type Commit struct {
	Message string
	Ref     string
}

type ErrGitHubGQL

type ErrGitHubGQL struct {
	Msg string
}

func (*ErrGitHubGQL) Error

func (e *ErrGitHubGQL) Error() string

type ErrGitHubGQLRateLimit

type ErrGitHubGQLRateLimit struct {
	ResetAt time.Time
}

func (*ErrGitHubGQLRateLimit) Error

func (e *ErrGitHubGQLRateLimit) Error() string

type Git

type Git struct {
	URL string
}

func (*Git) Dir

func (g *Git) Dir() (string, error)

Dir returns the location of the checked out repository

func (*Git) EdeaParams

func (g *Git) EdeaParams(sub string) (map[string]interface{}, error)

func (*Git) ExportPlotDirAt

func (g *Git) ExportPlotDirAt(dest, dir, revision string) (string, error)

ExportPlotDirAt pulls all the plotted svg files from the repository at the specified revision and copies them to a temporary folder

func (*Git) File

func (g *Git) File(name string, caseSensitive bool) (string, error)

File searches for a given file in the git respository

func (*Git) FileAt

func (g *Git) FileAt(name string, caseSensitive bool, revision string) ([]byte, error)

FileAt searches for a given file with the specific revision in the git respository the revision parameter can be anything ResolveRevision understands (tags, branches, HEAD^1, etc.)

func (*Git) FileByExtAt

func (g *Git) FileByExtAt(dir, ext, revision string) ([]byte, error)

FileByExtAt works like FilesByExtAt but only returns the first file found

func (*Git) FilesByExtAt

func (g *Git) FilesByExtAt(dir, ext, revision string) (files []GitFile, err error)

FilesByExtAt searches for a given file by extension with the specific revision in the git respository the revision parameter can be anything ResolveRevision understands (tags, branches, HEAD^1, etc.) NOTE: ext *must* contain the . (dot), e.g. ".kicad_pcb"

func (*Git) HasDocs

func (g *Git) HasDocs(sub string) (bool, error)

HasDocs searches for a book.toml file in the repository and returns true if found

func (*Git) History

func (g *Git) History(folder string) ([]*Commit, error)

History returns the commits and the reference hash for a repository or submodule

func (*Git) Pull

func (g *Git) Pull() error

Pull the latest changes from the origin

func (*Git) Readme

func (g *Git) Readme(revision string) (string, error)

Readme searches for a readme.md file in the repository and returns it if found

func (*Git) SubModuleDir

func (g *Git) SubModuleDir(sub string) (string, error)

SubModuleDir looks if a sub-module exists or else returns the base path

func (*Git) SubModuleDocs

func (g *Git) SubModuleDocs(sub string) (string, error)

SubModuleDocs searches for the doc subfolder in the module and returns all .md files

func (*Git) SubModuleReadme

func (g *Git) SubModuleReadme(sub, revision string) (string, error)

SubModuleReadme searches for a readme.md file in the repository and returns it if found

type GitFile

type GitFile struct {
	Name    string
	Content []byte
}

type GitHub

type GitHub struct {
	ProjectName  string
	ProjectOwner string
	Host         string
	AuthToken    string
}

func (*GitHub) RateLimit

func (r *GitHub) RateLimit() (remaining int, resetAt time.Time, err error)

func (*GitHub) Readme

func (r *GitHub) Readme() (string, error)

type GitLab

type GitLab struct {
	FullPath string
	Host     string
}

func (*GitLab) Readme

func (r *GitLab) Readme() (string, error)

type GitRepository

type GitRepository struct {
	Path string
	URL  string
}

func (*GitRepository) Clone

func (g *GitRepository) Clone(ctx context.Context) error

Clone a git repository

func (*GitRepository) Update

func (g *GitRepository) Update(ctx context.Context) error

Update (fetch) a git repository

type GraphQLQuery

type GraphQLQuery struct {
	Query         string      `json:"query"`
	OperationName string      `json:"operationName,omitempty"`
	Variables     interface{} `json:"variables,omitempty"`
}

GraphQLQuery helper struct

type GraphQLResponse

type GraphQLResponse struct {
	Message string `json:"message"`
	Errors  []struct {
		Message   string `json:"message,omitempty"`
		Locations []struct {
			Line   int `json:"line,omitempty"`
			Column int `json:"column,omitempty"`
		} `json:"locations,omitempty"`
	} `json:"errors,omitempty"`
	Data interface{} `json:"data,omitempty"`
}

GraphQLResponse struct

func (*GraphQLResponse) Error

func (e *GraphQLResponse) Error() string

type Info

type Info struct {
	LastCommit struct {
		Time time.Time
		Hash string
	}
	Readme string
}

type Module

type Module struct {
	Readme    string                 `yaml:"readme"` // readme file or folder which contains readme.md
	Directory string                 `yaml:"dir"`    // path to the kicad project file or folder which contains it
	Doc       string                 `yaml:"doc"`    // path to book.toml
	Params    map[string]interface{} `yaml:"params"` // module parameters, used for search
}

Module references the schematic and pcb for this module

type Project

type Project struct {
	Name    string            `yaml:"name"`
	Modules map[string]Module `yaml:"modules"`
}

Project is the top level project configuration

type RepoCache

type RepoCache struct {
	Base string
}

func (*RepoCache) Add

func (c *RepoCache) Add(url string) (err error)

Add a new repository to the cache

func (*RepoCache) Has

func (c *RepoCache) Has(url string) (found bool, err error)

Has returns true if the repository is already cached

type Repository

type Repository interface {
	Clone(context.Context) error // clone to path from URL
	Update(context.Context) error
	Size() (int64, error)
}

Jump to

Keyboard shortcuts

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