diff options
author | skanehira <sho19921005@gmail.com> | 2019-03-09 23:42:10 +0900 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2019-03-16 10:20:27 +1100 |
commit | 06fe726ee79d3993d936ae3e064761273b657ae8 (patch) | |
tree | 1da4c337f9e506944f762c09ba930451c5c823b4 /pkg/gui/commits_panel.go | |
parent | 1b6e46973ebfdb6ba873fac6a2ce05bb1f8db8c1 (diff) |
Add feature of display committed file list #383
Diffstat (limited to 'pkg/gui/commits_panel.go')
-rw-r--r-- | pkg/gui/commits_panel.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go index 2154ad5c9..e1d520be1 100644 --- a/pkg/gui/commits_panel.go +++ b/pkg/gui/commits_panel.go @@ -3,6 +3,7 @@ package gui import ( "fmt" "strconv" + "strings" "github.com/go-errors/errors" @@ -437,3 +438,38 @@ func (gui *Gui) HandlePasteCommits(g *gocui.Gui, v *gocui.View) error { }) }, nil) } + +func (gui *Gui) handleSwitchToCommitFilesPanel(g *gocui.Gui, v *gocui.View) error { + commit := gui.getSelectedCommit(g) + if commit == nil { + return nil + } + + commitfileView, err := g.View("commit files") + if err != nil { + return err + } + + files, err := gui.GitCommand.CommitFiles(commit.Sha) + if err != nil { + return gui.createErrorPanel(g, err.Error()) + } + + gui.State.Panels.CommitFiles = &commitFilesPanelState{SelectedLine: 0} + gui.State.CommitFiles = make([]*commands.CommitFile, 0) + + if files == "" { + gui.State.Panels.CommitFiles.SelectedLine = -1 + } + + for _, file := range strings.Split(strings.TrimRight(files, "\n"), "\n") { + gui.State.CommitFiles = append(gui.State.CommitFiles, &commands.CommitFile{ + Sha: commit.Sha, + Name: file, + DisplayString: file, + }) + } + + gui.renderString(g, "commit files", files) + return gui.switchFocus(g, v, commitfileView) +} |