commands

package
v0.20.11 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2020 License: MIT Imports: 28 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// UNSELECTED is for when the commit file has not been added to the patch in any way
	UNSELECTED = iota
	// WHOLE is for when you want to add the whole diff of a file to the patch,
	// including e.g. if it was deleted
	WHOLE = iota
	// PART is for when you're only talking about specific lines that have been modified
	PART
)
View Source
const (
	PATCH_HEADER = iota
	COMMIT_SHA
	COMMIT_DESCRIPTION
	HUNK_HEADER
	ADDITION
	DELETION
	CONTEXT
	NEWLINE_MESSAGE
)
View Source
const CurrentBranchNameRegex = `(?m)^\*.*?([^ ]*?)\)?$`

this takes something like:

  • (HEAD detached at 264fc6f5) remotes

and returns '264fc6f5' as the second match

View Source
const SEPARATION_CHAR = "|"

Variables

This section is empty.

Functions

func GetHeaderFromDiff added in v0.10.1

func GetHeaderFromDiff(diff string) string

func Kill added in v0.16.1

func Kill(cmd *exec.Cmd) error

func ModifiedPatchForRange added in v0.10.1

func ModifiedPatchForRange(log *logrus.Entry, filename string, diffText string, firstLineIdx int, lastLineIdx int, reverse bool, keepOriginalHeader bool) string

func NewDummyAppConfig added in v0.7.1

func NewDummyAppConfig() *config.AppConfig

NewDummyAppConfig creates a new dummy AppConfig for testing

func NewDummyLog added in v0.7.1

func NewDummyLog() *logrus.Entry

NewDummyLog creates a new dummy Log for testing

func RunCommandWithOutputLiveWrapper added in v0.7.1

func RunCommandWithOutputLiveWrapper(c *OSCommand, command string, output func(string) string) error

RunCommandWithOutputLiveWrapper runs a command and return every word that gets written in stdout Output is a function that executes by every word that gets read by bufio As return of output you need to give a string that will be written to stdin NOTE: If the return data is empty it won't written anything to stdin

func RunLineOutputCmd added in v0.20.1

func RunLineOutputCmd(cmd *exec.Cmd, onLine func(line string) (bool, error)) error

func WrapError added in v0.8.1

func WrapError(err error) error

WrapError wraps an error for the sake of showing a stack trace at the top level the go-errors package, for some reason, does not return nil when you try to wrap a non-error, so we're just doing it here

Types

type Branch

type Branch struct {
	Name string
	// the displayname is something like '(HEAD detached at 123asdf)', whereas in that case the name would be '123asdf'
	DisplayName  string
	Recency      string
	Pushables    string
	Pullables    string
	UpstreamName string
	Head         bool
}

Branch : A git branch duplicating this for now

type BranchListBuilder added in v0.10.1

type BranchListBuilder struct {
	Log           *logrus.Entry
	GitCommand    *GitCommand
	ReflogCommits []*Commit
}

BranchListBuilder returns a list of Branch objects for the current repo

func NewBranchListBuilder added in v0.10.1

func NewBranchListBuilder(log *logrus.Entry, gitCommand *GitCommand, reflogCommits []*Commit) (*BranchListBuilder, error)

NewBranchListBuilder builds a new branch list builder

func (*BranchListBuilder) Build added in v0.10.1

func (b *BranchListBuilder) Build() []*Branch

Build the list of branches for the current repo

type CheckoutOptions added in v0.20.1

type CheckoutOptions struct {
	Force   bool
	EnvVars []string
}

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

type Commit

type Commit struct {
	Sha           string
	Name          string
	Status        string // one of "unpushed", "pushed", "merged", "rebasing" or "selected"
	Action        string // one of "", "pick", "edit", "squash", "reword", "drop", "fixup"
	Tags          []string
	ExtraInfo     string // something like 'HEAD -> master, tag: v0.15.2'
	Author        string
	UnixTimestamp int64
}

Commit : A git commit

func (*Commit) ShortSha added in v0.20.1

func (c *Commit) ShortSha() string

type CommitFile added in v0.8.1

