Skip to content

Commit

Permalink
Merge branch 'master' into add-overrideGpg-switch
Browse files Browse the repository at this point in the history
Signed-off-by: Randshot <randshot@norealm.xyz>
  • Loading branch information
no-realm committed Jul 12, 2020
2 parents 65e955c + 7b69aa1 commit 570d27f
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 14 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# run with:
# docker build -t lazygit .
# docker run -it lazygit:latest /bin/sh -l
# docker run -it lazygit:latest /bin/sh

FROM golang:1.14-alpine3.11
WORKDIR /go/src/github.com/jesseduffield/lazygit/
Expand All @@ -13,3 +13,5 @@ WORKDIR /go/src/github.com/jesseduffield/lazygit/
COPY --from=0 /go/src/github.com/jesseduffield/lazygit /go/src/github.com/jesseduffield/lazygit
COPY --from=0 /go/src/github.com/jesseduffield/lazygit/lazygit /bin/
RUN echo "alias gg=lazygit" >> ~/.profile

ENTRYPOINT [ "lazygit" ]
9 changes: 7 additions & 2 deletions docs/Config.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Default path for the config file:
args: ""
skipHookPrefix: WIP
autoFetch: true
branchLogCmd: "git log --graph --color=always --abbrev-commit --decorate --date=relative --pretty=medium {{branchName}} --"
update:
method: prompt # can be: prompt | background | never
days: 14 # how often an update is checked for
Expand Down Expand Up @@ -95,7 +96,7 @@ Default path for the config file:
prevScreenMode: '_'
undo: 'z'
redo: '<c-z>'
filteringMenu: <c-s>
filteringMenu: '<c-s>'
diffingMenu: '<c-e>'
copyToClipboard: '<c-o>'
status:
Expand Down Expand Up @@ -260,14 +261,18 @@ For all possible keybinding options, check [Custom_Keybindings.md](https://githu
scrollDownMain-alt1: 'E'
scrollUpMain-alt2: '<c-u>'
scrollDownMain-alt2: '<c-e>'
undo: 'l'
redo: '<c-r>'
diffingMenu: 'M'
filteringMenu: '<c-f>'
files:
ignoreFile: 'I'
commits:
moveDownCommit: '<c-e>'
moveUpCommit: '<c-u>'
toggleDiffCommit: 'l'
branches:
viewGitFlowOptions: 'I'
setUpstream: 'U'
```

## Custom pull request URLs
Expand Down
7 changes: 6 additions & 1 deletion pkg/commands/dummies.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,19 @@ func NewDummyOSCommand() *OSCommand {

// NewDummyAppConfig creates a new dummy AppConfig for testing
func NewDummyAppConfig() *config.AppConfig {
userConfig := viper.New()
userConfig.SetConfigType("yaml")
if err := config.LoadDefaults(userConfig, config.GetDefaultConfig()); err != nil {
panic(err)
}
appConfig := &config.AppConfig{
Name: "lazygit",
Version: "unversioned",
Commit: "",
BuildDate: "",
Debug: false,
BuildSource: "",
UserConfig: viper.New(),
UserConfig: userConfig,
}
_ = yaml.Unmarshal([]byte{}, appConfig.AppState)
return appConfig
Expand Down
10 changes: 7 additions & 3 deletions pkg/commands/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ func (c *GitCommand) usingGpg() bool {
func (c *GitCommand) Commit(message string, flags string) (*exec.Cmd, error) {
command := fmt.Sprintf("git commit %s -m %s", flags, c.OSCommand.Quote(message))
if c.usingGpg() {
return c.OSCommand.PrepareSubProcess(c.OSCommand.Platform.shell, c.OSCommand.Platform.shellArg, command), nil
return c.OSCommand.ExecutableFromString(fmt.Sprintf("%s %s %s", c.OSCommand.Platform.shell, c.OSCommand.Platform.shellArg, command)), nil
}

return nil, c.OSCommand.RunCommand(command)
Expand All @@ -470,7 +470,7 @@ func (c *GitCommand) GetHeadCommitMessage() (string, error) {
func (c *GitCommand) AmendHead() (*exec.Cmd, error) {
command := "git commit --amend --no-edit --allow-empty"
if c.usingGpg() {
return c.OSCommand.PrepareSubProcess(c.OSCommand.Platform.shell, c.OSCommand.Platform.shellArg, command), nil
return c.OSCommand.ExecutableFromString(fmt.Sprintf("%s %s %s", c.OSCommand.Platform.shell, c.OSCommand.Platform.shellArg, command)), nil
}

return nil, c.OSCommand.RunCommand(command)
Expand Down Expand Up @@ -640,7 +640,11 @@ func (c *GitCommand) ShowCmdStr(sha string, filterPath string) string {
}

func (c *GitCommand) GetBranchGraphCmdStr(branchName string) string {
return fmt.Sprintf("git log --graph --color=always --abbrev-commit --decorate --date=relative --pretty=medium %s --", branchName)
branchLogCmdTemplate := c.Config.GetUserConfig().GetString("git.branchLogCmd")
templateValues := map[string]string{
"branchName": branchName,
}
return utils.ResolvePlaceholderString(branchLogCmdTemplate, templateValues)
}

// GetRemoteURL returns current repo remote url
Expand Down
12 changes: 5 additions & 7 deletions pkg/commands/git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ func TestGitCommandCommit(t *testing.T) {
"Commit using gpg",
func(cmd string, args ...string) *exec.Cmd {
assert.EqualValues(t, "bash", cmd)
assert.EqualValues(t, []string{"-c", `git commit -m 'test'`}, args)
assert.EqualValues(t, []string{"-c", "git", "commit", "-m", "test"}, args)

return exec.Command("echo")
},
Expand Down Expand Up @@ -905,7 +905,7 @@ func TestGitCommandAmendHead(t *testing.T) {
"Amend commit using gpg",
func(cmd string, args ...string) *exec.Cmd {
assert.EqualValues(t, "bash", cmd)
assert.EqualValues(t, []string{"-c", "git commit --amend --no-edit --allow-empty"}, args)
assert.EqualValues(t, []string{"-c", "git", "commit", "--amend", "--no-edit", "--allow-empty"}, args)

return exec.Command("echo")
},
Expand Down Expand Up @@ -1387,10 +1387,8 @@ func TestGitCommandGetBranchGraph(t *testing.T) {
gitCmd.OSCommand.command = func(cmd string, args ...string) *exec.Cmd {
assert.EqualValues(t, "git", cmd)
assert.EqualValues(t, []string{"log", "--graph", "--color=always", "--abbrev-commit", "--decorate", "--date=relative", "--pretty=medium", "test", "--"}, args)

return exec.Command("echo")
}

_, err := gitCmd.GetBranchGraph("test")
assert.NoError(t, err)
}
Expand All @@ -1410,7 +1408,7 @@ func TestGitCommandDiff(t *testing.T) {
"Default case",
func(cmd string, args ...string) *exec.Cmd {
assert.EqualValues(t, "git", cmd)
assert.EqualValues(t, []string{"diff", "--color=", "--", "test.txt"}, args)
assert.EqualValues(t, []string{"diff", "--color=always", "--", "test.txt"}, args)

return exec.Command("echo")
},
Expand All @@ -1426,7 +1424,7 @@ func TestGitCommandDiff(t *testing.T) {
"cached",
func(cmd string, args ...string) *exec.Cmd {
assert.EqualValues(t, "git", cmd)
assert.EqualValues(t, []string{"diff", "--color=", "--cached", "--", "test.txt"}, args)
assert.EqualValues(t, []string{"diff", "--color=always", "--cached", "--", "test.txt"}, args)

return exec.Command("echo")
},
Expand Down Expand Up @@ -1458,7 +1456,7 @@ func TestGitCommandDiff(t *testing.T) {
"File not tracked and file has no staged changes",
func(cmd string, args ...string) *exec.Cmd {
assert.EqualValues(t, "git", cmd)
assert.EqualValues(t, []string{"diff", "--color=", "--no-index", "/dev/null", "test.txt"}, args)
assert.EqualValues(t, []string{"diff", "--color=always", "--no-index", "/dev/null", "test.txt"}, args)

return exec.Command("echo")
},
Expand Down
1 change: 1 addition & 0 deletions pkg/config/app_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ git:
args: ""
skipHookPrefix: 'WIP'
autoFetch: true
branchLogCmd: "git log --graph --color=always --abbrev-commit --decorate --date=relative --pretty=medium {{branchName}} --"
overrideGpg: false # prevents lazygit from spawning a separate process when using GPG
update:
method: prompt # can be: prompt | background | never
Expand Down

0 comments on commit 570d27f

Please sign in to comment.