diff --git a/.github/workflows/uffizzi-build.yml b/.github/workflows/uffizzi-build.yml
new file mode 100644
index 000000000..58c7e5866
--- /dev/null
+++ b/.github/workflows/uffizzi-build.yml
@@ -0,0 +1,89 @@
+name: Build PR Image
+on:
+ pull_request:
+ types: [opened, synchronize, reopened, closed]
+
+jobs:
+ build-application:
+ name: Build and Push `lazygit`
+ runs-on: ubuntu-latest
+ if: ${{ github.event_name != 'pull_request' || github.event.action != 'closed' }}
+ outputs:
+ tags: ${{ steps.meta.outputs.tags }}
+ steps:
+ - name: Checkout git repo
+ uses: actions/checkout@v3
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v2
+ - name: Generate UUID image name
+ id: uuid
+ run: echo "UUID_APP_TAG=$(uuidgen)" >> $GITHUB_ENV
+ - name: Docker metadata
+ id: meta
+ uses: docker/metadata-action@v3
+ with:
+ images: registry.uffizzi.com/${{ env.UUID_APP_TAG }}
+ tags: type=raw,value=60d
+ - name: Build and Push Image to registry.uffizzi.com ephemeral registry
+ uses: docker/build-push-action@v2
+ with:
+ push: true
+ context: ./
+ tags: ${{ steps.meta.outputs.tags }}
+ labels: ${{ steps.meta.outputs.labels }}
+ file: ./uffizzi/DockerfileTtyd
+ cache-from: type=gha
+ cache-to: type=gha,mode=max
+
+
+ render-compose-file:
+ name: Render Docker Compose File
+ # Pass output of this workflow to another triggered by `workflow_run` event.
+ runs-on: ubuntu-latest
+ needs:
+ - build-application
+ outputs:
+ compose-file-cache-key: ${{ steps.hash.outputs.hash }}
+ steps:
+ - name: Checkout git repo
+ uses: actions/checkout@v3
+ - name: Render Compose File
+ run: |
+ APP_IMAGE=$(echo ${{ needs.build-application.outputs.tags }})
+ export APP_IMAGE
+ # Render simple template from environment variables.
+ envsubst < ./uffizzi/docker-compose.uffizzi.yml > docker-compose.rendered.yml
+ cat docker-compose.rendered.yml
+ - name: Upload Rendered Compose File as Artifact
+ uses: actions/upload-artifact@v3
+ with:
+ name: preview-spec
+ path: docker-compose.rendered.yml
+ retention-days: 2
+ - name: Serialize PR Event to File
+ run: |
+ cat << EOF > event.json
+ ${{ toJSON(github.event) }}
+
+ EOF
+ - name: Upload PR Event as Artifact
+ uses: actions/upload-artifact@v3
+ with:
+ name: preview-spec
+ path: event.json
+ retention-days: 2
+
+ delete-preview:
+ name: Call for Preview Deletion
+ runs-on: ubuntu-latest
+ if: ${{ github.event.action == 'closed' }}
+ steps:
+ # If this PR is closing, we will not render a compose file nor pass it to the next workflow.
+ - name: Serialize PR Event to File
+ run: echo '${{ toJSON(github.event) }}' > event.json
+ - name: Upload PR Event as Artifact
+ uses: actions/upload-artifact@v3
+ with:
+ name: preview-spec
+ path: event.json
+ retention-days: 2
diff --git a/.github/workflows/uffizzi-preview.yml b/.github/workflows/uffizzi-preview.yml
new file mode 100644
index 000000000..ce8a9c46f
--- /dev/null
+++ b/.github/workflows/uffizzi-preview.yml
@@ -0,0 +1,84 @@
+name: Deploy Uffizzi Preview
+
+on:
+ workflow_run:
+ workflows:
+ - "Build PR Image"
+ types:
+ - completed
+
+
+jobs:
+ cache-compose-file:
+ name: Cache Compose File
+ runs-on: ubuntu-latest
+ outputs:
+ compose-file-cache-key: ${{ env.COMPOSE_FILE_HASH }}
+ pr-number: ${{ env.PR_NUMBER }}
+ steps:
+ - name: 'Download artifacts'
+ # Fetch output (zip archive) from the workflow run that triggered this workflow.
+ uses: actions/github-script@v6
+ with:
+ script: |
+ let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ run_id: context.payload.workflow_run.id,
+ });
+ let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
+ return artifact.name == "preview-spec"
+ })[0];
+ let download = await github.rest.actions.downloadArtifact({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ artifact_id: matchArtifact.id,
+ archive_format: 'zip',
+ });
+ let fs = require('fs');
+ fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/preview-spec.zip`, Buffer.from(download.data));
+ - name: 'Unzip artifact'
+ run: unzip preview-spec.zip
+ - name: Read Event into ENV
+ run: |
+ echo 'EVENT_JSON<> $GITHUB_ENV
+ cat event.json >> $GITHUB_ENV
+ echo 'EOF' >> $GITHUB_ENV
+ - name: Hash Rendered Compose File
+ id: hash
+ # If the previous workflow was triggered by a PR close event, we will not have a compose file artifact.
+ if: ${{ fromJSON(env.EVENT_JSON).action != 'closed' }}
+ run: echo "COMPOSE_FILE_HASH=$(md5sum docker-compose.rendered.yml | awk '{ print $1 }')" >> $GITHUB_ENV
+ - name: Cache Rendered Compose File
+ if: ${{ fromJSON(env.EVENT_JSON).action != 'closed' }}
+ uses: actions/cache@v3
+ with:
+ path: docker-compose.rendered.yml
+ key: ${{ env.COMPOSE_FILE_HASH }}
+
+ - name: Read PR Number From Event Object
+ id: pr
+ run: echo "PR_NUMBER=${{ fromJSON(env.EVENT_JSON).number }}" >> $GITHUB_ENV
+
+ - name: DEBUG - Print Job Outputs
+ if: ${{ runner.debug }}
+ run: |
+ echo "PR number: ${{ env.PR_NUMBER }}"
+ echo "Compose file hash: ${{ env.COMPOSE_FILE_HASH }}"
+ cat event.json
+ deploy-uffizzi-preview:
+ name: Use Remote Workflow to Preview on Uffizzi
+ needs:
+ - cache-compose-file
+ uses: UffizziCloud/preview-action/.github/workflows/reusable.yaml@v2.6.1
+ with:
+ # If this workflow was triggered by a PR close event, cache-key will be an empty string
+ # and this reusable workflow will delete the preview deployment.
+ compose-file-cache-key: ${{ needs.cache-compose-file.outputs.compose-file-cache-key }}
+ compose-file-cache-path: docker-compose.rendered.yml
+ server: https://app.uffizzi.com
+ pr-number: ${{ needs.cache-compose-file.outputs.pr-number }}
+ permissions:
+ contents: read
+ pull-requests: write
+ id-token: write
\ No newline at end of file
diff --git a/README.md b/README.md
index 2dbfdbaed..cdb06fbad 100644
--- a/README.md
+++ b/README.md
@@ -22,7 +22,7 @@ A simple terminal UI for git commands, written in Go with the [gocui](https://gi
-



























































+




























































## Elevator Pitch
@@ -150,15 +150,10 @@ sudo eopkg install lazygit
### Ubuntu
```sh
-LAZYGIT_VERSION=$(curl -s "https://api.github.com/repos/jesseduffield/lazygit/releases/latest" | grep '"tag_name":' | sed -E 's/.*"v*([^"]+)".*/\1/')
-```
-
-```sh
+LAZYGIT_VERSION=$(curl -s "https://api.github.com/repos/jesseduffield/lazygit/releases/latest" | grep -Po '"tag_name": "v\K[^"]*')
curl -Lo lazygit.tar.gz "https://github.com/jesseduffield/lazygit/releases/latest/download/lazygit_${LAZYGIT_VERSION}_Linux_x86_64.tar.gz"
-```
-
-```sh
-sudo tar xf lazygit.tar.gz -C /usr/local/bin lazygit
+tar xf lazygit.tar.gz lazygit
+sudo install lazygit /usr/local/bin
```
Verify the correct installation of lazygit:
diff --git a/docs/Config.md b/docs/Config.md
index 4bcac2064..6a9be62e9 100644
--- a/docs/Config.md
+++ b/docs/Config.md
@@ -62,20 +62,21 @@ gui:
showIcons: false
commandLogSize: 8
splitDiff: 'auto' # one of 'auto' | 'always'
+ skipRewordInEditorWarning: false # for skipping the confirmation before launching the reword editor
git:
paging:
colorArg: always
useConfig: false
commit:
signOff: false
- verbose: false
+ verbose: default # one of 'default' | 'always' | 'never'
merging:
# only applicable to unix users
manualCommit: false
# extra args passed to `git merge`, e.g. --no-ff
args: ''
log:
- # one of date-order, author-date-order, topo-order.
+ # one of date-order, author-date-order, topo-order or default.
# topo-order makes it easier to read the git log graph, but commits may not
# appear chronologically. See https://git-scm.com/docs/git-log#_commit_ordering
order: 'topo-order'
@@ -190,6 +191,8 @@ keybinding:
viewResetOptions: 'D'
fetch: 'f'
toggleTreeView: '`'
+ openMergeTool: 'M'
+ openStatusFilter: ''
branches:
createPullRequest: 'o'
viewPullRequestOptions: 'O'
diff --git a/pkg/commands/git_commands/branch.go b/pkg/commands/git_commands/branch.go
index 117427778..a71e365ea 100644
--- a/pkg/commands/git_commands/branch.go
+++ b/pkg/commands/git_commands/branch.go
@@ -2,19 +2,12 @@ package git_commands
import (
"fmt"
- "regexp"
"strings"
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
"github.com/jesseduffield/lazygit/pkg/utils"
)
-// this takes something like:
-// * (HEAD detached at 264fc6f5)
-// remotes
-// and returns '264fc6f5' as the second match
-const CurrentBranchNameRegex = `(?m)^\*.*?([^ ]*?)\)?$`
-
type BranchCommands struct {
*GitCommon
}
@@ -41,19 +34,18 @@ func (self *BranchCommands) CurrentBranchInfo() (BranchInfo, error) {
DetachedHead: false,
}, nil
}
- output, err := self.cmd.New("git branch --contains").DontLog().RunWithOutput()
+ output, err := self.cmd.New(`git branch --points-at=HEAD --format="%(HEAD)%00%(objectname)%00%(refname)"`).DontLog().RunWithOutput()
if err != nil {
return BranchInfo{}, err
}
for _, line := range utils.SplitLines(output) {
- re := regexp.MustCompile(CurrentBranchNameRegex)
- match := re.FindStringSubmatch(line)
- if len(match) > 0 {
- branchName = match[1]
- displayBranchName := match[0][2:]
+ split := strings.Split(strings.TrimRight(line, "\r\n"), "\x00")
+ if len(split) == 3 && split[0] == "*" {
+ sha := split[1]
+ displayName := split[2]
return BranchInfo{
- RefName: branchName,
- DisplayName: displayBranchName,
+ RefName: sha,
+ DisplayName: displayName,
DetachedHead: true,
}, nil
}
diff --git a/pkg/commands/git_commands/branch_test.go b/pkg/commands/git_commands/branch_test.go
index 94456c0f8..2fdf7d9c2 100644
--- a/pkg/commands/git_commands/branch_test.go
+++ b/pkg/commands/git_commands/branch_test.go
@@ -181,26 +181,30 @@ func TestBranchCurrentBranchInfo(t *testing.T) {
},
},
{
- "falls back to git `git branch --contains` if symbolic-ref fails",
+ "falls back to git `git branch --points-at=HEAD` if symbolic-ref fails",
oscommands.NewFakeRunner(t).
Expect(`git symbolic-ref --short HEAD`, "", errors.New("error")).
- Expect(`git branch --contains`, "* (HEAD detached at 8982166a)", nil),
+ Expect(`git branch --points-at=HEAD --format="%(HEAD)%00%(objectname)%00%(refname)"`, "*\x006f71c57a8d4bd6c11399c3f55f42c815527a73a4\x00(HEAD detached at 6f71c57a)\n", nil),
func(info BranchInfo, err error) {
assert.NoError(t, err)
- assert.EqualValues(t, "8982166a", info.RefName)
- assert.EqualValues(t, "(HEAD detached at 8982166a)", info.DisplayName)
+ assert.EqualValues(t, "6f71c57a8d4bd6c11399c3f55f42c815527a73a4", info.RefName)
+ assert.EqualValues(t, "(HEAD detached at 6f71c57a)", info.DisplayName)
assert.True(t, info.DetachedHead)
},
},
{
- "handles a detached head",
+ "handles a detached head (LANG=zh_CN.UTF-8)",
oscommands.NewFakeRunner(t).
Expect(`git symbolic-ref --short HEAD`, "", errors.New("error")).
- Expect(`git branch --contains`, "* (HEAD detached at 123abcd)", nil),
+ Expect(
+ `git branch --points-at=HEAD --format="%(HEAD)%00%(objectname)%00%(refname)"`,
+ "*\x00679b0456f3db7c505b398def84e7d023e5b55a8d\x00(头指针在 679b0456 分离)\n"+
+ " \x00679b0456f3db7c505b398def84e7d023e5b55a8d\x00refs/heads/master\n",
+ nil),
func(info BranchInfo, err error) {
assert.NoError(t, err)
- assert.EqualValues(t, "123abcd", info.RefName)
- assert.EqualValues(t, "(HEAD detached at 123abcd)", info.DisplayName)
+ assert.EqualValues(t, "679b0456f3db7c505b398def84e7d023e5b55a8d", info.RefName)
+ assert.EqualValues(t, "(头指针在 679b0456 分离)", info.DisplayName)
assert.True(t, info.DetachedHead)
},
},
@@ -208,7 +212,7 @@ func TestBranchCurrentBranchInfo(t *testing.T) {
"bubbles up error if there is one",
oscommands.NewFakeRunner(t).
Expect(`git symbolic-ref --short HEAD`, "", errors.New("error")).
- Expect(`git branch --contains`, "", errors.New("error")),
+ Expect(`git branch --points-at=HEAD --format="%(HEAD)%00%(objectname)%00%(refname)"`, "", errors.New("error")),
func(info BranchInfo, err error) {
assert.Error(t, err)
assert.EqualValues(t, "", info.RefName)
diff --git a/pkg/commands/git_commands/commit.go b/pkg/commands/git_commands/commit.go
index be06cb245..b5293a2ff 100644
--- a/pkg/commands/git_commands/commit.go
+++ b/pkg/commands/git_commands/commit.go
@@ -74,9 +74,12 @@ func (self *CommitCommands) signoffFlag() string {
}
func (self *CommitCommands) verboseFlag() string {
- if self.UserConfig.Git.Commit.Verbose {
+ switch self.config.UserConfig.Git.Commit.Verbose {
+ case "always":
return " --verbose"
- } else {
+ case "never":
+ return " --no-verbose"
+ default:
return ""
}
}
diff --git a/pkg/commands/git_commands/commit_loader.go b/pkg/commands/git_commands/commit_loader.go
index f89f62c48..00e2f80ad 100644
--- a/pkg/commands/git_commands/commit_loader.go
+++ b/pkg/commands/git_commands/commit_loader.go
@@ -426,7 +426,10 @@ func (self *CommitLoader) getLogCmd(opts GetCommitsOptions) oscommands.ICmdObj {
config := self.UserConfig.Git.Log
- orderFlag := "--" + config.Order
+ orderFlag := ""
+ if config.Order != "default" {
+ orderFlag = " --" + config.Order
+ }
allFlag := ""
if opts.All {
allFlag = " --all"
@@ -434,7 +437,7 @@ func (self *CommitLoader) getLogCmd(opts GetCommitsOptions) oscommands.ICmdObj {
return self.cmd.New(
fmt.Sprintf(
- "git -c log.showSignature=false log %s %s %s --oneline %s%s --abbrev=%d%s",
+ "git -c log.showSignature=false log %s%s%s --oneline %s%s --abbrev=%d%s",
self.cmd.Quote(opts.RefName),
orderFlag,
allFlag,
@@ -446,14 +449,4 @@ func (self *CommitLoader) getLogCmd(opts GetCommitsOptions) oscommands.ICmdObj {
).DontLog()
}
-var prettyFormat = fmt.Sprintf(
- "--pretty=format:\"%%H%s%%at%s%%aN%s%%ae%s%%d%s%%p%s%%s\"",
- NULL_CODE,
- NULL_CODE,
- NULL_CODE,
- NULL_CODE,
- NULL_CODE,
- NULL_CODE,
-)
-
-const NULL_CODE = "%x00"
+const prettyFormat = `--pretty=format:"%H%x00%at%x00%aN%x00%ae%x00%d%x00%p%x00%s"`
diff --git a/pkg/commands/git_commands/commit_loader_test.go b/pkg/commands/git_commands/commit_loader_test.go
index ab6d5a105..aa20ae802 100644
--- a/pkg/commands/git_commands/commit_loader_test.go
+++ b/pkg/commands/git_commands/commit_loader_test.go
@@ -27,6 +27,7 @@ func TestGetCommits(t *testing.T) {
runner *oscommands.FakeCmdObjRunner
expectedCommits []*models.Commit
expectedError error
+ logOrder string
rebaseMode enums.RebaseMode
currentBranchName string
opts GetCommitsOptions
@@ -35,18 +36,20 @@ func TestGetCommits(t *testing.T) {
scenarios := []scenario{
{
testName: "should return no commits if there are none",
+ logOrder: "topo-order",
rebaseMode: enums.REBASE_MODE_NONE,
currentBranchName: "master",
opts: GetCommitsOptions{RefName: "HEAD", IncludeRebaseCommits: false},
runner: oscommands.NewFakeRunner(t).
Expect(`git merge-base "HEAD" "HEAD"@{u}`, "b21997d6b4cbdf84b149d8e6a2c4d06a8e9ec164", nil).
- Expect(`git -c log.showSignature=false log "HEAD" --topo-order --oneline --pretty=format:"%H%x00%at%x00%aN%x00%ae%x00%d%x00%p%x00%s" --abbrev=40`, "", nil),
+ Expect(`git -c log.showSignature=false log "HEAD" --topo-order --oneline --pretty=format:"%H%x00%at%x00%aN%x00%ae%x00%d%x00%p%x00%s" --abbrev=40`, "", nil),
expectedCommits: []*models.Commit{},
expectedError: nil,
},
{
testName: "should return commits if they are present",
+ logOrder: "topo-order",
rebaseMode: enums.REBASE_MODE_NONE,
currentBranchName: "master",
opts: GetCommitsOptions{RefName: "HEAD", IncludeRebaseCommits: false},
@@ -54,7 +57,7 @@ func TestGetCommits(t *testing.T) {
// here it's seeing which commits are yet to be pushed
Expect(`git merge-base "HEAD" "HEAD"@{u}`, "b21997d6b4cbdf84b149d8e6a2c4d06a8e9ec164", nil).
// here it's actually getting all the commits in a formatted form, one per line
- Expect(`git -c log.showSignature=false log "HEAD" --topo-order --oneline --pretty=format:"%H%x00%at%x00%aN%x00%ae%x00%d%x00%p%x00%s" --abbrev=40`, commitsOutput, nil).
+ Expect(`git -c log.showSignature=false log "HEAD" --topo-order --oneline --pretty=format:"%H%x00%at%x00%aN%x00%ae%x00%d%x00%p%x00%s" --abbrev=40`, commitsOutput, nil).
// here it's seeing where our branch diverged from the master branch so that we can mark that commit and parent commits as 'merged'
Expect(`git merge-base "HEAD" "master"`, "26c07b1ab33860a1a7591a0638f9925ccf497ffa", nil),
@@ -174,13 +177,29 @@ func TestGetCommits(t *testing.T) {
},
expectedError: nil,
},
+ {
+ testName: "should not specify order if `log.order` is `default`",
+ logOrder: "default",
+ rebaseMode: enums.REBASE_MODE_NONE,
+ currentBranchName: "master",
+ opts: GetCommitsOptions{RefName: "HEAD", IncludeRebaseCommits: false},
+ runner: oscommands.NewFakeRunner(t).
+ Expect(`git merge-base "HEAD" "HEAD"@{u}`, "b21997d6b4cbdf84b149d8e6a2c4d06a8e9ec164", nil).
+ Expect(`git -c log.showSignature=false log "HEAD" --oneline --pretty=format:"%H%x00%at%x00%aN%x00%ae%x00%d%x00%p%x00%s" --abbrev=40`, "", nil),
+
+ expectedCommits: []*models.Commit{},
+ expectedError: nil,
+ },
}
for _, scenario := range scenarios {
scenario := scenario
t.Run(scenario.testName, func(t *testing.T) {
+ common := utils.NewDummyCommon()
+ common.UserConfig.Git.Log.Order = scenario.logOrder
+
builder := &CommitLoader{
- Common: utils.NewDummyCommon(),
+ Common: common,
cmd: oscommands.NewDummyCmdObjBuilder(scenario.runner),
getCurrentBranchInfo: func() (BranchInfo, error) {
return BranchInfo{RefName: scenario.currentBranchName, DisplayName: scenario.currentBranchName, DetachedHead: false}, nil
diff --git a/pkg/commands/git_commands/commit_test.go b/pkg/commands/git_commands/commit_test.go
index f44d350f9..1d6bc7f8f 100644
--- a/pkg/commands/git_commands/commit_test.go
+++ b/pkg/commands/git_commands/commit_test.go
@@ -27,12 +27,11 @@ func TestCommitResetToCommit(t *testing.T) {
runner.CheckForMissingCalls()
}
-func TestCommitCommitObj(t *testing.T) {
+func TestCommitCommitCmdObj(t *testing.T) {
type scenario struct {
testName string
message string
configSignoff bool
- configVerbose bool
configSkipHookPrefix string
expected string
}
@@ -42,7 +41,6 @@ func TestCommitCommitObj(t *testing.T) {
testName: "Commit",
message: "test",
configSignoff: false,
- configVerbose: false,
configSkipHookPrefix: "",
expected: `git commit -m "test"`,
},
@@ -50,7 +48,6 @@ func TestCommitCommitObj(t *testing.T) {
testName: "Commit with --no-verify flag",
message: "WIP: test",
configSignoff: false,
- configVerbose: false,
configSkipHookPrefix: "WIP",
expected: `git commit --no-verify -m "WIP: test"`,
},
@@ -58,7 +55,6 @@ func TestCommitCommitObj(t *testing.T) {
testName: "Commit with multiline message",
message: "line1\nline2",
configSignoff: false,
- configVerbose: false,
configSkipHookPrefix: "",
expected: `git commit -m "line1" -m "line2"`,
},
@@ -66,23 +62,13 @@ func TestCommitCommitObj(t *testing.T) {
testName: "Commit with signoff",
message: "test",
configSignoff: true,
- configVerbose: false,
configSkipHookPrefix: "",
expected: `git commit --signoff -m "test"`,
},
- {
- testName: "Commit with message ignores verbose flag",
- message: "test",
- configSignoff: false,
- configVerbose: true,
- configSkipHookPrefix: "",
- expected: `git commit -m "test"`,
- },
{
testName: "Commit with signoff and no-verify",
message: "WIP: test",
configSignoff: true,
- configVerbose: false,
configSkipHookPrefix: "WIP",
expected: `git commit --no-verify --signoff -m "WIP: test"`,
},
@@ -93,7 +79,6 @@ func TestCommitCommitObj(t *testing.T) {
t.Run(s.testName, func(t *testing.T) {
userConfig := config.GetDefaultConfig()
userConfig.Git.Commit.SignOff = s.configSignoff
- userConfig.Git.Commit.Verbose = s.configVerbose
userConfig.Git.SkipHookPrefix = s.configSkipHookPrefix
instance := buildCommitCommands(commonDeps{userConfig: userConfig})
@@ -104,6 +89,62 @@ func TestCommitCommitObj(t *testing.T) {
}
}
+func TestCommitCommitEditorCmdObj(t *testing.T) {
+ type scenario struct {
+ testName string
+ configSignoff bool
+ configVerbose string
+ expected string
+ }
+
+ scenarios := []scenario{
+ {
+ testName: "Commit using editor",
+ configSignoff: false,
+ configVerbose: "default",
+ expected: `git commit`,
+ },
+ {
+ testName: "Commit with --no-verbose flag",
+ configSignoff: false,
+ configVerbose: "never",
+ expected: `git commit --no-verbose`,
+ },
+ {
+ testName: "Commit with --verbose flag",
+ configSignoff: false,
+ configVerbose: "always",
+ expected: `git commit --verbose`,
+ },
+ {
+ testName: "Commit with --signoff",
+ configSignoff: true,
+ configVerbose: "default",
+ expected: `git commit --signoff`,
+ },
+ {
+ testName: "Commit with --signoff and --no-verbose",
+ configSignoff: true,
+ configVerbose: "never",
+ expected: `git commit --signoff --no-verbose`,
+ },
+ }
+
+ for _, s := range scenarios {
+ s := s
+ t.Run(s.testName, func(t *testing.T) {
+ userConfig := config.GetDefaultConfig()
+ userConfig.Git.Commit.SignOff = s.configSignoff
+ userConfig.Git.Commit.Verbose = s.configVerbose
+
+ instance := buildCommitCommands(commonDeps{userConfig: userConfig})
+
+ cmdStr := instance.CommitEditorCmdObj().ToString()
+ assert.Equal(t, s.expected, cmdStr)
+ })
+ }
+}
+
func TestCommitCreateFixupCommit(t *testing.T) {
type scenario struct {
testName string
diff --git a/pkg/commands/patch/patch_parser.go b/pkg/commands/patch/patch_parser.go
index 90b2ea13e..1fd3c107a 100644
--- a/pkg/commands/patch/patch_parser.go
+++ b/pkg/commands/patch/patch_parser.go
@@ -202,10 +202,6 @@ func (p *PatchParser) Render(isFocused bool, firstLineIndex int, lastLineIndex i
return result
}
-func (p *PatchParser) RenderPlain() string {
- return renderLinesPlain(p.PatchLines)
-}
-
// RenderLinesPlain returns the non-coloured string of diff part from firstLineIndex to
// lastLineIndex
func (p *PatchParser) RenderLinesPlain(firstLineIndex, lastLineIndex int) string {
@@ -214,10 +210,10 @@ func (p *PatchParser) RenderLinesPlain(firstLineIndex, lastLineIndex int) string
func renderLinesPlain(lines []*PatchLine) string {
renderedLines := slices.Map(lines, func(line *PatchLine) string {
- return line.Content
+ return line.Content + "\n"
})
- return strings.Join(renderedLines, "\n")
+ return strings.Join(renderedLines, "")
}
// GetNextStageableLineIndex takes a line index and returns the line index of the next stageable line
diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go
index 4c5259fe1..5395cc256 100644
--- a/pkg/config/user_config.go
+++ b/pkg/config/user_config.go
@@ -27,30 +27,31 @@ type RefresherConfig struct {
}
type GuiConfig struct {
- AuthorColors map[string]string `yaml:"authorColors"`
- BranchColors map[string]string `yaml:"branchColors"`
- ScrollHeight int `yaml:"scrollHeight"`
- ScrollPastBottom bool `yaml:"scrollPastBottom"`
- MouseEvents bool `yaml:"mouseEvents"`
- SkipUnstageLineWarning bool `yaml:"skipUnstageLineWarning"`
- SkipStashWarning bool `yaml:"skipStashWarning"`
- SidePanelWidth float64 `yaml:"sidePanelWidth"`
- ExpandFocusedSidePanel bool `yaml:"expandFocusedSidePanel"`
- MainPanelSplitMode string `yaml:"mainPanelSplitMode"`
- Language string `yaml:"language"`
- TimeFormat string `yaml:"timeFormat"`
- Theme ThemeConfig `yaml:"theme"`
- CommitLength CommitLengthConfig `yaml:"commitLength"`
- SkipNoStagedFilesWarning bool `yaml:"skipNoStagedFilesWarning"`
- ShowListFooter bool `yaml:"showListFooter"`
- ShowFileTree bool `yaml:"showFileTree"`
- ShowRandomTip bool `yaml:"showRandomTip"`
- ShowCommandLog bool `yaml:"showCommandLog"`
- ShowBottomLine bool `yaml:"showBottomLine"`
- ShowIcons bool `yaml:"showIcons"`
- CommandLogSize int `yaml:"commandLogSize"`
- SplitDiff string `yaml:"splitDiff"`
- WindowSize string `yaml:"windowSize"`
+ AuthorColors map[string]string `yaml:"authorColors"`
+ BranchColors map[string]string `yaml:"branchColors"`
+ ScrollHeight int `yaml:"scrollHeight"`
+ ScrollPastBottom bool `yaml:"scrollPastBottom"`
+ MouseEvents bool `yaml:"mouseEvents"`
+ SkipUnstageLineWarning bool `yaml:"skipUnstageLineWarning"`
+ SkipStashWarning bool `yaml:"skipStashWarning"`
+ SidePanelWidth float64 `yaml:"sidePanelWidth"`
+ ExpandFocusedSidePanel bool `yaml:"expandFocusedSidePanel"`
+ MainPanelSplitMode string `yaml:"mainPanelSplitMode"`
+ Language string `yaml:"language"`
+ TimeFormat string `yaml:"timeFormat"`
+ Theme ThemeConfig `yaml:"theme"`
+ CommitLength CommitLengthConfig `yaml:"commitLength"`
+ SkipNoStagedFilesWarning bool `yaml:"skipNoStagedFilesWarning"`
+ ShowListFooter bool `yaml:"showListFooter"`
+ ShowFileTree bool `yaml:"showFileTree"`
+ ShowRandomTip bool `yaml:"showRandomTip"`
+ ShowCommandLog bool `yaml:"showCommandLog"`
+ ShowBottomLine bool `yaml:"showBottomLine"`
+ ShowIcons bool `yaml:"showIcons"`
+ CommandLogSize int `yaml:"commandLogSize"`
+ SplitDiff string `yaml:"splitDiff"`
+ SkipRewordInEditorWarning bool `yaml:"skipRewordInEditorWarning"`
+ WindowSize string `yaml:"windowSize"`
}
type ThemeConfig struct {
@@ -94,8 +95,8 @@ type PagingConfig struct {
}
type CommitConfig struct {
- SignOff bool `yaml:"signOff"`
- Verbose bool `yaml:"verbose"`
+ SignOff bool `yaml:"signOff"`
+ Verbose string `yaml:"verbose"`
}
type MergingConfig struct {
@@ -369,16 +370,17 @@ func GetDefaultConfig() *UserConfig {
UnstagedChangesColor: []string{"red"},
DefaultFgColor: []string{"default"},
},
- CommitLength: CommitLengthConfig{Show: true},
- SkipNoStagedFilesWarning: false,
- ShowListFooter: true,
- ShowCommandLog: true,
- ShowBottomLine: true,
- ShowFileTree: true,
- ShowRandomTip: true,
- ShowIcons: false,
- CommandLogSize: 8,
- SplitDiff: "auto",
+ CommitLength: CommitLengthConfig{Show: true},
+ SkipNoStagedFilesWarning: false,
+ ShowListFooter: true,
+ ShowCommandLog: true,
+ ShowBottomLine: true,
+ ShowFileTree: true,
+ ShowRandomTip: true,
+ ShowIcons: false,
+ CommandLogSize: 8,
+ SplitDiff: "auto",
+ SkipRewordInEditorWarning: false,
},
Git: GitConfig{
Paging: PagingConfig{
@@ -388,7 +390,7 @@ func GetDefaultConfig() *UserConfig {
},
Commit: CommitConfig{
SignOff: false,
- Verbose: false,
+ Verbose: "default",
},
Merging: MergingConfig{
ManualCommit: false,
diff --git a/pkg/gui/controllers/local_commits_controller.go b/pkg/gui/controllers/local_commits_controller.go
index 6539a13af..3a9aff86b 100644
--- a/pkg/gui/controllers/local_commits_controller.go
+++ b/pkg/gui/controllers/local_commits_controller.go
@@ -226,6 +226,26 @@ func (self *LocalCommitsController) reword(commit *models.Commit) error {
})
}
+func (self *LocalCommitsController) doRewordEditor() error {
+ self.c.LogAction(self.c.Tr.Actions.RewordCommit)
+
+ if self.context().GetSelectedLineIdx() == 0 {
+ return self.c.RunSubprocessAndRefresh(self.os.Cmd.New("git commit --allow-empty --amend --only"))
+ }
+
+ subProcess, err := self.git.Rebase.RewordCommitInEditor(
+ self.model.Commits, self.context().GetSelectedLineIdx(),
+ )
+ if err != nil {
+ return self.c.Error(err)
+ }
+ if subProcess != nil {
+ return self.c.RunSubprocessAndRefresh(subProcess)
+ }
+
+ return nil
+}
+
func (self *LocalCommitsController) rewordEditor(commit *models.Commit) error {
midRebase, err := self.handleMidRebaseCommand("reword", commit)
if err != nil {
@@ -235,29 +255,15 @@ func (self *LocalCommitsController) rewordEditor(commit *models.Commit) error {
return nil
}
- return self.c.Confirm(types.ConfirmOpts{
- Title: self.c.Tr.RewordInEditorTitle,
- Prompt: self.c.Tr.RewordInEditorPrompt,
- HandleConfirm: func() error {
- self.c.LogAction(self.c.Tr.Actions.RewordCommit)
-
- if self.context().GetSelectedLineIdx() == 0 {
- return self.c.RunSubprocessAndRefresh(self.os.Cmd.New("git commit --allow-empty --amend --only"))
- }
-
- subProcess, err := self.git.Rebase.RewordCommitInEditor(
- self.model.Commits, self.context().GetSelectedLineIdx(),
- )
- if err != nil {
- return self.c.Error(err)
- }
- if subProcess != nil {
- return self.c.RunSubprocessAndRefresh(subProcess)
- }
-
- return nil
- },
- })
+ if self.c.UserConfig.Gui.SkipRewordInEditorWarning {
+ return self.doRewordEditor()
+ } else {
+ return self.c.Confirm(types.ConfirmOpts{
+ Title: self.c.Tr.RewordInEditorTitle,
+ Prompt: self.c.Tr.RewordInEditorPrompt,
+ HandleConfirm: self.doRewordEditor,
+ })
+ }
}
func (self *LocalCommitsController) drop(commit *models.Commit) error {
diff --git a/pkg/i18n/chinese.go b/pkg/i18n/chinese.go
index 67cf264ce..e9d1ee475 100644
--- a/pkg/i18n/chinese.go
+++ b/pkg/i18n/chinese.go
@@ -73,8 +73,6 @@ func chineseTranslationSet() TranslationSet {
MergeConflictsTitle: "合并冲突",
LcCheckout: "检出",
NoChangedFiles: "没有更改过文件",
- NoFilesDisplay: "没有文件可显示",
- NotAFile: "不是文件",
PullWait: "正在拉取…",
PushWait: "正在推送…",
FetchWait: "正在抓取…",
@@ -104,7 +102,6 @@ func chineseTranslationSet() TranslationSet {
LcSquashDown: "向下压缩",
LcFixupCommit: "修正提交(fixup)",
NoCommitsThisBranch: "该分支没有提交",
- OnlySquashTopmostCommit: "只能压缩最顶层的提交",
YouNoCommitsToSquash: "您没有提交可以压缩",
Fixup: "修正(fixup)",
SureFixupThisCommit: "您确定要“修正”此提交吗?它将合并到下面的提交中",
diff --git a/pkg/i18n/dutch.go b/pkg/i18n/dutch.go
index 4436d653c..0127c07ad 100644
--- a/pkg/i18n/dutch.go
+++ b/pkg/i18n/dutch.go
@@ -39,8 +39,6 @@ func dutchTranslationSet() TranslationSet {
ResetCommitFilterState: "Reset commit file state filter",
MergeConflictsTitle: "Merge Conflicten",
LcCheckout: "uitchecken",
- NoFilesDisplay: "Geen bestanden om te laten zien",
- NotAFile: "Dit is geen bestand",
PullWait: "Pullen...",
PushWait: "Pushen...",
FetchWait: "Fetchen...",
@@ -69,7 +67,6 @@ func dutchTranslationSet() TranslationSet {
LcQuit: "quit",
LcSquashDown: "squash beneden",
LcFixupCommit: "Fixup commit",
- OnlySquashTopmostCommit: "Kan alleen bovenste commit squashen",
YouNoCommitsToSquash: "Je hebt geen commits om mee te squashen",
Fixup: "Fixup",
SureFixupThisCommit: "Weet je zeker dat je fixup wil uitvoeren op deze commit? De commit hieronder zol worden squashed in deze",
diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go
index f1c081018..c3a391795 100644
--- a/pkg/i18n/english.go
+++ b/pkg/i18n/english.go
@@ -59,8 +59,6 @@ type TranslationSet struct {
MergeConflictsTitle string
LcCheckout string
NoChangedFiles string
- NoFilesDisplay string
- NotAFile string
PullWait string
PushWait string
FetchWait string
@@ -89,7 +87,6 @@ type TranslationSet struct {
LcQuit string
LcSquashDown string
LcFixupCommit string
- OnlySquashTopmostCommit string
YouNoCommitsToSquash string
Fixup string
SureFixupThisCommit string
@@ -709,8 +706,6 @@ func EnglishTranslationSet() TranslationSet {
FilterUnstagedFiles: "Show only unstaged files",
ResetCommitFilterState: "Reset filter",
NoChangedFiles: "No changed files",
- NoFilesDisplay: "No file to display",
- NotAFile: "Not a file",
PullWait: "Pulling...",
PushWait: "Pushing...",
FetchWait: "Fetching...",
@@ -740,7 +735,6 @@ func EnglishTranslationSet() TranslationSet {
LcSquashDown: "squash down",
LcFixupCommit: "fixup commit",
NoCommitsThisBranch: "No commits for this branch",
- OnlySquashTopmostCommit: "Can only squash topmost commit",
YouNoCommitsToSquash: "You have no commits to squash with",
Fixup: "Fixup",
SureFixupThisCommit: "Are you sure you want to 'fixup' this commit? It will be merged into the commit below",
diff --git a/pkg/i18n/japanese.go b/pkg/i18n/japanese.go
index bfdf492f8..b119b0a63 100644
--- a/pkg/i18n/japanese.go
+++ b/pkg/i18n/japanese.go
@@ -64,8 +64,6 @@ func japaneseTranslationSet() TranslationSet {
FilterUnstagedFiles: "ステージされていないファイルのみを表示",
ResetCommitFilterState: "フィルタをリセット",
// NoChangedFiles: "No changed files",
- // NoFilesDisplay: "No file to display",
- // NotAFile: "Not a file",
PullWait: "Pull中...",
PushWait: "Push中...",
FetchWait: "Fetch中...",
@@ -95,7 +93,6 @@ func japaneseTranslationSet() TranslationSet {
// LcSquashDown: "squash down",
// LcFixupCommit: "fixup commit",
// NoCommitsThisBranch: "No commits for this branch",
- // OnlySquashTopmostCommit: "Can only squash topmost commit",
// YouNoCommitsToSquash: "You have no commits to squash with",
// Fixup: "Fixup",
// SureFixupThisCommit: "Are you sure you want to 'fixup' this commit? It will be merged into the commit below",
diff --git a/pkg/i18n/korean.go b/pkg/i18n/korean.go
index 573f22bdc..b891d83c3 100644
--- a/pkg/i18n/korean.go
+++ b/pkg/i18n/korean.go
@@ -63,8 +63,6 @@ func koreanTranslationSet() TranslationSet {
FilterUnstagedFiles: "Stage되지 않은 파일만 표시",
ResetCommitFilterState: "필터 리셋",
NoChangedFiles: "변경된 파일이 없습니다.",
- NoFilesDisplay: "표시할 파일이 없습니다",
- NotAFile: "파일이 아닙니다.",
PullWait: "업데이트 중...",
PushWait: "푸시 중...",
FetchWait: "패치 중...",
@@ -94,7 +92,6 @@ func koreanTranslationSet() TranslationSet {
LcSquashDown: "squash down",
LcFixupCommit: "fixup commit",
NoCommitsThisBranch: "이 브랜치에 커밋이 없습니다.",
- OnlySquashTopmostCommit: "Can only squash topmost commit",
YouNoCommitsToSquash: "You have no commits to squash with",
Fixup: "Fixup",
SureFixupThisCommit: "Are you sure you want to 'fixup' this commit? It will be merged into the commit below",
diff --git a/pkg/i18n/polish.go b/pkg/i18n/polish.go
index 8bcc460e1..05534c365 100644
--- a/pkg/i18n/polish.go
+++ b/pkg/i18n/polish.go
@@ -35,7 +35,6 @@ func polishTranslationSet() TranslationSet {
ResetCommitFilterState: "Resetuj filtr commitów",
LcCheckout: "przełącz",
NoChangedFiles: "Brak zmienionych plików",
- NoFilesDisplay: "Brak plików do wyświetlenia",
PullWait: "Pobieranie zmian...",
PushWait: "Wysyłanie zmian...",
FetchWait: "Pobieram...",
@@ -63,7 +62,6 @@ func polishTranslationSet() TranslationSet {
LcSquashDown: "ściśnij",
LcFixupCommit: "napraw commit",
NoCommitsThisBranch: "Brak commitów dla tej gałęzi",
- OnlySquashTopmostCommit: "Można tylko spłaszczyć najwyższy commit",
YouNoCommitsToSquash: "Nie masz commitów do spłaszczenia",
Fixup: "Napraw",
SureFixupThisCommit: "Jesteś pewny, ze chcesz naprawić ten commit? Commit poniżej zostanie spłaszczony w górę wraz z tym",
diff --git a/pkg/integration/tests/branch/detached_head.go b/pkg/integration/tests/branch/detached_head.go
new file mode 100644
index 000000000..7eb7e18ae
--- /dev/null
+++ b/pkg/integration/tests/branch/detached_head.go
@@ -0,0 +1,40 @@
+package branch
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var DetachedHead = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Create a new branch on detached head",
+ ExtraCmdArgs: "",
+ Skip: false,
+ SetupConfig: func(config *config.AppConfig) {},
+ SetupRepo: func(shell *Shell) {
+ shell.
+ CreateNCommits(10).
+ Checkout("HEAD^")
+ },
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ t.Views().Branches().
+ Focus().
+ Lines(
+ MatchesRegexp(`\*.*HEAD`).IsSelected(),
+ MatchesRegexp(`master`),
+ ).
+ Press(keys.Universal.New)
+
+ t.ExpectPopup().Prompt().
+ Title(MatchesRegexp(`^New Branch Name \(Branch is off of '[0-9a-f]+'\)$`)).
+ Type("new-branch").
+ Confirm()
+
+ t.Views().Branches().
+ Lines(
+ MatchesRegexp(`\* new-branch`).IsSelected(),
+ MatchesRegexp(`master`),
+ )
+
+ t.Git().CurrentBranchName("new-branch")
+ },
+})
diff --git a/pkg/integration/tests/tests.go b/pkg/integration/tests/tests.go
index f7463d0da..8d10b236f 100644
--- a/pkg/integration/tests/tests.go
+++ b/pkg/integration/tests/tests.go
@@ -38,6 +38,7 @@ var tests = []*components.IntegrationTest{
branch.RebaseAndDrop,
branch.Suggestions,
branch.Reset,
+ branch.DetachedHead,
cherry_pick.CherryPick,
cherry_pick.CherryPickConflicts,
commit.Commit,
diff --git a/pkg/utils/template.go b/pkg/utils/template.go
index d98a68b99..9b7f544d1 100644
--- a/pkg/utils/template.go
+++ b/pkg/utils/template.go
@@ -22,9 +22,12 @@ func ResolveTemplate(templateStr string, object interface{}, funcs template.Func
// ResolvePlaceholderString populates a template with values
func ResolvePlaceholderString(str string, arguments map[string]string) string {
+ oldnews := make([]string, 0, len(arguments)*4)
for key, value := range arguments {
- str = strings.Replace(str, "{{"+key+"}}", value, -1)
- str = strings.Replace(str, "{{."+key+"}}", value, -1)
+ oldnews = append(oldnews,
+ "{{"+key+"}}", value,
+ "{{."+key+"}}", value,
+ )
}
- return str
+ return strings.NewReplacer(oldnews...).Replace(str)
}
diff --git a/pkg/utils/template_test.go b/pkg/utils/template_test.go
index f294d115d..236c23278 100644
--- a/pkg/utils/template_test.go
+++ b/pkg/utils/template_test.go
@@ -53,6 +53,13 @@ func TestResolvePlaceholderString(t *testing.T) {
},
"{{}} {{ this }} { should not throw}} an {{{{}}}} error",
},
+ {
+ "{{a}}",
+ map[string]string{
+ "a": "X{{.a}}X",
+ },
+ "X{{.a}}X",
+ },
}
for _, s := range scenarios {
diff --git a/uffizzi/DockerfileTtyd b/uffizzi/DockerfileTtyd
new file mode 100644
index 000000000..274c58037
--- /dev/null
+++ b/uffizzi/DockerfileTtyd
@@ -0,0 +1,17 @@
+
+FROM uffizzi/ttyd:golang1.18-alpine as build
+
+WORKDIR /go/src/github.com/jesseduffield/lazygit/
+COPY go.mod go.sum ./
+RUN go mod download
+COPY . .
+RUN CGO_ENABLED=0 GOOS=linux go build
+
+RUN apk update --quiet && \
+ apk add -q --no-cache libgcc tini
+
+
+EXPOSE 7700/tcp
+
+ENTRYPOINT ["tini", "--"]
+CMD ["ttyd", "/bin/zsh"]
\ No newline at end of file
diff --git a/uffizzi/docker-compose.uffizzi.yml b/uffizzi/docker-compose.uffizzi.yml
new file mode 100644
index 000000000..859a315ff
--- /dev/null
+++ b/uffizzi/docker-compose.uffizzi.yml
@@ -0,0 +1,20 @@
+version: "3"
+
+x-uffizzi:
+ ingress:
+ service: application
+ port: 7681
+
+services:
+
+ application:
+ image: "${APP_IMAGE}"
+ entrypoint: ["/bin/bash", "-c"]
+ command: ["ttyd /usr/local/go/bin/go run /go/src/github.com/jesseduffield/lazygit/cmd/integration_test/main.go tui"]
+ ports:
+ - "7700:7700"
+ - "7681:7681"
+ deploy:
+ resources:
+ limits:
+ memory: 2000M