type CommitFile struct {
	Sha           string
	Name          string
	DisplayString string
	Status        int // one of 'WHOLE' 'PART' 'NONE'
}

CommitFile : A git commit file

type CommitListBuilder added in v0.10.1

type CommitListBuilder struct {
	Log                 *logrus.Entry
	GitCommand          *GitCommand
	OSCommand           *OSCommand
	Tr                  *i18n.Localizer
	CherryPickedCommits []*Commit
}

CommitListBuilder returns a list of Branch objects for the current repo

func NewCommitListBuilder added in v0.10.1

func NewCommitListBuilder(log *logrus.Entry, gitCommand *GitCommand, osCommand *OSCommand, tr *i18n.Localizer, cherryPickedCommits []*Commit) (*CommitListBuilder, error)

NewCommitListBuilder builds a new commit list builder

func (*CommitListBuilder) GetCommits added in v0.10.1

func (c *CommitListBuilder) GetCommits(options GetCommitsOptions) ([]*Commit, error)

GetCommits obtains the commits of the current branch

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
	HasInlineMergeConflicts bool
	DisplayString           string
	Type                    string // one of 'file', 'directory', and 'other'
	ShortStatus             string // e.g. 'AD', ' A', 'M ', '??'
}

File : A file from git status duplicating this for now

type GetCommitsOptions added in v0.20.1

type GetCommitsOptions struct {
	Limit      bool
	FilterPath string
}

type GitCommand

type GitCommand struct {
	Log       *logrus.Entry
	OSCommand *OSCommand
	Worktree  *gogit.Worktree
	Repo      *gogit.Repository
	Tr        *i18n.Localizer
	Config    config.AppConfigurer

	DotGitDir string

	PatchManager *PatchManager

	// Push to current determines whether the user has configured to push to the remote branch of the same name as the current or not
	PushToCurrent bool
	// contains filtered or unexported fields
}

GitCommand is our main git interface

func NewDummyGitCommand added in v0.7.1

func NewDummyGitCommand() *GitCommand

NewDummyGitCommand creates a new dummy GitCommand for testing

func NewDummyGitCommandWithOSCommand added in v0.7.1

func NewDummyGitCommandWithOSCommand(osCommand *OSCommand) *GitCommand

NewDummyGitCommandWithOSCommand creates a new dummy GitCommand for testing

func NewGitCommand

func NewGitCommand(log *logrus.Entry, osCommand *OSCommand, tr *i18n.Localizer, config config.AppConfigurer) (*GitCommand, error)

NewGitCommand it runs git commands

func (*GitCommand) AbortMerge

func (c *GitCommand) AbortMerge() error

AbortMerge abort merge

func (*GitCommand) AddRemote added in v0.11.1

func (c *GitCommand) AddRemote(name string, url string) error

func (*GitCommand) AmendHead added in v0.7.1

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

AmendHead amends HEAD with whatever is staged in your working tree

func (*GitCommand) AmendTo added in v0.7.1

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

AmendTo amends the given commit with whatever files are staged

func (*GitCommand) ApplyPatch added in v0.7.1

func (c *GitCommand) ApplyPatch(patch string, flags ...string) error

func (*GitCommand) BeginInteractiveRebaseForCommit added in v0.10.1

func (c *GitCommand) BeginInteractiveRebaseForCommit(commits []*Commit, commitIndex int) error

BeginInteractiveRebaseForCommit starts an interactive rebase to edit the current commit and pick all others. After this you'll want to call `c.GenericMerge("rebase", "continue")`

func (*GitCommand) CatFile

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

CatFile obtains the content of a file

func (*GitCommand) CheckRemoteBranchExists added in v0.7.1

func (c *GitCommand) CheckRemoteBranchExists(branch *Branch) bool

CheckRemoteBranchExists Returns remote branch

func (*GitCommand) Checkout

func (c *GitCommand) Checkout(branch string, options CheckoutOptions) error

func (*GitCommand) CheckoutFile added in v0.8.1

func (c *GitCommand) CheckoutFile(commitSha, fileName string) error

CheckoutFile checks out the file for the given commit

