1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-04-23 12:18:51 +02:00

Merge branch 'master' into add-overrideGpg-switch

Signed-off-by: Randshot <randshot@norealm.xyz>
This commit is contained in:
Randshot 2020-07-12 11:47:35 +02:00
commit 570d27ffaa
No known key found for this signature in database
GPG Key ID: 47E0D72B4F839031
6 changed files with 29 additions and 14 deletions

View File

@ -1,6 +1,6 @@
# run with: # run with:
# docker build -t lazygit . # 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 FROM golang:1.14-alpine3.11
WORKDIR /go/src/github.com/jesseduffield/lazygit/ 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 /go/src/github.com/jesseduffield/lazygit
COPY --from=0 /go/src/github.com/jesseduffield/lazygit/lazygit /bin/ COPY --from=0 /go/src/github.com/jesseduffield/lazygit/lazygit /bin/
RUN echo "alias gg=lazygit" >> ~/.profile RUN echo "alias gg=lazygit" >> ~/.profile
ENTRYPOINT [ "lazygit" ]

View File

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

View File

@ -19,6 +19,11 @@ func NewDummyOSCommand() *OSCommand {
// NewDummyAppConfig creates a new dummy AppConfig for testing // NewDummyAppConfig creates a new dummy AppConfig for testing
func NewDummyAppConfig() *config.AppConfig { func NewDummyAppConfig() *config.AppConfig {
userConfig := viper.New()
userConfig.SetConfigType("yaml")
if err := config.LoadDefaults(userConfig, config.GetDefaultConfig()); err != nil {
panic(err)
}
appConfig := &config.AppConfig{ appConfig := &config.AppConfig{
Name: "lazygit", Name: "lazygit",
Version: "unversioned", Version: "unversioned",
@ -26,7 +31,7 @@ func NewDummyAppConfig() *config.AppConfig {
BuildDate: "", BuildDate: "",
Debug: false, Debug: false,
BuildSource: "", BuildSource: "",
UserConfig: viper.New(), UserConfig: userConfig,
} }
_ = yaml.Unmarshal([]byte{}, appConfig.AppState) _ = yaml.Unmarshal([]byte{}, appConfig.AppState)
return appConfig return appConfig

View File

@ -453,7 +453,7 @@ func (c *GitCommand) usingGpg() bool {
func (c *GitCommand) Commit(message string, flags string) (*exec.Cmd, error) { func (c *GitCommand) Commit(message string, flags string) (*exec.Cmd, error) {
command := fmt.Sprintf("git commit %s -m %s", flags, c.OSCommand.Quote(message)) command := fmt.Sprintf("git commit %s -m %s", flags, c.OSCommand.Quote(message))
if c.usingGpg() { 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) return nil, c.OSCommand.RunCommand(command)
@ -470,7 +470,7 @@ func (c *GitCommand) GetHeadCommitMessage() (string, error) {
func (c *GitCommand) AmendHead() (*exec.Cmd, error) { func (c *GitCommand) AmendHead() (*exec.Cmd, error) {
command := "git commit --amend --no-edit --allow-empty" command := "git commit --amend --no-edit --allow-empty"
if c.usingGpg() { 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) 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 { 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 // GetRemoteURL returns current repo remote url

View File

@ -815,7 +815,7 @@ func TestGitCommandCommit(t *testing.T) {
"Commit using gpg", "Commit using gpg",
func(cmd string, args ...string) *exec.Cmd { func(cmd string, args ...string) *exec.Cmd {
assert.EqualValues(t, "bash", 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") return exec.Command("echo")
}, },
@ -905,7 +905,7 @@ func TestGitCommandAmendHead(t *testing.T) {
"Amend commit using gpg", "Amend commit using gpg",
func(cmd string, args ...string) *exec.Cmd { func(cmd string, args ...string) *exec.Cmd {
assert.EqualValues(t, "bash", 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") return exec.Command("echo")
}, },
@ -1387,10 +1387,8 @@ func TestGitCommandGetBranchGraph(t *testing.T) {
gitCmd.OSCommand.command = func(cmd string, args ...string) *exec.Cmd { gitCmd.OSCommand.command = func(cmd string, args ...string) *exec.Cmd {
assert.EqualValues(t, "git", cmd) assert.EqualValues(t, "git", cmd)
assert.EqualValues(t, []string{"log", "--graph", "--color=always", "--abbrev-commit", "--decorate", "--date=relative", "--pretty=medium", "test", "--"}, args) assert.EqualValues(t, []string{"log", "--graph", "--color=always", "--abbrev-commit", "--decorate", "--date=relative", "--pretty=medium", "test", "--"}, args)
return exec.Command("echo") return exec.Command("echo")
} }
_, err := gitCmd.GetBranchGraph("test") _, err := gitCmd.GetBranchGraph("test")
assert.NoError(t, err) assert.NoError(t, err)
} }
@ -1410,7 +1408,7 @@ func TestGitCommandDiff(t *testing.T) {
"Default case", "Default case",
func(cmd string, args ...string) *exec.Cmd { func(cmd string, args ...string) *exec.Cmd {
assert.EqualValues(t, "git", 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") return exec.Command("echo")
}, },
@ -1426,7 +1424,7 @@ func TestGitCommandDiff(t *testing.T) {
"cached", "cached",
func(cmd string, args ...string) *exec.Cmd { func(cmd string, args ...string) *exec.Cmd {
assert.EqualValues(t, "git", 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") return exec.Command("echo")
}, },
@ -1458,7 +1456,7 @@ func TestGitCommandDiff(t *testing.T) {
"File not tracked and file has no staged changes", "File not tracked and file has no staged changes",
func(cmd string, args ...string) *exec.Cmd { func(cmd string, args ...string) *exec.Cmd {
assert.EqualValues(t, "git", 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") return exec.Command("echo")
}, },

View File

@ -270,6 +270,7 @@ git:
args: "" args: ""
skipHookPrefix: 'WIP' skipHookPrefix: 'WIP'
autoFetch: true 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 overrideGpg: false # prevents lazygit from spawning a separate process when using GPG
update: update:
method: prompt # can be: prompt | background | never method: prompt # can be: prompt | background | never