undobranches

package
v14.2.1 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package undobranches restores the Git branches to a known snapshot.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CategorizeInconsistentChanges

func CategorizeInconsistentChanges(changes undodomain.InconsistentChanges, config configdomain.ValidatedConfig) (perennials, features undodomain.InconsistentChanges)

func DetermineUndoBranchesProgram

func DetermineUndoBranchesProgram(beginBranchesSnapshot, endBranchesSnapshot gitdomain.BranchesSnapshot, undoablePerennialCommits []gitdomain.SHA, fullConfig configdomain.ValidatedConfig) program.Program

Types

type BranchChanges

type BranchChanges struct {
	// Inconsistent changes are changes on both local and tracking branch, but where the local and tracking branch
	// don't have the same SHA before or after.
	// These changes cannot be undone for perennial branches because there is no way to reset the remote branch to the SHA it had before.
	InconsistentlyChanged undodomain.InconsistentChanges
	LocalAdded            gitdomain.LocalBranchNames
	LocalChanged          LocalBranchChange
	LocalRemoved          LocalBranchesSHAs
	// OmniChanges are changes where the local SHA and the remote SHA are identical before the change as well as after the change,
	OmniChanged LocalBranchChange // a branch had the same SHA locally and remotely, now it has a new SHA locally and remotely, the local and remote SHA are still equal
	// OmniRemoved is when a branch that has the same SHA on its local and tracking branch gets removed.
	OmniRemoved   LocalBranchesSHAs
	RemoteAdded   gitdomain.RemoteBranchNames
	RemoteChanged RemoteBranchChange
	RemoteRemoved RemoteBranchesSHAs
}

BranchChanges describes the changes made to the branches in a Git repo. Various types of changes are distinguished.

func (BranchChanges) UndoProgram

UndoProgram provides the steps to undo the changes described by this BranchChanges instance.

type BranchChangesUndoProgramArgs

type BranchChangesUndoProgramArgs struct {
	BeginBranch              gitdomain.LocalBranchName
	Config                   configdomain.ValidatedConfig
	EndBranch                gitdomain.LocalBranchName
	UndoablePerennialCommits []gitdomain.SHA
}

type BranchSpan

type BranchSpan struct {
	Before Option[gitdomain.BranchInfo] // the status of the branch before Git Town ran
	After  Option[gitdomain.BranchInfo] // the status of the branch after Git Town ran
}

BranchSpan represents changes of a branch over time.

func (BranchSpan) IsInconsistentChange

func (self BranchSpan) IsInconsistentChange() (isInconsistentChange bool, before, after gitdomain.BranchInfo)

func (BranchSpan) IsOmniChange

func (self BranchSpan) IsOmniChange() (isOmniChange bool, branchName gitdomain.LocalBranchName, beforeSHA, afterSHA gitdomain.SHA)

IsOmniChange indicates whether this BranchBeforeAfter changes a synced branch from one SHA both locally and remotely to another SHA both locally and remotely.

func (BranchSpan) IsOmniRemove

func (self BranchSpan) IsOmniRemove() (isOmniRemove bool, beforeBranchName gitdomain.LocalBranchName, beforeSHA gitdomain.SHA)

Indicates whether this BranchSpan describes the removal of an omni Branch and provides all relevant data for this situation.

func (BranchSpan) LocalAdded

func (self BranchSpan) LocalAdded() (isLocalAdded bool, afterBranchName gitdomain.LocalBranchName, afterSHA gitdomain.SHA)

func (BranchSpan) LocalChanged

func (self BranchSpan) LocalChanged() (localChanged bool, branch gitdomain.LocalBranchName, beforeSHA, afterSHA gitdomain.SHA)

func (BranchSpan) LocalRemoved

func (self BranchSpan) LocalRemoved() (localRemoved bool, branchName gitdomain.LocalBranchName, beforeSHA gitdomain.SHA)

func (BranchSpan) NoChanges

func (self BranchSpan) NoChanges() bool

NoChanges indicates whether this BranchSpan contains changes or not.

func (BranchSpan) RemoteAdded

func (self BranchSpan) RemoteAdded() (remoteAdded bool, addedRemoteBranchName gitdomain.RemoteBranchName, addedRemoteBranchSHA gitdomain.SHA)

func (BranchSpan) RemoteChanged

func (self BranchSpan) RemoteChanged() (remoteChanged bool, branchName gitdomain.RemoteBranchName, beforeSHA, afterSHA gitdomain.SHA)

func (BranchSpan) RemoteRemoved

func (self BranchSpan) RemoteRemoved() (remoteRemoved bool, remoteBranchName gitdomain.RemoteBranchName, beforeRemoteBranchSHA gitdomain.SHA)

type BranchSpans

type BranchSpans []BranchSpan

BranchSpans describes how a Git Town command has modified the branches in a Git repository.

func NewBranchSpans

func NewBranchSpans(beforeSnapshot, afterSnapshot gitdomain.BranchesSnapshot) BranchSpans

func (BranchSpans) Changes

func (self BranchSpans) Changes() BranchChanges

Changes describes the specific changes made in this BranchSpans.

type LocalBranchChange

type LocalBranchChange map[gitdomain.LocalBranchName]undodomain.Change[gitdomain.SHA]

func CategorizeLocalBranchChange

func CategorizeLocalBranchChange(change LocalBranchChange, config configdomain.ValidatedConfig) (changedPerennials, changedFeatures LocalBranchChange)

func (LocalBranchChange) BranchNames

func (self LocalBranchChange) BranchNames() gitdomain.LocalBranchNames

type LocalBranchesSHAs

type LocalBranchesSHAs map[gitdomain.LocalBranchName]gitdomain.SHA

func (LocalBranchesSHAs) BranchNames

func (self LocalBranchesSHAs) BranchNames() gitdomain.LocalBranchNames

type RemoteBranchChange

type RemoteBranchChange map[gitdomain.RemoteBranchName]undodomain.Change[gitdomain.SHA]

func CategorizeRemoteBranchChange

func CategorizeRemoteBranchChange(change RemoteBranchChange, config configdomain.ValidatedConfig) (perennialChanges, featureChanges RemoteBranchChange)

func (RemoteBranchChange) BranchNames

func (self RemoteBranchChange) BranchNames() gitdomain.RemoteBranchNames

type RemoteBranchesSHAs

type RemoteBranchesSHAs map[gitdomain.RemoteBranchName]gitdomain.SHA

func CategorizeRemoteBranchesSHAs

func CategorizeRemoteBranchesSHAs(shas RemoteBranchesSHAs, config configdomain.ValidatedConfig) (perennials, features RemoteBranchesSHAs)

func (RemoteBranchesSHAs) BranchNames

func (self RemoteBranchesSHAs) BranchNames() gitdomain.RemoteBranchNames

BranchNames provides the names of the involved branches as strings.

Jump to

Keyboard shortcuts

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