func (*GitCommand) CherryPickCommits added in v0.7.1

func (c *GitCommand) CherryPickCommits(commits []*Commit) error

CherryPickCommits begins an interactive rebase with the given shas being cherry picked onto HEAD

func (*GitCommand) Commit

func (c *GitCommand) Commit(message string, flags string) (*exec.Cmd, error)

Commit commits to git

func (*GitCommand) ConfiguredPager added in v0.16.1

func (c *GitCommand) ConfiguredPager() string

func (*GitCommand) CreateFixupCommit added in v0.8.1

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

CreateFixupCommit creates a commit that fixes up a previous commit

func (*GitCommand) CreateLightweightTag added in v0.11.1

func (c *GitCommand) CreateLightweightTag(tagName string, commitSha string) error

func (*GitCommand) CurrentBranchName added in v0.7.1

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

CurrentBranchName get the current branch name and displayname. the first returned string is the name and the second is the displayname e.g. name is 123asdf and displayname is '(HEAD detached at 123asdf)'

func (*GitCommand) DeleteBranch

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

DeleteBranch delete branch

func (*GitCommand) DeletePatchesFromCommit added in v0.10.1

func (c *GitCommand) DeletePatchesFromCommit(commits []*Commit, commitIndex int, p *PatchManager) error

DeletePatchesFromCommit applies a patch in reverse for a commit

func (*GitCommand) DeleteRemoteBranch added in v0.11.1

func (c *GitCommand) DeleteRemoteBranch(remoteName string, branchName string) error

func (*GitCommand) DeleteTag added in v0.11.1

func (c *GitCommand) DeleteTag(tagName string) error

func (*GitCommand) Diff

func (c *GitCommand) Diff(file *File, plain bool, cached bool) string

Diff returns the diff of a file

func (*GitCommand) DiffCmdStr added in v0.14.1

func (c *GitCommand) DiffCmdStr(file *File, plain bool, cached bool) string

func (*GitCommand) DiscardAllFileChanges added in v0.8.1

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

DiscardAllFileChanges directly

func (*GitCommand) DiscardAnyUnstagedFileChanges added in v0.8.1

func (c *GitCommand) DiscardAnyUnstagedFileChanges() error

DiscardAnyUnstagedFileChanges discards any unstages file changes via `git checkout -- .`

func (*GitCommand) DiscardOldFileChanges added in v0.8.1

func (c *GitCommand) DiscardOldFileChanges(commits []*Commit, commitIndex int, fileName string) error

DiscardOldFileChanges discards changes to a file from an old commit

func (*GitCommand) DiscardUnstagedFileChanges added in v0.8.1

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

DiscardUnstagedFileChanges directly

func (*GitCommand) EditRebaseTodo added in v0.7.1

func (c *GitCommand) EditRebaseTodo(index int, action string) error

EditRebaseTodo sets the action at a given index in the git-rebase-todo file

func (*GitCommand) FastForward added in v0.7.1

func (c *GitCommand) FastForward(branchName string, remoteName string, remoteBranchName string) error

func (*GitCommand) Fetch

func (c *GitCommand) Fetch(unamePassQuestion func(string) string, canAskForCredentials bool) error

Fetch fetch git repo

func (*GitCommand) FetchRemote added in v0.12.1

func (c *GitCommand) FetchRemote(remoteName string) error

func (*GitCommand) GenerateGenericRebaseTodo added in v0.7.1

func (c *GitCommand) GenerateGenericRebaseTodo(commits []*Commit, actionIndex int, action string) (string, string, error)

func (*GitCommand) GenericMerge added in v0.7.1

func (c *GitCommand) GenericMerge(commandType string, command string) error

GenericMerge takes a commandType of "merge" or "rebase" and a command of "abort", "skip" or "continue" By default we skip the editor in the case where a commit will be made

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) GetBranchGraphCmdStr added in v0.14.1

func (c *GitCommand) GetBranchGraphCmdStr(branchName string) string

func (*GitCommand) GetBranchUpstreamDifferenceCount added in v0.7.1

func (c *GitCommand) GetBranchUpstreamDifferenceCount(branchName string) (string, string)

