diff options
author | Randshot <randshot@norealm.xyz> | 2020-07-12 11:47:35 +0200 |
---|---|---|
committer | Randshot <randshot@norealm.xyz> | 2020-07-12 11:47:35 +0200 |
commit | 570d27ffaa1282e95748a83de08984baa30707e1 (patch) | |
tree | 09fe7b8e01bf02f12ede650e40afd77df67a95b9 | |
parent | 65e955c622937ab64b9a7e447afc1180a2a95b9d (diff) | |
parent | 7b69aa1fdaa7b1719cee8d9a07df11940c5c6cd0 (diff) |
Merge branch 'master' into add-overrideGpg-switch
Signed-off-by: Randshot <randshot@norealm.xyz>
-rw-r--r-- | Dockerfile | 4 | ||||
-rw-r--r-- | docs/Config.md | 9 | ||||
-rw-r--r-- | pkg/commands/dummies.go | 7 | ||||
-rw-r--r-- | pkg/commands/git.go | 10 | ||||
-rw-r--r-- | pkg/commands/git_test.go | 12 | ||||
-rw-r--r-- | pkg/config/app_config.go | 1 |
6 files changed, 29 insertions, 14 deletions
diff --git a/Dockerfile b/Dockerfile index 10ed10b2c..aec4ff2a0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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/ @@ -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" ] diff --git a/docs/Config.md b/docs/Config.md index 3b3350ec0..78f504e2c 100644 --- a/docs/Config.md +++ b/docs/Config.md @@ -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 @@ -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: @@ -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 diff --git a/pkg/commands/dummies.go b/pkg/commands/dummies.go index 34bf549d3..57bf1bed9 100644 --- a/pkg/commands/dummies.go +++ b/pkg/commands/dummies.go @@ -19,6 +19,11 @@ 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", @@ -26,7 +31,7 @@ func NewDummyAppConfig() *config.AppConfig { BuildDate: "", Debug: false, BuildSource: "", - UserConfig: viper.New(), + UserConfig: userConfig, } _ = yaml.Unmarshal([]byte{}, appConfig.AppState) return appConfig diff --git a/pkg/commands/git.go b/pkg/commands/git.go index 61daa06d9..fd7d9e9b1 100644 --- a/pkg/commands/git.go +++ b/pkg/commands/git.go @@ -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) @@ -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) @@ -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 diff --git a/pkg/commands/git_test.go b/pkg/commands/git_test.go index b70947534..ed1fed013 100644 --- a/pkg/commands/git_test.go +++ b/pkg/commands/git_test.go @@ -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") }, @@ -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") }, @@ -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) } @@ -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") }, @@ -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") }, @@ -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") }, diff --git a/pkg/config/app_config.go b/pkg/config/app_config.go index f3c5a7690..0d1bad23d 100644 --- a/pkg/config/app_config.go +++ b/pkg/config/app_config.go @@ -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 |