commands

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2018 License: MIT Imports: 14 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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) GetDisplayStrings added in v0.3.0

func (b *Branch) GetDisplayStrings() []string

GetDisplayStrings returns the dispaly string of branch

type Commit

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

Commit : A git commit

func (*Commit) GetDisplayStrings added in v0.3.0

func (c *Commit) GetDisplayStrings() []string

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
	Type               string // one of 'file', 'directory', and 'other'
}

File : A file from git status duplicating this for now

func (*File) GetDisplayStrings added in v0.3.0

func (f *File) GetDisplayStrings() []string

GetDisplayStrings returns the display string of a file

type GitCommand

type GitCommand struct {
	Log       *logrus.Entry
	OSCommand *OSCommand
	Worktree  *gogit.Worktree
	Repo      *gogit.Repository
	Tr        *i18n.Localizer
	// contains filtered or unexported fields
}

GitCommand is our main git interface

func NewGitCommand

func NewGitCommand(log *logrus.Entry, osCommand *OSCommand, tr *i18n.Localizer) (*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

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(fileName string) (string, error)

CatFile obtains the content 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(message string) (*exec.Cmd, error)

Commit commits to git

func (*GitCommand) DeleteBranch

func (c *GitCommand) DeleteBranch(branch string, force bool) 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() map[string]bool

GetCommitsToPush Returns the sha's of the commits that have not yet been pushed to the remote branch of the current branch, a map is returned to ease look up

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) error

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) PrepareCommitAmendSubProcess added in v0.2.2

func (c *GitCommand) PrepareCommitAmendSubProcess() *exec.Cmd

PrepareCommitAmendSubProcess prepares a subprocess for `git commit --amend --allow-empty`

func (*GitCommand) PrepareCommitSubProcess

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

PrepareCommitSubProcess prepares a subprocess for `git commit`

func (*GitCommand) Pull

func (c *GitCommand) Pull() error

Pull pulls from repo

func (*GitCommand) Push

func (c *GitCommand) Push(branchName string, force bool) error

Push pushes 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) 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) StageAll added in v0.2.0

func (c *GitCommand) StageAll() error

StageAll stages all files

func (*GitCommand) StageFile

func (c *GitCommand) StageFile(fileName 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(fileName string, tracked bool) error

UnStageFile unstages a file

func (*GitCommand) UnstageAll added in v0.2.0

func (c *GitCommand) UnstageAll() error

UnstageAll stages all files

func (*GitCommand) UpstreamDifferenceCount

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

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

type OSCommand

type OSCommand struct {
	Log      *logrus.Entry
	Platform *Platform
	Config   config.AppConfigurer
	// contains filtered or unexported fields
}

OSCommand holds all the os commands

func NewOSCommand

func NewOSCommand(log *logrus.Entry, config config.AppConfigurer) *OSCommand

NewOSCommand os command runner

func (*OSCommand) AppendLineToFile added in v0.1.73

func (c *OSCommand) AppendLineToFile(filename, line string) error

AppendLineToFile adds a new line in file

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) FileType added in v0.2.0

func (c *OSCommand) FileType(path string) string

FileType tells us if the file is a file, directory or other

func (*OSCommand) OpenFile

func (c *OSCommand) OpenFile(filename string) error

OpenFile opens a file with the given

func (*OSCommand) PrepareSubProcess

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

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) Unquote added in v0.1.71

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

Unquote removes wrapping quotations marks if they are present this is needed for removing quotes from staged filenames with spaces

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

func (*StashEntry) GetDisplayStrings added in v0.3.0

func (s *StashEntry) GetDisplayStrings() []string

GetDisplayStrings returns the dispaly string of branch

Jump to

Keyboard shortcuts

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