func (*GitCommand) GetCommitDifferences added in v0.7.1

func (c *GitCommand) GetCommitDifferences(from, to string) (string, string)

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

func (*GitCommand) GetCommitFiles added in v0.8.1

func (c *GitCommand) GetCommitFiles(commitSha string, patchManager *PatchManager) ([]*CommitFile, error)

GetCommitFiles get the specified commit files

func (*GitCommand) GetCurrentBranchUpstreamDifferenceCount added in v0.7.1

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

func (*GitCommand) GetHeadCommitMessage added in v0.20.3

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

Get the subject of the HEAD commit

func (*GitCommand) GetPager added in v0.16.1

func (c *GitCommand) GetPager(width int) string

func (*GitCommand) GetReflogCommits added in v0.14.1

func (c *GitCommand) GetReflogCommits(lastReflogCommit *Commit, filterPath string) ([]*Commit, bool, error)

func (*GitCommand) GetRemoteURL added in v0.7.1

func (c *GitCommand) GetRemoteURL() string

GetRemoteURL returns current repo remote url

func (*GitCommand) GetRemotes added in v0.11.1

func (c *GitCommand) GetRemotes() ([]*Remote, error)

func (*GitCommand) GetStashEntries

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

GetStashEntries stash entries

func (*GitCommand) GetStatusFiles

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

GetStatusFiles git status files

func (*GitCommand) GetTags added in v0.11.1

func (c *GitCommand) GetTags() ([]*Tag, error)

func (*GitCommand) GetUpstreamForBranch added in v0.10.6

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

func (*GitCommand) GitStatus

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

GitStatus returns the plaintext short status of the repo

func (*GitCommand) HardReset added in v0.7.1

func (c *GitCommand) HardReset(baseSha string) error

func (*GitCommand) Ignore

func (c *GitCommand) Ignore(filename string) error

Ignore adds a file to the gitignore for the repo

func (*GitCommand) InteractiveRebase added in v0.7.1

func (c *GitCommand) InteractiveRebase(commits []*Commit, index int, action string) error

func (*GitCommand) IsHeadDetached added in v0.11.1

func (c *GitCommand) IsHeadDetached() bool

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) MoveCommitDown added in v0.7.1

func (c *GitCommand) MoveCommitDown(commits []*Commit, index int) error

func (*GitCommand) MovePatchToSelectedCommit added in v0.10.1

func (c *GitCommand) MovePatchToSelectedCommit(commits []*Commit, sourceCommitIdx int, destinationCommitIdx int, p *PatchManager) error

func (*GitCommand) MoveTodoDown added in v0.7.1

func (c *GitCommand) MoveTodoDown(index int) error

MoveTodoDown moves a rebase todo item down by one position

func (*GitCommand) NewBranch

func (c *GitCommand) NewBranch(name string, baseBranch 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) PrepareInteractiveRebaseCommand added in v0.7.1

func (c *GitCommand) PrepareInteractiveRebaseCommand(baseSha string, todo string, overrideEditor bool) (*exec.Cmd, error)

PrepareInteractiveRebaseCommand returns the cmd for an interactive rebase we tell git to run lazygit to edit the todo list, and we pass the client lazygit a todo string to write to the todo file

func (*GitCommand) Pull

func (c *GitCommand) Pull(args string, ask func(string) string) error

Pull pulls from repo

func (*GitCommand) PullPatchIntoIndex added in v0.10.1

func (c *GitCommand) PullPatchIntoIndex(commits []*Commit, commitIdx int, p *PatchManager, stash bool) error

func (*GitCommand) PullPatchIntoNewCommit added in v0.20.3

func (c *GitCommand) PullPatchIntoNewCommit(commits []*Commit, commitIdx int, p *PatchManager) error

func (*GitCommand) PullWithoutPasswordCheck added in v0.14.4

func (c *GitCommand) PullWithoutPasswordCheck(args string) error

PullWithoutPasswordCheck assumes that the pull will not prompt the user for a password

func (*GitCommand) Push

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

Push pushes to a branch

func (*GitCommand) PushTag added in v0.11.1

