commands

package
v0.1.60 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2018 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoOpenCommand : When we don't know which command to use to open a file
	ErrNoOpenCommand = errors.New("Unsure what command to use to open this file")
	// ErrNoEditorDefined : When we can't find an editor to edit a file
	ErrNoEditorDefined = errors.New("No editor defined in $VISUAL, $EDITOR, or git config")
)

Functions

func Map

func Map(vs []string, f func(string) string) []string

Map (from https://gobyexample.com/collection-functions)

Types

type Branch

type Branch struct {
	Name    string
	Recency string
}

Branch : A git branch duplicating this for now

func (*Branch) GetColor

func (b *Branch) GetColor() color.Attribute

GetColor branch color

func (*Branch) GetDisplayString

func (b *Branch) GetDisplayString() string

GetDisplayString returns the dispaly string of branch

type Commit

type Commit struct {
	Sha           string
	Name          string
	Pushed        bool
	DisplayString string
}

Commit : A git commit

type Conflict

type Conflict struct {
	Start  int
	Middle int
	End    int
}

Conflict : A git conflict with a start middle and end corresponding to line numbers in the file where the conflict bars appear

type File

type File struct {
	Name               string
	HasStagedChanges   bool
	HasUnstagedChanges bool
	Tracked            bool
	Deleted            bool
	HasMergeConflicts  bool
	DisplayString      string
}

File : A staged/unstaged file TODO: decide whether to give all of these the Git prefix

type GitCommand

type GitCommand struct {
	Log       *logrus.Logger
	OSCommand *OSCommand
	Worktree  *gogit.Worktree
	Repo      *gogit.Repository
}

GitCommand is our main git interface

func NewGitCommand

func NewGitCommand(log *logrus.Logger, osCommand *OSCommand) (*GitCommand, error)

NewGitCommand it runs git commands

func (*GitCommand) AbortMerge

func (c *GitCommand) AbortMerge() error

AbortMerge abort merge

func (*GitCommand) AddPatch

func (c *GitCommand) AddPatch(filename string) (*exec.Cmd, error)

AddPatch prepares a subprocess for adding a patch by patch this will eventually be swapped out for a better solution inside the Gui

func (*GitCommand) CatFile

func (c *GitCommand) CatFile(file string) (string, error)

CatFile obtain the contents of a file

func (*GitCommand) Checkout

func (c *GitCommand) Checkout(branch string, force bool) error

Checkout checks out a branch, with --force if you set the force arg to true

func (*GitCommand) Commit

func (c *GitCommand) Commit(g *gocui.Gui, message string) (*exec.Cmd, error)

Commit commit to git

func (*GitCommand) DeleteBranch

func (c *GitCommand) DeleteBranch(branch string) error

DeleteBranch delete branch

func (*GitCommand) Diff

func (c *GitCommand) Diff(file File) string

Diff returns the diff of a file

func (*GitCommand) Fetch

func (c *GitCommand) Fetch() error

Fetch fetch git repo

func (*GitCommand) GetBranchGraph

func (c *GitCommand) GetBranchGraph(branchName string) (string, error)

GetBranchGraph gets the color-formatted graph of the log for the given branch Currently it limits the result to 100 commits, but when we get async stuff working we can do lazy loading

func (*GitCommand) GetBranchName

func (c *GitCommand) GetBranchName() (string, error)

GetBranchName branch name

func (*GitCommand) GetCommits

func (c *GitCommand) GetCommits() []Commit

GetCommits obtains the commits of the current branch

func (*GitCommand) GetCommitsToPush

func (c *GitCommand) GetCommitsToPush() []string

GetCommitsToPush Returns the sha's of the commits that have not yet been pushed to the remote branch of the current branch

func (*GitCommand) GetLog

func (c *GitCommand) GetLog() string

GetLog gets the git log (currently limited to 30 commits for performance until we work out lazy loading

func (*GitCommand) GetStashEntries

func (c *GitCommand) GetStashEntries() []StashEntry

GetStashEntries stash entryies

func (*GitCommand) GetStashEntryDiff

func (c *GitCommand) GetStashEntryDiff(index int) (string, error)

GetStashEntryDiff stash diff

func (*GitCommand) GetStatusFiles

func (c *GitCommand) GetStatusFiles() []File

GetStatusFiles git status files

func (*GitCommand) GitStatus

func (c *GitCommand) GitStatus() (string, error)

GitStatus returns the plaintext short status of the repo

func (*GitCommand) Ignore

func (c *GitCommand) Ignore(filename string)

Ignore adds a file to the gitignore for the repo

func (*GitCommand) IsInMergeState

func (c *GitCommand) IsInMergeState() (bool, error)

IsInMergeState states whether we are still mid-merge

func (*GitCommand) ListStash

func (c *GitCommand) ListStash() (string, error)

ListStash list stash

func (*GitCommand) Merge

func (c *GitCommand) Merge(branchName string) error

Merge merge

func (*GitCommand) MergeStatusFiles

func (c *GitCommand) MergeStatusFiles(oldFiles, newFiles []File) []File

MergeStatusFiles merge status files

func (*GitCommand) NewBranch

func (c *GitCommand) NewBranch(name string) error

NewBranch create new branch

func (*GitCommand) PrepareCommitSubProcess

func (c *GitCommand) PrepareCommitSubProcess() (*exec.Cmd, error)

PrepareCommitSubProcess prepares a subprocess for `git commit`

func (*GitCommand) Pull

func (c *GitCommand) Pull() error

Pull pull from repo

func (*GitCommand) Push

func (c *GitCommand) Push(branchName string) error

Push push to a branch

func (*GitCommand) RemoveFile

func (c *GitCommand) RemoveFile(file File) error

RemoveFile directly

func (*GitCommand) RenameCommit

func (c *GitCommand) RenameCommit(name string) error

RenameCommit renames the topmost commit with the given name

func (*GitCommand) ResetHard

func (c *GitCommand) ResetHard() error

ResetHard does the equivalent of `git reset --hard HEAD`

func (*GitCommand) ResetToCommit

func (c *GitCommand) ResetToCommit(sha string) error

ResetToCommit reset to commit

func (*GitCommand) SetupGit

func (c *GitCommand) SetupGit()

SetupGit sets git repo up

func (*GitCommand) Show

func (c *GitCommand) Show(sha string) string

Show shows the diff of a commit

func (*GitCommand) SquashFixupCommit

func (c *GitCommand) SquashFixupCommit(branchName string, shaValue string) error

SquashFixupCommit squashes a 'FIXUP' commit into the commit beneath it, retaining the commit message of the lower commit

func (*GitCommand) SquashPreviousTwoCommits

func (c *GitCommand) SquashPreviousTwoCommits(message string) error

SquashPreviousTwoCommits squashes a commit down to the one below it retaining the message of the higher commit

func (*GitCommand) StageFile

func (c *GitCommand) StageFile(file string) error

StageFile stages a file

func (*GitCommand) StashDo

func (c *GitCommand) StashDo(index int, method string) error

StashDo modify stash

func (*GitCommand) StashSave

func (c *GitCommand) StashSave(message string) error

StashSave save stash TODO: before calling this, check if there is anything to save

func (*GitCommand) UnStageFile

func (c *GitCommand) UnStageFile(file string, tracked bool) error

UnStageFile unstages a file

func (*GitCommand) UpstreamDifferenceCount

func (c *GitCommand) UpstreamDifferenceCount() (string, string)

UpstreamDifferenceCount checks how many pushables/pullables there are for the current branch

func (*GitCommand) UsingGpg

func (c *GitCommand) UsingGpg() bool

UsingGpg tells us whether the user has gpg enabled so that we can know whether we need to run a subprocess to allow them to enter their password

type OSCommand

type OSCommand struct {
	Log      *logrus.Logger
	Platform *Platform
}

OSCommand holds all the os commands

func NewOSCommand

func NewOSCommand(log *logrus.Logger) (*OSCommand, error)

NewOSCommand os command runner

func (*OSCommand) EditFile

func (c *OSCommand) EditFile(filename string) (*exec.Cmd, error)

EditFile opens a file in a subprocess using whatever editor is available, falling back to core.editor, VISUAL, EDITOR, then vi

func (*OSCommand) GetOpenCommand

func (c *OSCommand) GetOpenCommand() (string, string, error)

GetOpenCommand get open command

func (*OSCommand) OpenFile

func (c *OSCommand) OpenFile(filename string) (*exec.Cmd, error)

OpenFile opens a file with the given

func (*OSCommand) PrepareSubProcess

func (c *OSCommand) PrepareSubProcess(cmdName string, commandArgs ...string) (*exec.Cmd, error)

PrepareSubProcess iniPrepareSubProcessrocess then tells the Gui to switch to it

func (*OSCommand) Quote

func (c *OSCommand) Quote(message string) string

Quote wraps a message in platform-specific quotation marks

func (*OSCommand) RunCommand

func (c *OSCommand) RunCommand(command string) error

RunCommand runs a command and just returns the error

func (*OSCommand) RunCommandWithOutput

func (c *OSCommand) RunCommandWithOutput(command string) (string, error)

RunCommandWithOutput wrapper around commands returning their output and error

func (*OSCommand) RunDirectCommand

func (c *OSCommand) RunDirectCommand(command string) (string, error)

RunDirectCommand wrapper around direct commands

func (*OSCommand) SublimeOpenFile

func (c *OSCommand) SublimeOpenFile(filename string) (*exec.Cmd, error)

SublimeOpenFile opens the filein sublime may be deprecated in the future

func (*OSCommand) VsCodeOpenFile

func (c *OSCommand) VsCodeOpenFile(filename string) (*exec.Cmd, error)

VsCodeOpenFile opens the file in code, with the -r flag to open in the current window each of these open files needs to have the same function signature because they're being passed as arguments into another function, but only editFile actually returns a *exec.Cmd

type Platform

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

Platform stores the os state

type StashEntry

type StashEntry struct {
	Index         int
	Name          string
	DisplayString string
}

StashEntry : A git stash entry

Jump to

Keyboard shortcuts

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