1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-04-04 22:34:39 +02:00

Merge branch 'master' into #2319_default_screen_mode

This commit is contained in:
Phanindra Kumar Paladi 2023-01-29 10:25:14 +05:30 committed by GitHub
commit 01f0efb997
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 453 additions and 158 deletions

89
.github/workflows/uffizzi-build.yml vendored Normal file
View File

@ -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

84
.github/workflows/uffizzi-preview.yml vendored Normal file
View File

@ -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<<EOF' >> $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

File diff suppressed because one or more lines are too long

View File

@ -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: '<c-b>'
branches:
createPullRequest: 'o'
viewPullRequestOptions: 'O'

View File

@ -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
}

View File

@ -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)

View File

@ -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 ""
}
}

View File

@ -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"`

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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,

View File

@ -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 {

View File

@ -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: "您确定要“修正”此提交吗?它将合并到下面的提交中",

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -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")
},
})

View File

@ -38,6 +38,7 @@ var tests = []*components.IntegrationTest{
branch.RebaseAndDrop,
branch.Suggestions,
branch.Reset,
branch.DetachedHead,
cherry_pick.CherryPick,
cherry_pick.CherryPickConflicts,
commit.Commit,

View File

@ -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)
}

View File

@ -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 {

17
uffizzi/DockerfileTtyd Normal file
View File

@ -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"]

View File

@ -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