func (c *GitCommand) PushTag(remoteName string, tagName string) error

func (*GitCommand) RebaseBranch added in v0.7.1

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

RebaseBranch interactive rebases onto a branch

func (*GitCommand) RebaseMode added in v0.7.1

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

RebaseMode returns "" for non-rebase mode, "normal" for normal rebase and "interactive" for interactive rebase

func (*GitCommand) RemoveRemote added in v0.11.1

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

func (*GitCommand) RemoveTrackedFiles added in v0.14.3

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

RemoveTrackedFiles will delete the given file(s) even if they are currently tracked

func (*GitCommand) RemoveUntrackedFiles added in v0.8.1

func (c *GitCommand) RemoveUntrackedFiles() error

RemoveUntrackedFiles runs `git clean -fd`

func (*GitCommand) RenameBranch added in v0.17.0

func (c *GitCommand) RenameBranch(oldName string, newName string) error

func (*GitCommand) RenameCommit

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

RenameCommit renames the topmost commit with the given name

func (*GitCommand) RenameRemote added in v0.11.1

func (c *GitCommand) RenameRemote(oldRemoteName string, newRemoteName string) error

func (*GitCommand) ResetAndClean added in v0.7.1

func (c *GitCommand) ResetAndClean() error

ResetAndClean removes all unstaged changes and removes all untracked files

func (*GitCommand) ResetHard

func (c *GitCommand) ResetHard(ref string) error

ResetHardHead runs `git reset --hard`

func (*GitCommand) ResetSoft added in v0.12.1

func (c *GitCommand) ResetSoft(ref string) error

ResetSoft runs `git reset --soft HEAD`

func (*GitCommand) ResetToCommit

func (c *GitCommand) ResetToCommit(sha string, strength string, options RunCommandOptions) error

ResetToCommit reset to commit

func (*GitCommand) Revert added in v0.7.1

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

Revert reverts the selected commit by sha

func (*GitCommand) RewordCommit added in v0.7.1

func (c *GitCommand) RewordCommit(commits []*Commit, index int) (*exec.Cmd, error)

func (*GitCommand) RunSkipEditorCommand added in v0.7.1

func (c *GitCommand) RunSkipEditorCommand(command string) error

func (*GitCommand) SetBranchUpstream added in v0.11.1

func (c *GitCommand) SetBranchUpstream(remoteName string, remoteBranchName string, branchName string) error

func (*GitCommand) SetUpstreamBranch added in v0.10.6

func (c *GitCommand) SetUpstreamBranch(upstream string) error

func (*GitCommand) ShowCmdStr added in v0.14.1

func (c *GitCommand) ShowCmdStr(sha string, filterPath string) string

func (*GitCommand) ShowCommitFile added in v0.8.1

func (c *GitCommand) ShowCommitFile(commitSha, fileName string, plain bool) (string, error)

ShowCommitFile get the diff of specified commit file

func (*GitCommand) ShowCommitFileCmdStr added in v0.14.1

func (c *GitCommand) ShowCommitFileCmdStr(commitSha, fileName string, plain bool) string

func (*GitCommand) ShowStashEntryCmdStr added in v0.14.1

func (c *GitCommand) ShowStashEntryCmdStr(index int) string

GetStashEntryDiff stash diff

func (*GitCommand) SoftReset added in v0.7.1

func (c *GitCommand) SoftReset(baseSha string) error

func (*GitCommand) SquashAllAboveFixupCommits added in v0.8.1

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

SquashAllAboveFixupCommits squashes all fixup! commits above the given one

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) StashSaveStagedChanges added in v0.8.1

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

StashSaveStagedChanges stashes only the currently staged changes. This takes a few steps shoutouts to Joe on https://stackoverflow.com/questions/14759748/stashing-only-staged-changes-in-git-is-it-possible

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) UpdateRemoteUrl added in v0.11.1

func (c *GitCommand) UpdateRemoteUrl(remoteName string, updatedUrl string) error

func (*GitCommand) WorkingTreeState added in v0.20.1

func (c *GitCommand) WorkingTreeState() string

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 NewDummyOSCommand added in v0.7.1

