git

package
v0.0.0-...-c42b1bb Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2018 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultCloneTimeout = 2 * time.Minute
	CheckPushTag        = "flux-write-check"
)

Variables

View Source
var (
	ErrNoChanges  = errors.New("no changes made in repo")
	ErrNoConfig   = errors.New("git repo does not have valid config")
	ErrNotCloned  = errors.New("git repo has not been cloned yet")
	ErrClonedOnly = errors.New("git repo has been cloned but not yet checked for write access")
)
View Source
var (
	ErrReadOnly = errors.New("cannot make a working clone of a read-only git repo")
)
View Source
var NoRepoError = &fluxerr.Error{
	Type: fluxerr.User,
	Err:  errors.New("no repo in user config"),
	Help: `No Git repository URL in your config

We need to clone a git repo to proceed, and you haven't supplied
one. Please upload a config file, including a git repository URL, as
described in

    https://github.com/weaveworks/flux/blob/master/site/using.md

`,
}
View Source
var ReadOnly optionFunc = func(r *Repo) {
	r.readonly = true
}

Functions

func CloningError

func CloningError(url string, actual error) error

func ErrUpstreamNotWritable

func ErrUpstreamNotWritable(url string, actual error) error

func PushError

func PushError(url string, actual error) error

Types

type Checkout

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

Checkout is a local working clone of the remote repo. It is intended to be used for one-off "transactions", e.g,. committing changes then pushing upstream. It has no locking.

func (*Checkout) ChangedFiles

func (c *Checkout) ChangedFiles(ctx context.Context, ref string) ([]string, error)

ChangedFiles does a git diff listing changed files

func (*Checkout) Clean

func (c *Checkout) Clean()

Clean a Checkout up (remove the clone)

func (*Checkout) CommitAndPush

func (c *Checkout) CommitAndPush(ctx context.Context, commitAction CommitAction, note interface{}) error

CommitAndPush commits changes made in this checkout, along with any extra data as a note, and pushes the commit and note to the remote repo.

func (*Checkout) Dir

func (c *Checkout) Dir() string

Dir returns the path to the repo

func (*Checkout) GetNote

func (c *Checkout) GetNote(ctx context.Context, rev string, note interface{}) (bool, error)

GetNote gets a note for the revision specified, or nil if there is no such note.

func (*Checkout) HeadRevision

func (c *Checkout) HeadRevision(ctx context.Context) (string, error)

func (*Checkout) ManifestDirs

func (c *Checkout) ManifestDirs() []string

ManifestDirs returns the paths to the manifests files. It ensures that at least one path is returned, so that it can be used with `Manifest.LoadManifests`.

func (*Checkout) MoveSyncTagAndPush

func (c *Checkout) MoveSyncTagAndPush(ctx context.Context, ref, msg string) error

func (*Checkout) NoteRevList

func (c *Checkout) NoteRevList(ctx context.Context) (map[string]struct{}, error)

func (*Checkout) SyncRevision

func (c *Checkout) SyncRevision(ctx context.Context) (string, error)

type Commit

type Commit struct {
	Revision string
	Message  string
}

type CommitAction

type CommitAction struct {
	Author  string
	Message string
}

CommitAction - struct holding commit information

type Config

type Config struct {
	Branch      string   // branch we're syncing to
	Paths       []string // paths within the repo containing files we care about
	SyncTag     string
	NotesRef    string
	UserName    string
	UserEmail   string
	SetAuthor   bool
	SkipMessage string
}

Config holds some values we use when working in the working clone of a repo.

type Export

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

func (*Export) Clean

func (e *Export) Clean()

func (*Export) Dir

func (e *Export) Dir() string

type GitRepoStatus

type GitRepoStatus string

GitRepoStatus represents the progress made synchronising with a git repo. These are given below in expected order, but the status may go backwards if e.g., a deploy key is deleted.

const (
	RepoNoConfig GitRepoStatus = "unconfigured" // configuration is empty
	RepoNew      GitRepoStatus = "new"          // no attempt made to clone it yet
	RepoCloned   GitRepoStatus = "cloned"       // has been read (cloned); no attempt made to write
	RepoReady    GitRepoStatus = "ready"        // has been written to, so ready to sync
)

type NotReadyError

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

func (NotReadyError) Error

func (err NotReadyError) Error() string

type Option

type Option interface {
	// contains filtered or unexported methods
}

type PollInterval

type PollInterval time.Duration

type Remote

type Remote struct {
	URL string // clone from here
}

Remote points at a git repo somewhere.

type Repo

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

func NewRepo

func NewRepo(origin Remote, opts ...Option) *Repo

NewRepo constructs a repo mirror which will sync itself.

func (*Repo) Clean

func (r *Repo) Clean()

Clean removes the mirrored repo. Syncing may continue with a new directory, so you may need to stop that first.

func (*Repo) Clone

func (r *Repo) Clone(ctx context.Context, conf Config) (*Checkout, error)

Clone returns a local working clone of the sync'ed `*Repo`, using the config given.

func (*Repo) CommitsBefore

func (r *Repo) CommitsBefore(ctx context.Context, ref string, paths ...string) ([]Commit, error)

func (*Repo) CommitsBetween

func (r *Repo) CommitsBetween(ctx context.Context, ref1, ref2 string, paths ...string) ([]Commit, error)

func (*Repo) Dir

func (r *Repo) Dir() string

Dir returns the local directory into which the repo has been cloned, if it has been cloned.

func (*Repo) Export

func (r *Repo) Export(ctx context.Context, ref string) (*Export, error)

Export creates a minimal clone of the repo, at the ref given.

func (*Repo) Notify

func (r *Repo) Notify()

Notify tells the repo that it should fetch from the origin as soon as possible. It does not block.

func (*Repo) Origin

func (r *Repo) Origin() Remote

Origin returns the Remote with which the Repo was constructed.

func (*Repo) Ready

func (r *Repo) Ready(ctx context.Context) error

Ready tries to advance the cloning process along as far as possible, and returns an error if it is not able to get to a ready state.

func (*Repo) Refresh

func (r *Repo) Refresh(ctx context.Context) error

func (*Repo) Revision

func (r *Repo) Revision(ctx context.Context, ref string) (string, error)

Revision returns the revision (SHA1) of the ref passed in

func (*Repo) Start

func (r *Repo) Start(shutdown <-chan struct{}, done *sync.WaitGroup) error

Start begins synchronising the repo by cloning it, then fetching the required tags and so on.

func (*Repo) Status

func (r *Repo) Status() (GitRepoStatus, error)

Status reports that readiness status of this Git repo: whether it has been cloned and is writable, and if not, the error stopping it getting to the next state.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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