Skip to content

Commit

Permalink
Merge pull request jesseduffield#143 from jesseduffield/feature/clean_up
Browse files Browse the repository at this point in the history
Platform should only be present once
  • Loading branch information
jesseduffield authored Aug 14, 2018
2 parents c0a1f90 + 842ceec commit ad3d332
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 34 deletions.
10 changes: 5 additions & 5 deletions pkg/commands/os.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var (
)

// Platform stores the os state
type platform struct {
type Platform struct {
os string
shell string
shellArg string
Expand All @@ -29,7 +29,7 @@ type platform struct {
// OSCommand holds all the os commands
type OSCommand struct {
Log *logrus.Logger
Platform platform
Platform *Platform
}

// NewOSCommand os command runner
Expand Down Expand Up @@ -67,17 +67,17 @@ func sanitisedCommandOutput(output []byte, err error) (string, error) {
return outputString, err
}

func getPlatform() platform {
func getPlatform() *Platform {
switch runtime.GOOS {
case "windows":
return platform{
return &Platform{
os: "windows",
shell: "cmd",
shellArg: "/c",
escapedQuote: "\\\"",
}
default:
return platform{
return &Platform{
os: runtime.GOOS,
shell: "bash",
shellArg: "-c",
Expand Down
31 changes: 2 additions & 29 deletions pkg/gui/gui.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"log"
"os"
"os/exec"
"runtime"
"strings"
"time"

Expand Down Expand Up @@ -53,7 +52,7 @@ type guiState struct {
ConflictTop bool
Conflicts []commands.Conflict
EditHistory *stack.Stack
Platform platform
Platform commands.Platform
Version string
}

Expand All @@ -68,7 +67,7 @@ func NewGui(log *logrus.Logger, gitCommand *commands.GitCommand, oSCommand *comm
ConflictTop: true,
Conflicts: make([]commands.Conflict, 0),
EditHistory: stack.New(),
Platform: getPlatform(),
Platform: *oSCommand.Platform,
Version: "test version", // TODO: send version in
}

Expand All @@ -81,32 +80,6 @@ func NewGui(log *logrus.Logger, gitCommand *commands.GitCommand, oSCommand *comm
}, nil
}

type platform struct {
os string
shell string
shellArg string
escapedQuote string
}

func getPlatform() platform {
switch runtime.GOOS {
case "windows":
return platform{
os: "windows",
shell: "cmd",
shellArg: "/c",
escapedQuote: "\\\"",
}
default:
return platform{
os: runtime.GOOS,
shell: "bash",
shellArg: "-c",
escapedQuote: "\"",
}
}
}

func (gui *Gui) scrollUpMain(g *gocui.Gui, v *gocui.View) error {
mainView, _ := g.View("main")
ox, oy := mainView.Origin()
Expand Down

0 comments on commit ad3d332

Please sign in to comment.