func NewDummyOSCommand() *OSCommand

NewDummyOSCommand creates a new dummy OSCommand for testing

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) CopyToClipboard added in v0.20.1

func (c *OSCommand) CopyToClipboard(str string) error

func (*OSCommand) CreateFileWithContent added in v0.10.1

func (c *OSCommand) CreateFileWithContent(path string, content string) error

CreateFileWithContent creates a file with the given content

func (*OSCommand) CreateTempFile added in v0.7.1

func (c *OSCommand) CreateTempFile(filename, content string) (string, error)

CreateTempFile writes a string to a new temp file and returns the file's name

func (*OSCommand) DetectUnamePass added in v0.7.1

func (c *OSCommand) DetectUnamePass(command string, ask func(string) string) error

DetectUnamePass detect a username / password question in a command ask is a function that gets executen when this function detect you need to fillin a password The ask argument will be "username" or "password" and expects the user's password or username back

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) ExecutableFromString added in v0.7.1

func (c *OSCommand) ExecutableFromString(commandStr string) *exec.Cmd

ExecutableFromString takes a string like `git status` and returns an executable command for it

func (*OSCommand) FileExists added in v0.7.1

func (c *OSCommand) FileExists(path string) (bool, error)

FileExists checks whether a file exists at the specified path

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) GetLazygitPath added in v0.7.1

func (c *OSCommand) GetLazygitPath() string

GetLazygitPath returns the path of the currently executed file

func (*OSCommand) OpenFile

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

OpenFile opens a file with the given

func (c *OSCommand) OpenLink(link string) error

OpenLink opens a file with the given

func (*OSCommand) PipeCommands added in v0.8.1

func (c *OSCommand) PipeCommands(commandStrings ...string) error

PipeCommands runs a heap of commands and pipes their inputs/outputs together like A | B | C

func (*OSCommand) PrepareSubProcess

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

PrepareSubProcess iniPrepareSubProcessrocess then tells the Gui to switch to it TODO: see if this needs to exist, given that ExecutableFromString does the same things

func (*OSCommand) Quote

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

Quote wraps a message in platform-specific quotation marks

func (*OSCommand) Remove added in v0.8.1

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

Remove removes a file or directory at the specified path

func (*OSCommand) RunCommand

func (c *OSCommand) RunCommand(formatString string, formatArgs ...interface{}) error

RunCommand runs a command and just returns the error

func (*OSCommand) RunCommandWithOptions added in v0.20.1

func (c *OSCommand) RunCommandWithOptions(command string, options RunCommandOptions) error

func (*OSCommand) RunCommandWithOutput

func (c *OSCommand) RunCommandWithOutput(formatString string, formatArgs ...interface{}) (string, error)

RunCommandWithOutput wrapper around commands returning their output and error NOTE: If you don't pass any formatArgs we'll just use the command directly, however there's a bizarre compiler error/warning when you pass in a formatString with a percent sign because it thinks it's supposed to be a formatString when in that case it's not. To get around that error you'll need to define the string in a variable and pass the variable into RunCommandWithOutput.

func (*OSCommand) RunCommandWithOutputLive added in v0.7.1

func (c *OSCommand) RunCommandWithOutputLive(command string, output func(string) string) error

RunCommandWithOutputLive runs RunCommandWithOutputLiveWrapper

func (*OSCommand) RunCommandWithOutputWithOptions added in v0.20.1

func (c *OSCommand) RunCommandWithOutputWithOptions(command string, options RunCommandOptions) (string, error)

func (*OSCommand) RunCustomCommand added in v0.8.1

func (c *OSCommand) RunCustomCommand(command string) *exec.Cmd

RunCustomCommand returns the pointer to a custom command

func (*OSCommand) RunDirectCommand

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

RunDirectCommand wrapper around direct commands

func (*OSCommand) RunExecutable added in v0.7.1

func (c *OSCommand) RunExecutable(cmd *exec.Cmd) error

RunExecutable runs an executable file and returns an error if there was one

func (*OSCommand) RunExecutableWithOutput added in v0.7.1

