From 965f7bfcb219c7a08a9dbd865bd86e96fbe7e768 Mon Sep 17 00:00:00 2001 From: Ryooooooga Date: Mon, 2 Jan 2023 00:49:59 +0900 Subject: [PATCH 01/17] feat(config): change `git.commit.verbose` to accept "default" --- docs/Config.md | 2 +- pkg/commands/git_commands/commit.go | 7 ++- pkg/commands/git_commands/commit_test.go | 73 ++++++++++++++++++------ pkg/config/user_config.go | 6 +- 4 files changed, 66 insertions(+), 22 deletions(-) diff --git a/docs/Config.md b/docs/Config.md index d3b3aeb3a..250ed2cf5 100644 --- a/docs/Config.md +++ b/docs/Config.md @@ -67,7 +67,7 @@ git: useConfig: false commit: signOff: false - verbose: false + verbose: default # one of 'default' | 'always' | 'never' merging: # only applicable to unix users manualCommit: false 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_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/config/user_config.go b/pkg/config/user_config.go index 06dcf085b..59244f3f4 100644 --- a/pkg/config/user_config.go +++ b/pkg/config/user_config.go @@ -93,8 +93,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 { @@ -387,7 +387,7 @@ func GetDefaultConfig() *UserConfig { }, Commit: CommitConfig{ SignOff: false, - Verbose: false, + Verbose: "default", }, Merging: MergingConfig{ ManualCommit: false, From 21f8857d360dcc1c9079616c726e9b708a66726e Mon Sep 17 00:00:00 2001 From: Ryooooooga Date: Wed, 4 Jan 2023 22:13:11 +0900 Subject: [PATCH 02/17] refactor: simplify log format --- pkg/commands/git_commands/commit_loader.go | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/pkg/commands/git_commands/commit_loader.go b/pkg/commands/git_commands/commit_loader.go index f89f62c48..401292875 100644 --- a/pkg/commands/git_commands/commit_loader.go +++ b/pkg/commands/git_commands/commit_loader.go @@ -446,14 +446,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"` From acbcf9933db32c41ed6406a3738b003006c8abae Mon Sep 17 00:00:00 2001 From: Ryooooooga Date: Tue, 10 Jan 2023 20:43:23 +0900 Subject: [PATCH 03/17] docs(Config.md): add missing keybindings --- docs/Config.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/Config.md b/docs/Config.md index d3b3aeb3a..eaf131865 100644 --- a/docs/Config.md +++ b/docs/Config.md @@ -189,6 +189,8 @@ keybinding: viewResetOptions: 'D' fetch: 'f' toggleTreeView: '`' + openMergeTool: 'M' + openStatusFilter: '' branches: createPullRequest: 'o' viewPullRequestOptions: 'O' From b90af5461abb8109553ca89f824747a5196525b0 Mon Sep 17 00:00:00 2001 From: Aramayis <> Date: Wed, 26 Oct 2022 16:39:23 +0400 Subject: [PATCH 04/17] feat: uffizzi integration --- .github/workflows/uffizzi-build.yml | 89 +++++++++++++++++++++++++++ .github/workflows/uffizzi-preview.yml | 84 +++++++++++++++++++++++++ uffizzi/DockerfileTtyd | 17 +++++ uffizzi/docker-compose.uffizzi.yml | 20 ++++++ 4 files changed, 210 insertions(+) create mode 100644 .github/workflows/uffizzi-build.yml create mode 100644 .github/workflows/uffizzi-preview.yml create mode 100644 uffizzi/DockerfileTtyd create mode 100644 uffizzi/docker-compose.uffizzi.yml 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/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 From 6127e487dd977dc4a5c5f12fc72cc70d9d6205d1 Mon Sep 17 00:00:00 2001 From: README-bot Date: Mon, 16 Jan 2023 08:10:18 +0000 Subject: [PATCH 05/17] Updated README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2dbfdbaed..e91e80c92 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 From 48df9b7f4e950a7145fd66c1e1147efaa900b9ea Mon Sep 17 00:00:00 2001 From: README-bot Date: Mon, 16 Jan 2023 22:19:40 +0000 Subject: [PATCH 06/17] Updated README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e91e80c92..9588711d3 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 From b45c5d849190d41f5c14cd68139c9a3d54699bb5 Mon Sep 17 00:00:00 2001 From: Ryooooooga Date: Tue, 17 Jan 2023 16:28:05 +0900 Subject: [PATCH 07/17] docs(README.md): fix installation scripts for Ubuntu --- README.md | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index b3aae5515..9699e3529 100644 --- a/README.md +++ b/README.md @@ -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: From 7149cfeb11de63aac06ca96bc957c70c7e48321c Mon Sep 17 00:00:00 2001 From: Ryooooooga Date: Wed, 18 Jan 2023 20:56:22 +0900 Subject: [PATCH 08/17] fix: fix `ReplacePlaceholderString` --- pkg/utils/template.go | 9 ++++++--- pkg/utils/template_test.go | 7 +++++++ 2 files changed, 13 insertions(+), 3 deletions(-) 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 { From b8d33b8f7bb68e859871fde7741f3e70f6c87c72 Mon Sep 17 00:00:00 2001 From: stk Date: Sun, 22 Jan 2023 14:57:43 +0100 Subject: [PATCH 09/17] Extract helper function doRewordEditor No behavior change, just a preparation for the next commit. --- .../controllers/local_commits_controller.go | 44 ++++++++++--------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/pkg/gui/controllers/local_commits_controller.go b/pkg/gui/controllers/local_commits_controller.go index 6539a13af..8480a84a8 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 { @@ -236,27 +256,9 @@ func (self *LocalCommitsController) rewordEditor(commit *models.Commit) error { } 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 - }, + Title: self.c.Tr.RewordInEditorTitle, + Prompt: self.c.Tr.RewordInEditorPrompt, + HandleConfirm: self.doRewordEditor, }) } From 069af50f50b1791f717c3764f2ad5963657d1479 Mon Sep 17 00:00:00 2001 From: Ryooooooga Date: Tue, 24 Jan 2023 21:24:46 +0900 Subject: [PATCH 10/17] chore(i18n): remove unused texts --- pkg/i18n/chinese.go | 3 --- pkg/i18n/dutch.go | 3 --- pkg/i18n/english.go | 6 ------ pkg/i18n/japanese.go | 3 --- pkg/i18n/korean.go | 3 --- pkg/i18n/polish.go | 2 -- 6 files changed, 20 deletions(-) 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", From 7e54b5641f17b33f30de08bd2fd7909faddde9f0 Mon Sep 17 00:00:00 2001 From: README-bot Date: Thu, 26 Jan 2023 00:51:36 +0000 Subject: [PATCH 11/17] Updated README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9588711d3..d6577db1a 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 From 67fb28e2b89c7e9dd9cb58f6ad1acb76d4c78fa4 Mon Sep 17 00:00:00 2001 From: stk Date: Sun, 22 Jan 2023 15:09:13 +0100 Subject: [PATCH 12/17] Add user config gui.skipRewordInEditorWarning --- docs/Config.md | 1 + pkg/config/user_config.go | 68 ++++++++++--------- .../controllers/local_commits_controller.go | 14 ++-- 3 files changed, 45 insertions(+), 38 deletions(-) diff --git a/docs/Config.md b/docs/Config.md index e30bf6786..f7e236843 100644 --- a/docs/Config.md +++ b/docs/Config.md @@ -61,6 +61,7 @@ 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 diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go index 59244f3f4..705553407 100644 --- a/pkg/config/user_config.go +++ b/pkg/config/user_config.go @@ -27,29 +27,30 @@ 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"` + 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"` } type ThemeConfig struct { @@ -368,16 +369,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{ diff --git a/pkg/gui/controllers/local_commits_controller.go b/pkg/gui/controllers/local_commits_controller.go index 8480a84a8..3a9aff86b 100644 --- a/pkg/gui/controllers/local_commits_controller.go +++ b/pkg/gui/controllers/local_commits_controller.go @@ -255,11 +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: self.doRewordEditor, - }) + 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 { From 93d845cb015696863033ee3adf1b813b525698d0 Mon Sep 17 00:00:00 2001 From: stk Date: Wed, 25 Jan 2023 17:25:53 +0100 Subject: [PATCH 13/17] Cleanup: remove unused function RenderPlain --- pkg/commands/patch/patch_parser.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pkg/commands/patch/patch_parser.go b/pkg/commands/patch/patch_parser.go index 90b2ea13e..b57242c67 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 { From fc38e3b54d2327feee6ef30a78463238eb7554a4 Mon Sep 17 00:00:00 2001 From: stk Date: Wed, 25 Jan 2023 21:36:43 +0100 Subject: [PATCH 14/17] Don't omit final line feed when copying diff lines to clipboard --- pkg/commands/patch/patch_parser.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/commands/patch/patch_parser.go b/pkg/commands/patch/patch_parser.go index b57242c67..1fd3c107a 100644 --- a/pkg/commands/patch/patch_parser.go +++ b/pkg/commands/patch/patch_parser.go @@ -210,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 From 5dec08071902fabf5b9853c55ad3fb33fe14c5e6 Mon Sep 17 00:00:00 2001 From: Ryooooooga Date: Fri, 27 Jan 2023 20:14:03 +0900 Subject: [PATCH 15/17] fix: fix RefName of detached HEAD to works in Chinese --- pkg/commands/git_commands/branch.go | 22 ++++------ pkg/commands/git_commands/branch_test.go | 22 +++++----- pkg/integration/tests/branch/detached_head.go | 40 +++++++++++++++++++ pkg/integration/tests/tests.go | 1 + 4 files changed, 61 insertions(+), 24 deletions(-) create mode 100644 pkg/integration/tests/branch/detached_head.go 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/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, From 2183c157d42437fac74453700bbb2784d9341e3b Mon Sep 17 00:00:00 2001 From: Ryooooooga Date: Sat, 28 Jan 2023 21:10:57 +0900 Subject: [PATCH 16/17] feat(log): allow to disable `git.log.order` --- docs/Config.md | 2 +- pkg/commands/git_commands/commit_loader.go | 7 ++++-- .../git_commands/commit_loader_test.go | 25 ++++++++++++++++--- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/docs/Config.md b/docs/Config.md index e30bf6786..9bfc44f89 100644 --- a/docs/Config.md +++ b/docs/Config.md @@ -74,7 +74,7 @@ git: # 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' diff --git a/pkg/commands/git_commands/commit_loader.go b/pkg/commands/git_commands/commit_loader.go index 401292875..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, 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 From 9d5d61260af1475adcd10a3fd60563772084923c Mon Sep 17 00:00:00 2001 From: README-bot Date: Sun, 29 Jan 2023 02:43:45 +0000 Subject: [PATCH 17/17] Updated README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d89f53afc..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