git

package
v0.0.0-...-39eb47e Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2018 License: LGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MirrorNameFromURI

func MirrorNameFromURI(uri string) (name string)

MirrorNameFromURI Creates a Name from a Git uri. It will panic if the uri is not in the expected format.

Types

type CommandError

type CommandError interface {
	gmm.ApplicationError
}

CommandError represents an error executing a Git command

type CommandRunner

type CommandRunner interface {
	GetRemote(directory string) (string, CommandError)
	LsRemoteTags(uri string) (string, CommandError)
	FetchPrune(directory string) CommandError
	CreateMirror(uri string, dirPath string) CommandError
	CreateTagArchive(tag string, dirPath string) CommandError
	Exec(directory string, args ...string) (string, CommandError)
}

CommandRunner invokes the Git CLI

type Cron

type Cron interface {
	Stop()
	Start()
	AddFunc(spec string, cmd func()) error
}

Cron represents a simplified cron job

func CreateUpdateCron

func CreateUpdateCron(mirror *Mirror, interval string) (Cron, gmm.ApplicationError)

CreateUpdateCron creates a Cron that updates a mirror

type CronFactory

type CronFactory func(mirror *Mirror, interval string) (Cron, gmm.ApplicationError)

CronFactory creates a new Cron

type DefaultCommandRunner

type DefaultCommandRunner struct {
	Fs       util.FileSystemUtil
	Executor util.CommandExecutor
}

DefaultCommandRunner is the default implementation of CommandRunner

func (*DefaultCommandRunner) CreateMirror

func (m *DefaultCommandRunner) CreateMirror(uri string, dirPath string) CommandError

CreateMirror creates a Git mirror on the filesystem

func (*DefaultCommandRunner) CreateTagArchive

func (m *DefaultCommandRunner) CreateTagArchive(tag string, dirPath string) CommandError

CreateTagArchive builds a ZIP file for a given tag

func (*DefaultCommandRunner) Exec

func (m *DefaultCommandRunner) Exec(directory string, args ...string) (string, CommandError)

Exec executes "git" binary commands

func (*DefaultCommandRunner) FetchPrune

func (m *DefaultCommandRunner) FetchPrune(directory string) CommandError

FetchPrune updates a local repository with the default remote

func (*DefaultCommandRunner) GetRemote

func (m *DefaultCommandRunner) GetRemote(directory string) (string, CommandError)

GetRemote fetches the URI for the default remote at given path

func (*DefaultCommandRunner) LsRemoteTags

func (m *DefaultCommandRunner) LsRemoteTags(uri string) (string, CommandError)

LsRemoteTags lists the tags in a remote repository

type Mirror

type Mirror struct {
	Name string
	Cron Cron
	// contains filtered or unexported fields
}

Mirror represents a Git mirror

func NewMirror

func NewMirror(
	uri string,
	baseDir string,
	updateInterval string,
	cmd CommandRunner,
	fs util.FileSystemUtil,
	updateCronFactory CronFactory,
) (*Mirror, gmm.ApplicationError)

NewMirror creates a new Mirror struct, cloning the remote in separate subroutine

func (*Mirror) AssertValidRemote

func (m *Mirror) AssertValidRemote(uri string) gmm.ApplicationError

AssertValidRemote ensures the repository at uri can be chatted with

func (*Mirror) Destroy

func (m *Mirror) Destroy() gmm.ApplicationError

Destroy removes local data and jobs

func (*Mirror) Path

func (m *Mirror) Path() string

Path returns the full path to local data

func (*Mirror) Update

func (m *Mirror) Update() gmm.ApplicationError

Update updates the local mirror with the remote

Jump to

Keyboard shortcuts

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