func (c *OSCommand) RunExecutableWithOutput(cmd *exec.Cmd) (string, error)

RunExecutableWithOutput runs an executable file and returns its output

func (*OSCommand) RunPreparedCommand added in v0.7.1

func (c *OSCommand) RunPreparedCommand(cmd *exec.Cmd) error

RunPreparedCommand takes a pointer to an exec.Cmd and runs it this is useful if you need to give your command some environment variables before running it

func (*OSCommand) SetBeforeExecuteCmd added in v0.14.1

func (c *OSCommand) SetBeforeExecuteCmd(cmd func(*exec.Cmd))

func (*OSCommand) SetCommand added in v0.7.1

func (c *OSCommand) SetCommand(cmd func(string, ...string) *exec.Cmd)

SetCommand sets the command function used by the struct. To be used for testing only

func (*OSCommand) ShellCommandFromString added in v0.20.8

func (c *OSCommand) ShellCommandFromString(commandStr string) *exec.Cmd

ShellCommandFromString takes a string like `git commit` and returns an executable shell command for it

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 PatchHunk added in v0.10.1

type PatchHunk struct {
	FirstLineIdx int
	LastLineIdx  int
	// contains filtered or unexported fields
}

func GetHunksFromDiff added in v0.10.1

func GetHunksFromDiff(diff string) []*PatchHunk

type PatchLine added in v0.10.1

type PatchLine struct {
	Kind    int
	Content string // something like '+ hello' (note the first character is not removed)
}

type PatchManager added in v0.10.1

type PatchManager struct {
	CommitSha string

	Log        *logrus.Entry
	ApplyPatch applyPatchFunc
	// contains filtered or unexported fields
}

PatchManager manages the building of a patch for a commit to be applied to another commit (or the working tree, or removed from the current commit)

func NewPatchManager added in v0.10.1

func NewPatchManager(log *logrus.Entry, applyPatch applyPatchFunc) *PatchManager

NewPatchManager returns a new PatchModifier

func (*PatchManager) AddFile added in v0.10.1

func (p *PatchManager) AddFile(filename string)

func (*PatchManager) AddFileLineRange added in v0.10.1

func (p *PatchManager) AddFileLineRange(filename string, firstLineIdx, lastLineIdx int)

func (*PatchManager) ApplyPatches added in v0.10.1

func (p *PatchManager) ApplyPatches(reverse bool) error

func (*PatchManager) CommitSelected added in v0.10.1

func (p *PatchManager) CommitSelected() bool

func (*PatchManager) GetFileIncLineIndices added in v0.10.1

func (p *PatchManager) GetFileIncLineIndices(filename string) []int

func (*PatchManager) GetFileStatus added in v0.10.1

func (p *PatchManager) GetFileStatus(filename string) int

func (*PatchManager) IsEmpty added in v0.10.1

func (p *PatchManager) IsEmpty() bool

func (*PatchManager) RemoveFile added in v0.10.1

func (p *PatchManager) RemoveFile(filename string)

func (*PatchManager) RemoveFileLineRange added in v0.10.1

func (p *PatchManager) RemoveFileLineRange(filename string, firstLineIdx, lastLineIdx int)

func (*PatchManager) RenderAggregatedPatchColored added in v0.10.1

func (p *PatchManager) RenderAggregatedPatchColored(plain bool) string

func (*PatchManager) RenderEachFilePatch added in v0.10.1

func (p *PatchManager) RenderEachFilePatch(plain bool) []string

func (*PatchManager) RenderPatchForFile added in v0.10.1

func (p *PatchManager) RenderPatchForFile(filename string, plain bool, reverse bool, keepOriginalHeader bool) string

func (*PatchManager) RenderPlainPatchForFile added in v0.10.1

func (p *PatchManager) RenderPlainPatchForFile(filename string, reverse bool, keepOriginalHeader bool) string

func (*PatchManager) Reset added in v0.10.1

func (p *PatchManager) Reset()

clears the patch

func (*PatchManager) Start added in v0.10.1

func (p *PatchManager) Start(commitSha string, diffMap map[string]string)

