updates

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultRemote = "origin"

DefaultRemote is the default Git remote name.

Functions

func GetAutomaticUpdateCheckSettings

func GetAutomaticUpdateCheckSettings() (enabled bool, isSet bool)

GetAutomaticUpdateCheckSettings gets the automatic update settings.

func GetCloneURL

func GetCloneURL() (url string, branch string)

GetCloneURL get the clone url and clone branch.

func GetDefaultCloneBranch

func GetDefaultCloneBranch() string

GetDefaultCloneBranch get the default clone branch.

func GetDefaultCloneURL

func GetDefaultCloneURL() string

GetDefaultCloneURL get the default clone url.

func GetUpdateCheckTimestamp

func GetUpdateCheckTimestamp() (t time.Time, isSet bool, err error)

GetUpdateCheckTimestamp gets the update check time.

func MergeUpdates

func MergeUpdates(cloneDir string, dryRun bool) (currentSHA string, err error)

MergeUpdates merges updates in the Githooks clone directory. Only a fast-forward merge of the remote branch into the local branch is performed, no remote fetch is performed. Returns the commit SHA after the fast-forward.

func RecordUpdateCheckTimestamp

func RecordUpdateCheckTimestamp() error

RecordUpdateCheckTimestamp records the current update check time.

func ResetCloneBranch

func ResetCloneBranch() error

ResetCloneBranch resets the Githooks clone branch.

func ResetUpdateCheckTimestamp

func ResetUpdateCheckTimestamp() error

ResetUpdateCheckTimestamp resets the update check time.

func RunUpdate

func RunUpdate(
	installDir string,
	acceptUpdate AcceptUpdateCallback,
	run func() error) (updateAvailable bool, accepted bool, err error)

RunUpdate runs the procedure of updating Githooks.

func RunUpdateOverExecutable

func RunUpdateOverExecutable(
	installDir string,
	execC cm.IExecContext,
	pipeSetup cm.PipeSetupFunc,
	args ...string) error

RunUpdateOverExecutbale executes the installer to run the update.

func SetAutomaticUpdateCheckSettings

func SetAutomaticUpdateCheckSettings(enable bool, reset bool) error

SetAutomaticUpdateCheckSettings set the automatic update settings.

func SetCloneBranch

func SetCloneBranch(branch string) error

SetCloneBranch sets the Githooks clone branch.

func SetCloneURL

func SetCloneURL(url string, branch string) (err error)

SetCloneURL get the clone url and clone branch. The `branch` can be empty.

Types

type AcceptUpdateCallback

type AcceptUpdateCallback func(status *ReleaseStatus) bool

AcceptUpdateCallback is the callback type for accepting/rejecting updates.

func DefaultAcceptUpdateCallback

func DefaultAcceptUpdateCallback(
	log cm.ILogContext,
	promptCtx prompt.IContext,
	acceptIfNoPrompt bool) AcceptUpdateCallback

DefaultAcceptUpdateCallback creates a default accept update callback which prompts the user.

type Binaries

type Binaries struct {
	Cli    string   // The Githooks cli binary.
	Others []string // All other binaries except the cli binary.
	All    []string // All binaries.

	BinDir string // Directory where all binaries reside.
}

Binaries define all binaries used by githooks.

type ReleaseStatus

type ReleaseStatus struct {
	RemoteURL  string
	RemoteName string

	IsNewClone bool

	LocalCommitSHA  string // Current local commit and corresponding to the current installed version.
	LocalTag        string // Current local tag  and corresponding to the current installed version.
	RemoteCommitSHA string // Remote head on the remote branch.

	IsUpdateAvailable bool
	UpdateCommitSHA   string           // The determined update SHA (always <= RemoteCommitSHA).
	UpdateTag         string           // The update tag.
	UpdateVersion     *version.Version // The update version.
	UpdateInfo        []string         // The update info read from the commit.

	Branch       string
	RemoteBranch string
}

ReleaseStatus contains the status of the release clone.

func FetchUpdates

func FetchUpdates(
	cloneDir string,
	url string,
	branch string,
	checkRemote bool,
	checkRemoteAction RemoteCheckAction,
	skipPrerelease bool) (status ReleaseStatus, err error)

FetchUpdates fetches updates in the Githooks clone directory. Arguments `url` and `branch` can be empty which triggers.

func GetStatus

func GetStatus(cloneDir string, checkRemote, skipPrerelease bool) (status ReleaseStatus, err error)

GetStatus returns the status of the release clone.

type RemoteCheckAction

type RemoteCheckAction string

RemoteCheckAction is the action type for the remote check.

const (
	// ErrorOnWrongRemote errors out if wrong remote detected.
	ErrorOnWrongRemote RemoteCheckAction = "error"
	// RecloneOnWrongRemote reclones if wrong remote detected.
	RecloneOnWrongRemote RemoteCheckAction = "reclone"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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