repo

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2018 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package repo deals with a Github repository of generators.

It provides functionality to store and update remote generators from a Github repository locally. It can track a Git branch, a tag, or a commit SHA1.

It uses the Github API and doesn't rely on Git.

Index

Constants

View Source
const (
	// StatesDir is the name of the states directory.
	StatesDir = "states"

	// StateFile is the name of the state file.
	StateFile = "repo.json"

	// StateDirPerm is the file mode for a state directory.
	StateDirPerm = 0755

	// StateFilePerm is the file mode for a state file.
	StateFilePerm = 0644

	// SrcDir is the name of the directory where sources are stored.
	SrcDir = "src"

	// SrcPerm is the file mode for a state directory.
	SrcPerm = 0755
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Repo

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

Repo manages a Github repository.

func New

func New(path, owner, repo, ghToken string, isRemote bool) *Repo

New instantiates a repository.

func (*Repo) Generate

func (r *Repo) Generate(name, dst string, opts *generator.Options, ref string) error

Generate executes a generator by name. Ref can be a branch, a tag, or a commit SHA1.

func (*Repo) GetState

func (r *Repo) GetState(ref string) (*State, error)

GetState returns the state of the repository. Ref can be a branch, a tag, or a commit SHA1. If the repository does not exist locally, it returns nil.

func (*Repo) GetStateOrCreate

func (r *Repo) GetStateOrCreate(ref string) (*State, error)

GetStateOrCreate returns the state of the repository. If the repository does not exist locally, it creates it by calling Update(). Ref can be a branch, a tag, or a commit SHA1.

func (*Repo) List

func (r *Repo) List(ref string) ([]*generator.Definition, error)

List lists the generators of the repository. If the repository does not exist locally, it creates it by calling Update(). Ref can be a branch, a tag, or a commit SHA1.

func (*Repo) Update

func (r *Repo) Update(ref string, force bool) (*State, bool, error)

Update downloads the latest release if needed (or if force is true). Ref can be a branch, a tag, or a commit SHA1.

type State

type State struct {
	// Owner is the Github username of the owner of the repository.
	Owner string `json:"owner"`

	// Repo is the name of the Github repository.
	Repo string `json:"repo"`

	// Ref is a branch, a tag, or a commit SHA1.
	Ref string `json:"ref"`

	// SHA1 is the commit SHA1 of the downloaded version.
	// It is used to check if an update is available on Github.
	SHA1 string `json:"sha1"`
}

State describes a repository.

Jump to

Keyboard shortcuts

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