NewPatchManager returns a new PatchModifier

func (*PatchManager) ToggleFileWhole added in v0.10.1

func (p *PatchManager) ToggleFileWhole(filename string)

type PatchModifier added in v0.10.1

type PatchModifier struct {
	Log *logrus.Entry
	// contains filtered or unexported fields
}

func NewPatchModifier added in v0.10.1

func NewPatchModifier(log *logrus.Entry, filename string, diffText string) *PatchModifier

func (*PatchModifier) ModifiedPatchForLines added in v0.10.1

func (d *PatchModifier) ModifiedPatchForLines(lineIndices []int, reverse bool, keepOriginalHeader bool) string

func (*PatchModifier) ModifiedPatchForRange added in v0.10.1

func (d *PatchModifier) ModifiedPatchForRange(firstLineIdx int, lastLineIdx int, reverse bool, keepOriginalHeader bool) string

func (*PatchModifier) OriginalPatchLength added in v0.10.1

func (d *PatchModifier) OriginalPatchLength() int

type PatchParser added in v0.10.1

type PatchParser struct {
	Log            *logrus.Entry
	PatchLines     []*PatchLine
	PatchHunks     []*PatchHunk
	HunkStarts     []int
	StageableLines []int // rename to mention we're talking about indexes
}

func NewPatchParser added in v0.10.1

func NewPatchParser(log *logrus.Entry, patch string) (*PatchParser, error)

NewPatchParser builds a new branch list builder

func (*PatchParser) GetHunkContainingLine added in v0.10.1

func (p *PatchParser) GetHunkContainingLine(lineIndex int, offset int) *PatchHunk

GetHunkContainingLine takes a line index and an offset and finds the hunk which contains the line index, then returns the hunk considering the offset. e.g. if the offset is 1 it will return the next hunk.

func (*PatchParser) GetNextStageableLineIndex added in v0.10.1

func (p *PatchParser) GetNextStageableLineIndex(currentIndex int) int

GetNextStageableLineIndex takes a line index and returns the line index of the next stageable line note this will actually include the current index if it is stageable

func (*PatchParser) Render added in v0.10.1

func (p *PatchParser) Render(firstLineIndex int, lastLineIndex int, incLineIndices []int) string

Render returns the coloured string of the diff with any selected lines highlighted

type Platform

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

Platform stores the os state

type PullRequest added in v0.7.1

type PullRequest struct {
	GitServices []*Service
	GitCommand  *GitCommand
}

PullRequest opens a link in browser to create new pull request with selected branch

func NewPullRequest added in v0.7.1

func NewPullRequest(gitCommand *GitCommand) *PullRequest

NewPullRequest creates new instance of PullRequest

func (*PullRequest) Create added in v0.7.1

func (pr *PullRequest) Create(branch *Branch) error

Create opens link to new pull request in browser

type Remote added in v0.11.1

type Remote struct {
	Name     string
	Urls     []string
	Branches []*RemoteBranch
}

Remote : A git remote

type RemoteBranch added in v0.11.1

type RemoteBranch struct {
	Name       string
	RemoteName string
}

Remote Branch : A git remote branch

func (*RemoteBranch) FullName added in v0.20.1

func (r *RemoteBranch) FullName() string

type RepoInformation added in v0.7.1

type RepoInformation struct {
	Owner      string
	Repository string
}

RepoInformation holds some basic information about the repo

type RunCommandOptions added in v0.20.1

type RunCommandOptions struct {
	EnvVars []string
}

type Service added in v0.7.1

type Service struct {
	Name           string
	PullRequestURL string
}

Service is a service that repository is on (Github, Bitbucket, ...)

func NewService added in v0.16.1

func NewService(typeName string, repositoryDomain string, siteDomain string) *Service

NewService builds a Service based on the host type

type StashEntry

type StashEntry struct {
	Index int
	Name  string
}

StashEntry : A git stash entry

func (*StashEntry) RefName added in v0.20.1

func (s *StashEntry) RefName() string

type Tag added in v0.11.1

type Tag struct {
	Name string
}

Tag : A git tag

Jump to

Keyboard shortcuts

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