1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-05-29 23:17:32 +02:00

rename Sha to parent now that we're also considering stash entries

This commit is contained in:
Jesse Duffield 2020-08-21 20:10:25 +10:00
parent 9b42cd2214
commit 609f3f4bfa
5 changed files with 13 additions and 13 deletions

View File

@ -2,7 +2,7 @@ package commands
// CommitFile : A git commit file
type CommitFile struct {
Sha string
Parent string
Name string
DisplayString string
Status int // one of 'WHOLE' 'PART' 'NONE'

View File

@ -1046,13 +1046,13 @@ func (c *GitCommand) CherryPickCommits(commits []*Commit) error {
}
// GetFilesInRef get the specified commit files
func (c *GitCommand) GetFilesInRef(commitSha string, isStash bool, patchManager *patch.PatchManager) ([]*CommitFile, error) {
func (c *GitCommand) GetFilesInRef(parent string, isStash bool, patchManager *patch.PatchManager) ([]*CommitFile, error) {
command := "git diff-tree"
if isStash {
command = "git stash show"
}
files, err := c.OSCommand.RunCommandWithOutput("%s --no-commit-id --name-only -r --no-renames %s", command, commitSha)
files, err := c.OSCommand.RunCommandWithOutput("%s --no-commit-id --name-only -r --no-renames %s", command, parent)
if err != nil {
return nil, err
}
@ -1061,12 +1061,12 @@ func (c *GitCommand) GetFilesInRef(commitSha string, isStash bool, patchManager
for _, file := range strings.Split(strings.TrimRight(files, "\n"), "\n") {
status := patch.UNSELECTED
if patchManager != nil && patchManager.CommitSha == commitSha {
if patchManager != nil && patchManager.CommitSha == parent {
status = patchManager.GetFileStatus(file)
}
commitFiles = append(commitFiles, &CommitFile{
Sha: commitSha,
Parent: parent,
Name: file,
DisplayString: file,
Status: status,

View File

@ -1874,8 +1874,8 @@ func TestGitCommandGetFilesInRef(t *testing.T) {
func(commitFiles []*CommitFile, err error) {
assert.NoError(t, err)
assert.Equal(t, []*CommitFile{
{Sha: "123456", Name: "hello", DisplayString: "hello"},
{Sha: "123456", Name: "world", DisplayString: "world"},
{Parent: "123456", Name: "hello", DisplayString: "hello"},
{Parent: "123456", Name: "world", DisplayString: "world"},
}, commitFiles)
},
},

View File

@ -27,7 +27,7 @@ func (gui *Gui) handleCommitFileSelect() error {
}
cmd := gui.OSCommand.ExecutableFromString(
gui.GitCommand.ShowCommitFileCmdStr(commitFile.Sha, commitFile.Name, false),
gui.GitCommand.ShowCommitFileCmdStr(commitFile.Parent, commitFile.Name, false),
)
task := gui.createRunPtyTask(cmd)
@ -43,7 +43,7 @@ func (gui *Gui) handleCommitFileSelect() error {
func (gui *Gui) handleCheckoutCommitFile(g *gocui.Gui, v *gocui.View) error {
file := gui.State.CommitFiles[gui.State.Panels.CommitFiles.SelectedLineIdx]
if err := gui.GitCommand.CheckoutFile(file.Sha, file.Name); err != nil {
if err := gui.GitCommand.CheckoutFile(file.Parent, file.Name); err != nil {
return gui.surfaceError(err)
}
@ -133,7 +133,7 @@ func (gui *Gui) handleToggleFileForPatch(g *gocui.Gui, v *gocui.View) error {
return gui.refreshCommitFilesView()
}
if gui.GitCommand.PatchManager.CommitSelected() && gui.GitCommand.PatchManager.CommitSha != commitFile.Sha {
if gui.GitCommand.PatchManager.CommitSelected() && gui.GitCommand.PatchManager.CommitSha != commitFile.Parent {
return gui.ask(askOpts{
returnToView: v,
returnFocusOnClose: true,
@ -152,7 +152,7 @@ func (gui *Gui) handleToggleFileForPatch(g *gocui.Gui, v *gocui.View) error {
func (gui *Gui) startPatchManager() error {
diffMap := map[string]string{}
for _, commitFile := range gui.State.CommitFiles {
commitText, err := gui.GitCommand.ShowCommitFile(commitFile.Sha, commitFile.Name, true)
commitText, err := gui.GitCommand.ShowCommitFile(commitFile.Parent, commitFile.Name, true)
if err != nil {
return err
}
@ -196,7 +196,7 @@ func (gui *Gui) enterCommitFile(selectedLineIdx int) error {
return gui.refreshPatchBuildingPanel(selectedLineIdx)
}
if gui.GitCommand.PatchManager.CommitSelected() && gui.GitCommand.PatchManager.CommitSha != commitFile.Sha {
if gui.GitCommand.PatchManager.CommitSelected() && gui.GitCommand.PatchManager.CommitSha != commitFile.Parent {
return gui.ask(askOpts{
returnToView: gui.getCommitFilesView(),
returnFocusOnClose: false,

View File

@ -22,7 +22,7 @@ func (gui *Gui) refreshPatchBuildingPanel(selectedLineIdx int) error {
return nil
}
diff, err := gui.GitCommand.ShowCommitFile(commitFile.Sha, commitFile.Name, true)
diff, err := gui.GitCommand.ShowCommitFile(commitFile.Parent, commitFile.Name, true)
if err != nil {
return err
}