From 8b894d7bf5813411814d03fe7f0952da5d3985fc Mon Sep 17 00:00:00 2001 From: Arnaud PERALTA Date: Sun, 27 Nov 2022 01:00:51 +0100 Subject: [PATCH 1/6] wip: commit logic in helper and reported in files/staging controllers --- pkg/gui/controllers/files_controller.go | 124 +--------------- .../helpers/working_tree_helper.go | 137 +++++++++++++++++- pkg/gui/controllers/staging_controller.go | 15 ++ 3 files changed, 154 insertions(+), 122 deletions(-) diff --git a/pkg/gui/controllers/files_controller.go b/pkg/gui/controllers/files_controller.go index 22da8332b..27ae9b3fd 100644 --- a/pkg/gui/controllers/files_controller.go +++ b/pkg/gui/controllers/files_controller.go @@ -1,18 +1,14 @@ package controllers import ( - "fmt" - "regexp" "strings" "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/models" - "github.com/jesseduffield/lazygit/pkg/config" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/filetree" "github.com/jesseduffield/lazygit/pkg/gui/types" - "github.com/jesseduffield/lazygit/pkg/utils" ) type FilesController struct { @@ -54,12 +50,12 @@ func (self *FilesController) GetKeybindings(opts types.KeybindingsOpts) []*types }, { Key: opts.GetKey(opts.Config.Files.CommitChanges), - Handler: self.HandleCommitPress, + Handler: self.helpers.WorkingTree.HandleCommitPress, Description: self.c.Tr.CommitChanges, }, { Key: opts.GetKey(opts.Config.Files.CommitChangesWithoutHook), - Handler: self.HandleWIPCommitPress, + Handler: self.helpers.WorkingTree.HandleWIPCommitPress, Description: self.c.Tr.LcCommitChangesWithoutHook, }, { @@ -69,7 +65,7 @@ func (self *FilesController) GetKeybindings(opts types.KeybindingsOpts) []*types }, { Key: opts.GetKey(opts.Config.Files.CommitChangesWithEditor), - Handler: self.HandleCommitEditorPress, + Handler: self.helpers.WorkingTree.HandleCommitEditorPress, Description: self.c.Tr.CommitChangesWithEditor, }, { @@ -554,112 +550,17 @@ func (self *FilesController) ignoreOrExcludeMenu(node *filetree.FileNode) error }) } -func (self *FilesController) HandleWIPCommitPress() error { - skipHookPrefix := self.c.UserConfig.Git.SkipHookPrefix - if skipHookPrefix == "" { - return self.c.ErrorMsg(self.c.Tr.SkipHookPrefixNotConfigured) - } - - self.setCommitMessage(skipHookPrefix) - - return self.HandleCommitPress() -} - -func (self *FilesController) commitPrefixConfigForRepo() *config.CommitPrefixConfig { - cfg, ok := self.c.UserConfig.Git.CommitPrefixes[utils.GetCurrentRepoName()] - if !ok { - return nil - } - - return &cfg -} - -func (self *FilesController) prepareFilesForCommit() error { - noStagedFiles := !self.helpers.WorkingTree.AnyStagedFiles() - if noStagedFiles && self.c.UserConfig.Gui.SkipNoStagedFilesWarning { - self.c.LogAction(self.c.Tr.Actions.StageAllFiles) - err := self.git.WorkingTree.StageAll() - if err != nil { - return err - } - - return self.syncRefresh() - } - - return nil -} - -// for when you need to refetch files before continuing an action. Runs synchronously. -func (self *FilesController) syncRefresh() error { - return self.c.Refresh(types.RefreshOptions{Mode: types.SYNC, Scope: []types.RefreshableView{types.FILES}}) -} - func (self *FilesController) refresh() error { return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.FILES}}) } -func (self *FilesController) HandleCommitPress() error { - if err := self.prepareFilesForCommit(); err != nil { - return self.c.Error(err) - } - - if len(self.model.Files) == 0 { - return self.c.ErrorMsg(self.c.Tr.NoFilesStagedTitle) - } - - if !self.helpers.WorkingTree.AnyStagedFiles() { - return self.promptToStageAllAndRetry(self.HandleCommitPress) - } - - savedCommitMessage := self.getSavedCommitMessage() - if len(savedCommitMessage) > 0 { - self.setCommitMessage(savedCommitMessage) - } else { - commitPrefixConfig := self.commitPrefixConfigForRepo() - if commitPrefixConfig != nil { - prefixPattern := commitPrefixConfig.Pattern - prefixReplace := commitPrefixConfig.Replace - rgx, err := regexp.Compile(prefixPattern) - if err != nil { - return self.c.ErrorMsg(fmt.Sprintf("%s: %s", self.c.Tr.LcCommitPrefixPatternError, err.Error())) - } - prefix := rgx.ReplaceAllString(self.helpers.Refs.GetCheckedOutRef().Name, prefixReplace) - self.setCommitMessage(prefix) - } - } - - if err := self.c.PushContext(self.contexts.CommitMessage); err != nil { - return err - } - - return nil -} - -func (self *FilesController) promptToStageAllAndRetry(retry func() error) error { - return self.c.Confirm(types.ConfirmOpts{ - Title: self.c.Tr.NoFilesStagedTitle, - Prompt: self.c.Tr.NoFilesStagedPrompt, - HandleConfirm: func() error { - self.c.LogAction(self.c.Tr.Actions.StageAllFiles) - if err := self.git.WorkingTree.StageAll(); err != nil { - return self.c.Error(err) - } - if err := self.syncRefresh(); err != nil { - return self.c.Error(err) - } - - return retry() - }, - }) -} - func (self *FilesController) handleAmendCommitPress() error { if len(self.model.Files) == 0 { return self.c.ErrorMsg(self.c.Tr.NoFilesStagedTitle) } if !self.helpers.WorkingTree.AnyStagedFiles() { - return self.promptToStageAllAndRetry(self.handleAmendCommitPress) + return self.helpers.WorkingTree.PromptToStageAllAndRetry(self.handleAmendCommitPress) } if len(self.model.Commits) == 0 { @@ -677,23 +578,6 @@ func (self *FilesController) handleAmendCommitPress() error { }) } -// HandleCommitEditorPress - handle when the user wants to commit changes via -// their editor rather than via the popup panel -func (self *FilesController) HandleCommitEditorPress() error { - if len(self.model.Files) == 0 { - return self.c.ErrorMsg(self.c.Tr.NoFilesStagedTitle) - } - - if !self.helpers.WorkingTree.AnyStagedFiles() { - return self.promptToStageAllAndRetry(self.HandleCommitEditorPress) - } - - self.c.LogAction(self.c.Tr.Actions.Commit) - return self.c.RunSubprocessAndRefresh( - self.git.Commit.CommitEditorCmdObj(), - ) -} - func (self *FilesController) handleStatusFilterPressed() error { return self.c.Menu(types.CreateMenuOptions{ Title: self.c.Tr.FilteringMenuTitle, diff --git a/pkg/gui/controllers/helpers/working_tree_helper.go b/pkg/gui/controllers/helpers/working_tree_helper.go index ab52a37c7..a40bcbc6e 100644 --- a/pkg/gui/controllers/helpers/working_tree_helper.go +++ b/pkg/gui/controllers/helpers/working_tree_helper.go @@ -1,9 +1,14 @@ package helpers import ( + "fmt" + "regexp" "github.com/jesseduffield/lazygit/pkg/commands" "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/gui/types" + "github.com/jesseduffield/lazygit/pkg/config" + "github.com/jesseduffield/lazygit/pkg/utils" + "github.com/jesseduffield/lazygit/pkg/gui/context" ) type IWorkingTreeHelper interface { @@ -16,15 +21,30 @@ type IWorkingTreeHelper interface { type WorkingTreeHelper struct { c *types.HelperCommon git *commands.GitCommand - + contexts *context.ContextTree + refHelper *RefsHelper model *types.Model + setCommitMessage func(message string) + getSavedCommitMessage func() string } -func NewWorkingTreeHelper(c *types.HelperCommon, git *commands.GitCommand, model *types.Model) *WorkingTreeHelper { +func NewWorkingTreeHelper( + c *types.HelperCommon, + git *commands.GitCommand, + contexts *context.ContextTree, + refHelper *RefsHelper, + model *types.Model, + setCommitMessage func(message string), + getSavedCommitMessage func() string, +) *WorkingTreeHelper { return &WorkingTreeHelper{ c: c, git: git, + contexts: contexts, + refHelper: refHelper, model: model, + setCommitMessage: setCommitMessage, + getSavedCommitMessage: getSavedCommitMessage, } } @@ -72,3 +92,116 @@ func (self *WorkingTreeHelper) OpenMergeTool() error { }, }) } + +func (self *WorkingTreeHelper) HandleCommitPress() error { + if err := self.prepareFilesForCommit(); err != nil { + return self.c.Error(err) + } + + if len(self.model.Files) == 0 { + return self.c.ErrorMsg(self.c.Tr.NoFilesStagedTitle) + } + + if !self.AnyStagedFiles() { + return self.PromptToStageAllAndRetry(self.HandleCommitPress) + } + + savedCommitMessage := self.getSavedCommitMessage() + if len(savedCommitMessage) > 0 { + self.setCommitMessage(savedCommitMessage) + } else { + commitPrefixConfig := self.commitPrefixConfigForRepo() + if commitPrefixConfig != nil { + prefixPattern := commitPrefixConfig.Pattern + prefixReplace := commitPrefixConfig.Replace + rgx, err := regexp.Compile(prefixPattern) + if err != nil { + return self.c.ErrorMsg(fmt.Sprintf("%s: %s", self.c.Tr.LcCommitPrefixPatternError, err.Error())) + } + prefix := rgx.ReplaceAllString(self.refHelper.GetCheckedOutRef().Name, prefixReplace) + self.setCommitMessage(prefix) + } + } + + if err := self.c.PushContext(self.contexts.CommitMessage); err != nil { + return err + } + + return nil +} + +// HandleCommitEditorPress - handle when the user wants to commit changes via +// their editor rather than via the popup panel +func (self *WorkingTreeHelper) HandleCommitEditorPress() error { + if len(self.model.Files) == 0 { + return self.c.ErrorMsg(self.c.Tr.NoFilesStagedTitle) + } + + if !self.AnyStagedFiles() { + return self.PromptToStageAllAndRetry(self.HandleCommitEditorPress) + } + + self.c.LogAction(self.c.Tr.Actions.Commit) + return self.c.RunSubprocessAndRefresh( + self.git.Commit.CommitEditorCmdObj(), + ) +} + +func (self *WorkingTreeHelper) HandleWIPCommitPress() error { + skipHookPrefix := self.c.UserConfig.Git.SkipHookPrefix + if skipHookPrefix == "" { + return self.c.ErrorMsg(self.c.Tr.SkipHookPrefixNotConfigured) + } + + self.setCommitMessage(skipHookPrefix) + + return self.HandleCommitPress() +} + +func (self *WorkingTreeHelper) PromptToStageAllAndRetry(retry func() error) error { + return self.c.Confirm(types.ConfirmOpts{ + Title: self.c.Tr.NoFilesStagedTitle, + Prompt: self.c.Tr.NoFilesStagedPrompt, + HandleConfirm: func() error { + self.c.LogAction(self.c.Tr.Actions.StageAllFiles) + if err := self.git.WorkingTree.StageAll(); err != nil { + return self.c.Error(err) + } + if err := self.syncRefresh(); err != nil { + return self.c.Error(err) + } + + return retry() + }, + }) +} + +// for when you need to refetch files before continuing an action. Runs synchronously. +func (self *WorkingTreeHelper) syncRefresh() error { + return self.c.Refresh(types.RefreshOptions{Mode: types.SYNC, Scope: []types.RefreshableView{types.FILES}}) +} + +func (self *WorkingTreeHelper) prepareFilesForCommit() error { + noStagedFiles := !self.AnyStagedFiles() + if noStagedFiles && self.c.UserConfig.Gui.SkipNoStagedFilesWarning { + self.c.LogAction(self.c.Tr.Actions.StageAllFiles) + err := self.git.WorkingTree.StageAll() + if err != nil { + return err + } + + return self.syncRefresh(); + } + + return nil +} + +func (self *WorkingTreeHelper) commitPrefixConfigForRepo() *config.CommitPrefixConfig { + cfg, ok := self.c.UserConfig.Git.CommitPrefixes[utils.GetCurrentRepoName()] + if !ok { + return nil + } + + return &cfg +} + diff --git a/pkg/gui/controllers/staging_controller.go b/pkg/gui/controllers/staging_controller.go index d41bb1ff5..a141c4740 100644 --- a/pkg/gui/controllers/staging_controller.go +++ b/pkg/gui/controllers/staging_controller.go @@ -73,6 +73,21 @@ func (self *StagingController) GetKeybindings(opts types.KeybindingsOpts) []*typ Handler: self.EditHunkAndRefresh, Description: self.c.Tr.EditHunk, }, + { + Key: opts.GetKey(opts.Config.Files.CommitChanges), + Handler: self.helpers.WorkingTree.HandleCommitPress, + Description: self.c.Tr.CommitChanges, + }, + { + Key: opts.GetKey(opts.Config.Files.CommitChangesWithoutHook), + Handler: self.helpers.WorkingTree.HandleWIPCommitPress, + Description: self.c.Tr.LcCommitChangesWithoutHook, + }, + { + Key: opts.GetKey(opts.Config.Files.CommitChangesWithEditor), + Handler: self.helpers.WorkingTree.HandleCommitEditorPress, + Description: self.c.Tr.CommitChangesWithEditor, + }, } } From 0af63daf1890bf6be5a299f00033e72826e0af8a Mon Sep 17 00:00:00 2001 From: Arnaud PERALTA Date: Sun, 27 Nov 2022 01:10:24 +0100 Subject: [PATCH 2/6] workingtree controller fixed with new references for commit in staged menu --- pkg/gui/controllers.go | 12 +++--- .../helpers/working_tree_helper.go | 40 +++++++++---------- 2 files changed, 25 insertions(+), 27 deletions(-) diff --git a/pkg/gui/controllers.go b/pkg/gui/controllers.go index 4efb5e1ff..98a15b3d8 100644 --- a/pkg/gui/controllers.go +++ b/pkg/gui/controllers.go @@ -24,6 +24,10 @@ func (gui *Gui) resetControllers() { rebaseHelper := helpers.NewMergeAndRebaseHelper(helperCommon, gui.State.Contexts, gui.git, refsHelper) suggestionsHelper := helpers.NewSuggestionsHelper(helperCommon, model, gui.refreshSuggestions) + setCommitMessage := gui.getSetTextareaTextFn(func() *gocui.View { return gui.Views.CommitMessage }) + getSavedCommitMessage := func() string { + return gui.State.savedCommitMessage + } gui.helpers = &helpers.Helpers{ Refs: refsHelper, Host: helpers.NewHostHelper(helperCommon, gui.git), @@ -31,7 +35,7 @@ func (gui *Gui) resetControllers() { Bisect: helpers.NewBisectHelper(helperCommon, gui.git), Suggestions: suggestionsHelper, Files: helpers.NewFilesHelper(helperCommon, gui.git, osCommand), - WorkingTree: helpers.NewWorkingTreeHelper(helperCommon, gui.git, model), + WorkingTree: helpers.NewWorkingTreeHelper(helperCommon, gui.git, gui.State.Contexts, refsHelper, model, setCommitMessage, getSavedCommitMessage), Tags: helpers.NewTagsHelper(helperCommon, gui.git), GPG: helpers.NewGpgHelper(helperCommon, gui.os, gui.git), MergeAndRebase: rebaseHelper, @@ -76,16 +80,10 @@ func (gui *Gui) resetControllers() { bisectController := controllers.NewBisectController(common) - getSavedCommitMessage := func() string { - return gui.State.savedCommitMessage - } - getCommitMessage := func() string { return strings.TrimSpace(gui.Views.CommitMessage.TextArea.GetContent()) } - setCommitMessage := gui.getSetTextareaTextFn(func() *gocui.View { return gui.Views.CommitMessage }) - onCommitAttempt := func(message string) { gui.State.savedCommitMessage = message gui.Views.CommitMessage.ClearTextArea() diff --git a/pkg/gui/controllers/helpers/working_tree_helper.go b/pkg/gui/controllers/helpers/working_tree_helper.go index a40bcbc6e..17850b994 100644 --- a/pkg/gui/controllers/helpers/working_tree_helper.go +++ b/pkg/gui/controllers/helpers/working_tree_helper.go @@ -2,13 +2,14 @@ package helpers import ( "fmt" - "regexp" + "regexp" + "github.com/jesseduffield/lazygit/pkg/commands" "github.com/jesseduffield/lazygit/pkg/commands/models" - "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/config" - "github.com/jesseduffield/lazygit/pkg/utils" "github.com/jesseduffield/lazygit/pkg/gui/context" + "github.com/jesseduffield/lazygit/pkg/gui/types" + "github.com/jesseduffield/lazygit/pkg/utils" ) type IWorkingTreeHelper interface { @@ -19,30 +20,30 @@ type IWorkingTreeHelper interface { } type WorkingTreeHelper struct { - c *types.HelperCommon - git *commands.GitCommand - contexts *context.ContextTree - refHelper *RefsHelper - model *types.Model + c *types.HelperCommon + git *commands.GitCommand + contexts *context.ContextTree + refHelper *RefsHelper + model *types.Model setCommitMessage func(message string) getSavedCommitMessage func() string } func NewWorkingTreeHelper( - c *types.HelperCommon, - git *commands.GitCommand, - contexts *context.ContextTree, - refHelper *RefsHelper, - model *types.Model, + c *types.HelperCommon, + git *commands.GitCommand, + contexts *context.ContextTree, + refHelper *RefsHelper, + model *types.Model, setCommitMessage func(message string), getSavedCommitMessage func() string, ) *WorkingTreeHelper { return &WorkingTreeHelper{ - c: c, - git: git, - contexts: contexts, - refHelper: refHelper, - model: model, + c: c, + git: git, + contexts: contexts, + refHelper: refHelper, + model: model, setCommitMessage: setCommitMessage, getSavedCommitMessage: getSavedCommitMessage, } @@ -190,7 +191,7 @@ func (self *WorkingTreeHelper) prepareFilesForCommit() error { return err } - return self.syncRefresh(); + return self.syncRefresh() } return nil @@ -204,4 +205,3 @@ func (self *WorkingTreeHelper) commitPrefixConfigForRepo() *config.CommitPrefixC return &cfg } - From d0499286e23780eecf07b51e4baab578de8693bf Mon Sep 17 00:00:00 2001 From: Arnaud PERALTA Date: Sun, 27 Nov 2022 01:13:45 +0100 Subject: [PATCH 3/6] keybindings cheatsheet for commit in unstaged/staged --- docs/keybindings/Keybindings_en.md | 3 +++ docs/keybindings/Keybindings_ja.md | 3 +++ docs/keybindings/Keybindings_ko.md | 3 +++ docs/keybindings/Keybindings_nl.md | 3 +++ docs/keybindings/Keybindings_pl.md | 3 +++ docs/keybindings/Keybindings_zh.md | 3 +++ 6 files changed, 18 insertions(+) diff --git a/docs/keybindings/Keybindings_en.md b/docs/keybindings/Keybindings_en.md index df42f5a62..5c56b6b83 100644 --- a/docs/keybindings/Keybindings_en.md +++ b/docs/keybindings/Keybindings_en.md @@ -191,6 +191,9 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct space: toggle line staged / unstaged d: delete change (git reset) E: edit hunk + c: commit changes + w: commit changes without pre-commit hook + C: commit changes using git editor ## Reflog diff --git a/docs/keybindings/Keybindings_ja.md b/docs/keybindings/Keybindings_ja.md index 910b6938d..2cf603abf 100644 --- a/docs/keybindings/Keybindings_ja.md +++ b/docs/keybindings/Keybindings_ja.md @@ -251,6 +251,9 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct space: 選択行をステージ/アンステージ d: 変更を削除 (git reset) E: edit hunk + c: 変更をコミット + w: pre-commitフックを実行せずに変更をコミット + C: gitエディタを使用して変更をコミット ## リモート diff --git a/docs/keybindings/Keybindings_ko.md b/docs/keybindings/Keybindings_ko.md index 2edef93ff..f49e6eb78 100644 --- a/docs/keybindings/Keybindings_ko.md +++ b/docs/keybindings/Keybindings_ko.md @@ -136,6 +136,9 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct space: 선택한 행을 staged / unstaged d: 변경을 삭제 (git reset) E: edit hunk + c: 커밋 변경내용 + w: commit changes without pre-commit hook + C: Git 편집기를 사용하여 변경 내용을 커밋합니다. ## 브랜치 diff --git a/docs/keybindings/Keybindings_nl.md b/docs/keybindings/Keybindings_nl.md index 06b96af5c..01ea95417 100644 --- a/docs/keybindings/Keybindings_nl.md +++ b/docs/keybindings/Keybindings_nl.md @@ -229,6 +229,9 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct space: toggle lijnen staged / unstaged d: verwijdert change (git reset) E: edit hunk + c: commit veranderingen + w: commit veranderingen zonder pre-commit hook + C: commit veranderingen met de git editor ## Stash diff --git a/docs/keybindings/Keybindings_pl.md b/docs/keybindings/Keybindings_pl.md index a1ca9cfd2..23473ca2c 100644 --- a/docs/keybindings/Keybindings_pl.md +++ b/docs/keybindings/Keybindings_pl.md @@ -168,6 +168,9 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct space: toggle line staged / unstaged d: delete change (git reset) E: edit hunk + c: Zatwierdź zmiany + w: zatwierdź zmiany bez skryptu pre-commit + C: Zatwierdź zmiany używając edytora ## Reflog diff --git a/docs/keybindings/Keybindings_zh.md b/docs/keybindings/Keybindings_zh.md index 98b180a52..6650d0f71 100644 --- a/docs/keybindings/Keybindings_zh.md +++ b/docs/keybindings/Keybindings_zh.md @@ -238,6 +238,9 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct space: 切换行暂存状态 d: 取消变更 (git reset) E: edit hunk + c: 提交更改 + w: 提交更改而无需预先提交钩子 + C: 提交更改(使用编辑器编辑提交信息) ## 正常 From 87e0f6b92d2d34e5707da633e428a92a93bbac15 Mon Sep 17 00:00:00 2001 From: Arnaud PERALTA Date: Sun, 27 Nov 2022 17:33:37 +0100 Subject: [PATCH 4/6] integration tests for commit in staged files and unstaged files menus --- pkg/integration/tests/commit/staged.go | 33 ++++++++++++++++++ pkg/integration/tests/commit/unstaged.go | 32 +++++++++++++++++ pkg/integration/tests/tests.go | 2 ++ .../expected/repo/.git_keep/COMMIT_EDITMSG | 1 + .../staged/expected/repo/.git_keep/FETCH_HEAD | 0 .../staged/expected/repo/.git_keep/HEAD | 1 + .../staged/expected/repo/.git_keep/MERGE_RR | 0 .../staged/expected/repo/.git_keep/config | 12 +++++++ .../expected/repo/.git_keep/description | 1 + .../staged/expected/repo/.git_keep/index | Bin 0 -> 209 bytes .../expected/repo/.git_keep/info/exclude | 6 ++++ .../staged/expected/repo/.git_keep/logs/HEAD | 1 + .../repo/.git_keep/logs/refs/heads/master | 1 + .../3a/e2df795236e3c84cb1faa242d3268838603515 | Bin 0 -> 76 bytes .../97/04090f88911a4083ef7d5907e38b9f45e43b16 | Bin 0 -> 31 bytes .../ad/a5661567ddf0a64f589cad3cd0cffd7e79af99 | Bin 0 -> 30 bytes .../ef/3197feca3fdc5b9f0170f483c6ff138d5cf186 | 2 ++ .../expected/repo/.git_keep/refs/heads/master | 1 + .../commit/staged/expected/repo/myfile | 1 + .../commit/staged/expected/repo/myfile2 | 1 + .../expected/repo/.git_keep/COMMIT_EDITMSG | 1 + .../expected/repo/.git_keep/FETCH_HEAD | 0 .../staging/expected/repo/.git_keep/HEAD | 1 + .../staging/expected/repo/.git_keep/MERGE_RR | 0 .../staging/expected/repo/.git_keep/config | 12 +++++++ .../expected/repo/.git_keep/description | 1 + .../staging/expected/repo/.git_keep/index | Bin 0 -> 209 bytes .../expected/repo/.git_keep/info/exclude | 6 ++++ .../staging/expected/repo/.git_keep/logs/HEAD | 1 + .../repo/.git_keep/logs/refs/heads/master | 1 + .../28/f8e24755d8792e66738e36f193949a68021709 | Bin 0 -> 125 bytes .../3a/e2df795236e3c84cb1faa242d3268838603515 | Bin 0 -> 76 bytes .../97/04090f88911a4083ef7d5907e38b9f45e43b16 | Bin 0 -> 31 bytes .../ad/a5661567ddf0a64f589cad3cd0cffd7e79af99 | Bin 0 -> 30 bytes .../expected/repo/.git_keep/refs/heads/master | 1 + .../commit/staging/expected/repo/myfile | 1 + .../commit/staging/expected/repo/myfile2 | 1 + .../expected/repo/.git_keep/COMMIT_EDITMSG | 1 + .../expected/repo/.git_keep/FETCH_HEAD | 0 .../unstaged/expected/repo/.git_keep/HEAD | 1 + .../unstaged/expected/repo/.git_keep/MERGE_RR | 0 .../unstaged/expected/repo/.git_keep/config | 12 +++++++ .../expected/repo/.git_keep/description | 1 + .../unstaged/expected/repo/.git_keep/index | Bin 0 -> 137 bytes .../expected/repo/.git_keep/info/exclude | 6 ++++ .../expected/repo/.git_keep/logs/HEAD | 1 + .../repo/.git_keep/logs/refs/heads/master | 1 + .../0c/4369dfc55cd41da90e149f2fa8ee3fc0a8f297 | Bin 0 -> 51 bytes .../ad/a5661567ddf0a64f589cad3cd0cffd7e79af99 | Bin 0 -> 30 bytes .../d4/6951396fe8179592ec90aee0c0414fc0512fc5 | Bin 0 -> 124 bytes .../expected/repo/.git_keep/refs/heads/master | 1 + .../commit/unstaged/expected/repo/myfile | 1 + .../commit/unstaged/expected/repo/myfile2 | 1 + 53 files changed, 147 insertions(+) create mode 100644 pkg/integration/tests/commit/staged.go create mode 100644 pkg/integration/tests/commit/unstaged.go create mode 100644 test/integration_new/commit/staged/expected/repo/.git_keep/COMMIT_EDITMSG create mode 100644 test/integration_new/commit/staged/expected/repo/.git_keep/FETCH_HEAD create mode 100644 test/integration_new/commit/staged/expected/repo/.git_keep/HEAD create mode 100644 test/integration_new/commit/staged/expected/repo/.git_keep/MERGE_RR create mode 100644 test/integration_new/commit/staged/expected/repo/.git_keep/config create mode 100644 test/integration_new/commit/staged/expected/repo/.git_keep/description create mode 100644 test/integration_new/commit/staged/expected/repo/.git_keep/index create mode 100644 test/integration_new/commit/staged/expected/repo/.git_keep/info/exclude create mode 100644 test/integration_new/commit/staged/expected/repo/.git_keep/logs/HEAD create mode 100644 test/integration_new/commit/staged/expected/repo/.git_keep/logs/refs/heads/master create mode 100644 test/integration_new/commit/staged/expected/repo/.git_keep/objects/3a/e2df795236e3c84cb1faa242d3268838603515 create mode 100644 test/integration_new/commit/staged/expected/repo/.git_keep/objects/97/04090f88911a4083ef7d5907e38b9f45e43b16 create mode 100644 test/integration_new/commit/staged/expected/repo/.git_keep/objects/ad/a5661567ddf0a64f589cad3cd0cffd7e79af99 create mode 100644 test/integration_new/commit/staged/expected/repo/.git_keep/objects/ef/3197feca3fdc5b9f0170f483c6ff138d5cf186 create mode 100644 test/integration_new/commit/staged/expected/repo/.git_keep/refs/heads/master create mode 100644 test/integration_new/commit/staged/expected/repo/myfile create mode 100644 test/integration_new/commit/staged/expected/repo/myfile2 create mode 100644 test/integration_new/commit/staging/expected/repo/.git_keep/COMMIT_EDITMSG create mode 100644 test/integration_new/commit/staging/expected/repo/.git_keep/FETCH_HEAD create mode 100644 test/integration_new/commit/staging/expected/repo/.git_keep/HEAD create mode 100644 test/integration_new/commit/staging/expected/repo/.git_keep/MERGE_RR create mode 100644 test/integration_new/commit/staging/expected/repo/.git_keep/config create mode 100644 test/integration_new/commit/staging/expected/repo/.git_keep/description create mode 100644 test/integration_new/commit/staging/expected/repo/.git_keep/index create mode 100644 test/integration_new/commit/staging/expected/repo/.git_keep/info/exclude create mode 100644 test/integration_new/commit/staging/expected/repo/.git_keep/logs/HEAD create mode 100644 test/integration_new/commit/staging/expected/repo/.git_keep/logs/refs/heads/master create mode 100644 test/integration_new/commit/staging/expected/repo/.git_keep/objects/28/f8e24755d8792e66738e36f193949a68021709 create mode 100644 test/integration_new/commit/staging/expected/repo/.git_keep/objects/3a/e2df795236e3c84cb1faa242d3268838603515 create mode 100644 test/integration_new/commit/staging/expected/repo/.git_keep/objects/97/04090f88911a4083ef7d5907e38b9f45e43b16 create mode 100644 test/integration_new/commit/staging/expected/repo/.git_keep/objects/ad/a5661567ddf0a64f589cad3cd0cffd7e79af99 create mode 100644 test/integration_new/commit/staging/expected/repo/.git_keep/refs/heads/master create mode 100644 test/integration_new/commit/staging/expected/repo/myfile create mode 100644 test/integration_new/commit/staging/expected/repo/myfile2 create mode 100644 test/integration_new/commit/unstaged/expected/repo/.git_keep/COMMIT_EDITMSG create mode 100644 test/integration_new/commit/unstaged/expected/repo/.git_keep/FETCH_HEAD create mode 100644 test/integration_new/commit/unstaged/expected/repo/.git_keep/HEAD create mode 100644 test/integration_new/commit/unstaged/expected/repo/.git_keep/MERGE_RR create mode 100644 test/integration_new/commit/unstaged/expected/repo/.git_keep/config create mode 100644 test/integration_new/commit/unstaged/expected/repo/.git_keep/description create mode 100644 test/integration_new/commit/unstaged/expected/repo/.git_keep/index create mode 100644 test/integration_new/commit/unstaged/expected/repo/.git_keep/info/exclude create mode 100644 test/integration_new/commit/unstaged/expected/repo/.git_keep/logs/HEAD create mode 100644 test/integration_new/commit/unstaged/expected/repo/.git_keep/logs/refs/heads/master create mode 100644 test/integration_new/commit/unstaged/expected/repo/.git_keep/objects/0c/4369dfc55cd41da90e149f2fa8ee3fc0a8f297 create mode 100644 test/integration_new/commit/unstaged/expected/repo/.git_keep/objects/ad/a5661567ddf0a64f589cad3cd0cffd7e79af99 create mode 100644 test/integration_new/commit/unstaged/expected/repo/.git_keep/objects/d4/6951396fe8179592ec90aee0c0414fc0512fc5 create mode 100644 test/integration_new/commit/unstaged/expected/repo/.git_keep/refs/heads/master create mode 100644 test/integration_new/commit/unstaged/expected/repo/myfile create mode 100644 test/integration_new/commit/unstaged/expected/repo/myfile2 diff --git a/pkg/integration/tests/commit/staged.go b/pkg/integration/tests/commit/staged.go new file mode 100644 index 000000000..80de2bca9 --- /dev/null +++ b/pkg/integration/tests/commit/staged.go @@ -0,0 +1,33 @@ +package commit + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var Staged = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Staging a couple files, going in the staged files menu and committing", + ExtraCmdArgs: "", + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell.CreateFile("myfile", "myfile content") + shell.CreateFile("myfile2", "myfile2 content") + }, + Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { + assert.CommitCount(0) + + input.PrimaryAction() + input.NextItem() + input.PrimaryAction() + input.Confirm() + input.PressKeys(keys.Files.CommitChanges) + + commitMessage := "my commit message" + input.Type(commitMessage) + input.Confirm() + + assert.CommitCount(1) + assert.MatchHeadCommitMessage(Equals(commitMessage)) + }, +}) diff --git a/pkg/integration/tests/commit/unstaged.go b/pkg/integration/tests/commit/unstaged.go new file mode 100644 index 000000000..5dd396eec --- /dev/null +++ b/pkg/integration/tests/commit/unstaged.go @@ -0,0 +1,32 @@ +package commit + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var Unstaged = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Staging a couple files, going in the unstaged files menu and committing", + ExtraCmdArgs: "", + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell.CreateFile("myfile", "myfile content") + shell.CreateFile("myfile2", "myfile2 content") + }, + Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { + assert.CommitCount(0) + + input.PrimaryAction() + input.NextItem() + input.Confirm() + input.PressKeys(keys.Files.CommitChanges) + + commitMessage := "my commit message" + input.Type(commitMessage) + input.Confirm() + + assert.CommitCount(1) + assert.MatchHeadCommitMessage(Equals(commitMessage)) + }, +}) diff --git a/pkg/integration/tests/tests.go b/pkg/integration/tests/tests.go index 6c074bb10..9b654ad80 100644 --- a/pkg/integration/tests/tests.go +++ b/pkg/integration/tests/tests.go @@ -36,6 +36,8 @@ var tests = []*components.IntegrationTest{ cherry_pick.CherryPickConflicts, commit.Commit, commit.NewBranch, + commit.Staged, + commit.Unstaged, custom_commands.Basic, custom_commands.FormPrompts, custom_commands.MenuFromCommand, diff --git a/test/integration_new/commit/staged/expected/repo/.git_keep/COMMIT_EDITMSG b/test/integration_new/commit/staged/expected/repo/.git_keep/COMMIT_EDITMSG new file mode 100644 index 000000000..8a744b4fe --- /dev/null +++ b/test/integration_new/commit/staged/expected/repo/.git_keep/COMMIT_EDITMSG @@ -0,0 +1 @@ +my commit message diff --git a/test/integration_new/commit/staged/expected/repo/.git_keep/FETCH_HEAD b/test/integration_new/commit/staged/expected/repo/.git_keep/FETCH_HEAD new file mode 100644 index 000000000..e69de29bb diff --git a/test/integration_new/commit/staged/expected/repo/.git_keep/HEAD b/test/integration_new/commit/staged/expected/repo/.git_keep/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/test/integration_new/commit/staged/expected/repo/.git_keep/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/test/integration_new/commit/staged/expected/repo/.git_keep/MERGE_RR b/test/integration_new/commit/staged/expected/repo/.git_keep/MERGE_RR new file mode 100644 index 000000000..e69de29bb diff --git a/test/integration_new/commit/staged/expected/repo/.git_keep/config b/test/integration_new/commit/staged/expected/repo/.git_keep/config new file mode 100644 index 000000000..2b89b8630 --- /dev/null +++ b/test/integration_new/commit/staged/expected/repo/.git_keep/config @@ -0,0 +1,12 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true +[user] + email = CI@example.com + name = CI +[commit] + gpgSign = false +[protocol "file"] + allow = always diff --git a/test/integration_new/commit/staged/expected/repo/.git_keep/description b/test/integration_new/commit/staged/expected/repo/.git_keep/description new file mode 100644 index 000000000..498b267a8 --- /dev/null +++ b/test/integration_new/commit/staged/expected/repo/.git_keep/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/test/integration_new/commit/staged/expected/repo/.git_keep/index b/test/integration_new/commit/staged/expected/repo/.git_keep/index new file mode 100644 index 0000000000000000000000000000000000000000..193a6619c85c5c3d651b6fe2f70ca51ea7dfc7d7 GIT binary patch literal 209 zcmZ?q402{*U|<5_l14+ z26l)!MnFv=L9VVqN|M1y!GO!^(f!IGv&ScVHvU@VbXl##BEeL&@rKAx)%Wdxn-^KW N<+(l~ 1669566692 +0100 commit (initial): my commit message diff --git a/test/integration_new/commit/staged/expected/repo/.git_keep/logs/refs/heads/master b/test/integration_new/commit/staged/expected/repo/.git_keep/logs/refs/heads/master new file mode 100644 index 000000000..40d31f9ee --- /dev/null +++ b/test/integration_new/commit/staged/expected/repo/.git_keep/logs/refs/heads/master @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 ef3197feca3fdc5b9f0170f483c6ff138d5cf186 CI 1669566692 +0100 commit (initial): my commit message diff --git a/test/integration_new/commit/staged/expected/repo/.git_keep/objects/3a/e2df795236e3c84cb1faa242d3268838603515 b/test/integration_new/commit/staged/expected/repo/.git_keep/objects/3a/e2df795236e3c84cb1faa242d3268838603515 new file mode 100644 index 0000000000000000000000000000000000000000..57198442f6ad83fffd10538fa84ecee53ee8f023 GIT binary patch literal 76 zcmV-S0JHyi0V^p=O;s?nWH2-^Ff%bx$gNDv%t>WfyEIKS{qBcl{tT_-wHN?jA|1xZp&@wy literal 0 HcmV?d00001 diff --git a/test/integration_new/commit/staged/expected/repo/.git_keep/objects/97/04090f88911a4083ef7d5907e38b9f45e43b16 b/test/integration_new/commit/staged/expected/repo/.git_keep/objects/97/04090f88911a4083ef7d5907e38b9f45e43b16 new file mode 100644 index 0000000000000000000000000000000000000000..c4b48a2f084a86a8022e805a2a31d1f398d03f12 GIT binary patch literal 31 ncmbxm'Uԝ}M0 \ No newline at end of file diff --git a/test/integration_new/commit/staged/expected/repo/.git_keep/refs/heads/master b/test/integration_new/commit/staged/expected/repo/.git_keep/refs/heads/master new file mode 100644 index 000000000..b44143ba4 --- /dev/null +++ b/test/integration_new/commit/staged/expected/repo/.git_keep/refs/heads/master @@ -0,0 +1 @@ +ef3197feca3fdc5b9f0170f483c6ff138d5cf186 diff --git a/test/integration_new/commit/staged/expected/repo/myfile b/test/integration_new/commit/staged/expected/repo/myfile new file mode 100644 index 000000000..ada566156 --- /dev/null +++ b/test/integration_new/commit/staged/expected/repo/myfile @@ -0,0 +1 @@ +myfile content \ No newline at end of file diff --git a/test/integration_new/commit/staged/expected/repo/myfile2 b/test/integration_new/commit/staged/expected/repo/myfile2 new file mode 100644 index 000000000..9704090f8 --- /dev/null +++ b/test/integration_new/commit/staged/expected/repo/myfile2 @@ -0,0 +1 @@ +myfile2 content \ No newline at end of file diff --git a/test/integration_new/commit/staging/expected/repo/.git_keep/COMMIT_EDITMSG b/test/integration_new/commit/staging/expected/repo/.git_keep/COMMIT_EDITMSG new file mode 100644 index 000000000..8a744b4fe --- /dev/null +++ b/test/integration_new/commit/staging/expected/repo/.git_keep/COMMIT_EDITMSG @@ -0,0 +1 @@ +my commit message diff --git a/test/integration_new/commit/staging/expected/repo/.git_keep/FETCH_HEAD b/test/integration_new/commit/staging/expected/repo/.git_keep/FETCH_HEAD new file mode 100644 index 000000000..e69de29bb diff --git a/test/integration_new/commit/staging/expected/repo/.git_keep/HEAD b/test/integration_new/commit/staging/expected/repo/.git_keep/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/test/integration_new/commit/staging/expected/repo/.git_keep/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/test/integration_new/commit/staging/expected/repo/.git_keep/MERGE_RR b/test/integration_new/commit/staging/expected/repo/.git_keep/MERGE_RR new file mode 100644 index 000000000..e69de29bb diff --git a/test/integration_new/commit/staging/expected/repo/.git_keep/config b/test/integration_new/commit/staging/expected/repo/.git_keep/config new file mode 100644 index 000000000..2b89b8630 --- /dev/null +++ b/test/integration_new/commit/staging/expected/repo/.git_keep/config @@ -0,0 +1,12 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true +[user] + email = CI@example.com + name = CI +[commit] + gpgSign = false +[protocol "file"] + allow = always diff --git a/test/integration_new/commit/staging/expected/repo/.git_keep/description b/test/integration_new/commit/staging/expected/repo/.git_keep/description new file mode 100644 index 000000000..498b267a8 --- /dev/null +++ b/test/integration_new/commit/staging/expected/repo/.git_keep/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/test/integration_new/commit/staging/expected/repo/.git_keep/index b/test/integration_new/commit/staging/expected/repo/.git_keep/index new file mode 100644 index 0000000000000000000000000000000000000000..3c44f83b5778461cfcfffb754547d358a3777c52 GIT binary patch literal 209 zcmZ?q402{*U|<5_ 1669566470 +0100 commit (initial): my commit message diff --git a/test/integration_new/commit/staging/expected/repo/.git_keep/logs/refs/heads/master b/test/integration_new/commit/staging/expected/repo/.git_keep/logs/refs/heads/master new file mode 100644 index 000000000..910749aff --- /dev/null +++ b/test/integration_new/commit/staging/expected/repo/.git_keep/logs/refs/heads/master @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 28f8e24755d8792e66738e36f193949a68021709 CI 1669566470 +0100 commit (initial): my commit message diff --git a/test/integration_new/commit/staging/expected/repo/.git_keep/objects/28/f8e24755d8792e66738e36f193949a68021709 b/test/integration_new/commit/staging/expected/repo/.git_keep/objects/28/f8e24755d8792e66738e36f193949a68021709 new file mode 100644 index 0000000000000000000000000000000000000000..cc6a8ec738cdbc068ec2dd881effc185383097a4 GIT binary patch literal 125 zcmV-@0D}K`0ga783c@fD06pgwdlzJrO|~hB2tD-~Yr0jzCDKOF-&^nlUWXZ`RI_^n zpLo|6RUpwY&0U`Yu~NygT>LB&Vwfm!&XgG``Q+r)ZgqiSgyS%t^)2>%=%G|QfoJX$ fbLsUw@K4Kb!Q*=C1AR)a#i;Qvz{;YtX(^% literal 0 HcmV?d00001 diff --git a/test/integration_new/commit/staging/expected/repo/.git_keep/objects/3a/e2df795236e3c84cb1faa242d3268838603515 b/test/integration_new/commit/staging/expected/repo/.git_keep/objects/3a/e2df795236e3c84cb1faa242d3268838603515 new file mode 100644 index 0000000000000000000000000000000000000000..57198442f6ad83fffd10538fa84ecee53ee8f023 GIT binary patch literal 76 zcmV-S0JHyi0V^p=O;s?nWH2-^Ff%bx$gNDv%t>WfyEIKS{qBcl{tT_-wHN?jA|1xZp&@wy literal 0 HcmV?d00001 diff --git a/test/integration_new/commit/staging/expected/repo/.git_keep/objects/97/04090f88911a4083ef7d5907e38b9f45e43b16 b/test/integration_new/commit/staging/expected/repo/.git_keep/objects/97/04090f88911a4083ef7d5907e38b9f45e43b16 new file mode 100644 index 0000000000000000000000000000000000000000..c4b48a2f084a86a8022e805a2a31d1f398d03f12 GIT binary patch literal 31 ncmbZ) zn6uXA!uh{-mFs6Ru;o^!W#*&;^)Q44xw--=Nd`j&11=ut%=<@UuE?(B6Pd5S;+_40 c6`!V?-%w!kf3aV!s5SH6i^YNZaw2x~0L}(5CIA2c literal 0 HcmV?d00001 diff --git a/test/integration_new/commit/unstaged/expected/repo/.git_keep/info/exclude b/test/integration_new/commit/unstaged/expected/repo/.git_keep/info/exclude new file mode 100644 index 000000000..a5196d1be --- /dev/null +++ b/test/integration_new/commit/unstaged/expected/repo/.git_keep/info/exclude @@ -0,0 +1,6 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ diff --git a/test/integration_new/commit/unstaged/expected/repo/.git_keep/logs/HEAD b/test/integration_new/commit/unstaged/expected/repo/.git_keep/logs/HEAD new file mode 100644 index 000000000..c2cf4bcdd --- /dev/null +++ b/test/integration_new/commit/unstaged/expected/repo/.git_keep/logs/HEAD @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 d46951396fe8179592ec90aee0c0414fc0512fc5 CI 1669566705 +0100 commit (initial): my commit message diff --git a/test/integration_new/commit/unstaged/expected/repo/.git_keep/logs/refs/heads/master b/test/integration_new/commit/unstaged/expected/repo/.git_keep/logs/refs/heads/master new file mode 100644 index 000000000..c2cf4bcdd --- /dev/null +++ b/test/integration_new/commit/unstaged/expected/repo/.git_keep/logs/refs/heads/master @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 d46951396fe8179592ec90aee0c0414fc0512fc5 CI 1669566705 +0100 commit (initial): my commit message diff --git a/test/integration_new/commit/unstaged/expected/repo/.git_keep/objects/0c/4369dfc55cd41da90e149f2fa8ee3fc0a8f297 b/test/integration_new/commit/unstaged/expected/repo/.git_keep/objects/0c/4369dfc55cd41da90e149f2fa8ee3fc0a8f297 new file mode 100644 index 0000000000000000000000000000000000000000..79af4f45f798b3b47d9f64165886623304a60f87 GIT binary patch literal 51 zcmV-30L=e*0V^p=O;s>9VK6i>Ff%bx$gNDv%t>WfyEIKS{qBcl{t Date: Sun, 27 Nov 2022 18:24:00 +0100 Subject: [PATCH 5/6] commit integrations test with window name's assertion --- pkg/integration/tests/commit/staged.go | 11 ++++++----- pkg/integration/tests/commit/unstaged.go | 11 ++++++----- .../commit/staged/expected/repo/.git_keep/index | Bin 209 -> 137 bytes .../staged/expected/repo/.git_keep/logs/HEAD | 2 +- .../repo/.git_keep/logs/refs/heads/master | 2 +- .../2c/32ecbb77ddbbb0584ceae9316e290da7733327 | Bin 0 -> 51 bytes .../3a/e2df795236e3c84cb1faa242d3268838603515 | Bin 76 -> 0 bytes .../45/e15f2c1a4f47adeba3dbfc075e46a574f9b1fa | Bin 0 -> 48 bytes .../97/04090f88911a4083ef7d5907e38b9f45e43b16 | Bin 31 -> 0 bytes .../a0/a4dfd8937f66345c93ee7ebf5f85d53e05e9e8 | 2 ++ .../a4/de8e0658023fb43037b687b5052c1b5b2ab0c3 | Bin 0 -> 34 bytes .../ad/a5661567ddf0a64f589cad3cd0cffd7e79af99 | Bin 30 -> 0 bytes .../ef/3197feca3fdc5b9f0170f483c6ff138d5cf186 | 2 -- .../expected/repo/.git_keep/refs/heads/master | 2 +- .../commit/staged/expected/repo/myfile | 3 ++- .../expected/repo/.git_keep/COMMIT_EDITMSG | 1 - .../staging/expected/repo/.git_keep/FETCH_HEAD | 0 .../commit/staging/expected/repo/.git_keep/HEAD | 1 - .../staging/expected/repo/.git_keep/MERGE_RR | 0 .../staging/expected/repo/.git_keep/config | 12 ------------ .../staging/expected/repo/.git_keep/description | 1 - .../staging/expected/repo/.git_keep/index | Bin 209 -> 0 bytes .../expected/repo/.git_keep/info/exclude | 6 ------ .../staging/expected/repo/.git_keep/logs/HEAD | 1 - .../repo/.git_keep/logs/refs/heads/master | 1 - .../28/f8e24755d8792e66738e36f193949a68021709 | Bin 125 -> 0 bytes .../3a/e2df795236e3c84cb1faa242d3268838603515 | Bin 76 -> 0 bytes .../97/04090f88911a4083ef7d5907e38b9f45e43b16 | Bin 31 -> 0 bytes .../ad/a5661567ddf0a64f589cad3cd0cffd7e79af99 | Bin 30 -> 0 bytes .../expected/repo/.git_keep/refs/heads/master | 1 - .../commit/staging/expected/repo/myfile | 1 - .../commit/staging/expected/repo/myfile2 | 1 - .../unstaged/expected/repo/.git_keep/index | Bin 137 -> 137 bytes .../unstaged/expected/repo/.git_keep/logs/HEAD | 2 +- .../repo/.git_keep/logs/refs/heads/master | 2 +- .../00/e2463e8a06d3191bd825531e5dbf26bac22d6b | Bin 0 -> 31 bytes .../0c/4369dfc55cd41da90e149f2fa8ee3fc0a8f297 | Bin 51 -> 0 bytes .../10/9e5843c76c640d7075c2897b5720f1714df776 | 2 ++ .../ad/a5661567ddf0a64f589cad3cd0cffd7e79af99 | Bin 30 -> 0 bytes .../d4/6951396fe8179592ec90aee0c0414fc0512fc5 | Bin 124 -> 0 bytes .../e7/bcdb57454dacf229e5be8122bb27bb56d78dba | 1 + .../expected/repo/.git_keep/refs/heads/master | 2 +- .../commit/unstaged/expected/repo/myfile | 3 ++- 43 files changed, 27 insertions(+), 46 deletions(-) create mode 100644 test/integration_new/commit/staged/expected/repo/.git_keep/objects/2c/32ecbb77ddbbb0584ceae9316e290da7733327 delete mode 100644 test/integration_new/commit/staged/expected/repo/.git_keep/objects/3a/e2df795236e3c84cb1faa242d3268838603515 create mode 100644 test/integration_new/commit/staged/expected/repo/.git_keep/objects/45/e15f2c1a4f47adeba3dbfc075e46a574f9b1fa delete mode 100644 test/integration_new/commit/staged/expected/repo/.git_keep/objects/97/04090f88911a4083ef7d5907e38b9f45e43b16 create mode 100644 test/integration_new/commit/staged/expected/repo/.git_keep/objects/a0/a4dfd8937f66345c93ee7ebf5f85d53e05e9e8 create mode 100644 test/integration_new/commit/staged/expected/repo/.git_keep/objects/a4/de8e0658023fb43037b687b5052c1b5b2ab0c3 delete mode 100644 test/integration_new/commit/staged/expected/repo/.git_keep/objects/ad/a5661567ddf0a64f589cad3cd0cffd7e79af99 delete mode 100644 test/integration_new/commit/staged/expected/repo/.git_keep/objects/ef/3197feca3fdc5b9f0170f483c6ff138d5cf186 delete mode 100644 test/integration_new/commit/staging/expected/repo/.git_keep/COMMIT_EDITMSG delete mode 100644 test/integration_new/commit/staging/expected/repo/.git_keep/FETCH_HEAD delete mode 100644 test/integration_new/commit/staging/expected/repo/.git_keep/HEAD delete mode 100644 test/integration_new/commit/staging/expected/repo/.git_keep/MERGE_RR delete mode 100644 test/integration_new/commit/staging/expected/repo/.git_keep/config delete mode 100644 test/integration_new/commit/staging/expected/repo/.git_keep/description delete mode 100644 test/integration_new/commit/staging/expected/repo/.git_keep/index delete mode 100644 test/integration_new/commit/staging/expected/repo/.git_keep/info/exclude delete mode 100644 test/integration_new/commit/staging/expected/repo/.git_keep/logs/HEAD delete mode 100644 test/integration_new/commit/staging/expected/repo/.git_keep/logs/refs/heads/master delete mode 100644 test/integration_new/commit/staging/expected/repo/.git_keep/objects/28/f8e24755d8792e66738e36f193949a68021709 delete mode 100644 test/integration_new/commit/staging/expected/repo/.git_keep/objects/3a/e2df795236e3c84cb1faa242d3268838603515 delete mode 100644 test/integration_new/commit/staging/expected/repo/.git_keep/objects/97/04090f88911a4083ef7d5907e38b9f45e43b16 delete mode 100644 test/integration_new/commit/staging/expected/repo/.git_keep/objects/ad/a5661567ddf0a64f589cad3cd0cffd7e79af99 delete mode 100644 test/integration_new/commit/staging/expected/repo/.git_keep/refs/heads/master delete mode 100644 test/integration_new/commit/staging/expected/repo/myfile delete mode 100644 test/integration_new/commit/staging/expected/repo/myfile2 create mode 100644 test/integration_new/commit/unstaged/expected/repo/.git_keep/objects/00/e2463e8a06d3191bd825531e5dbf26bac22d6b delete mode 100644 test/integration_new/commit/unstaged/expected/repo/.git_keep/objects/0c/4369dfc55cd41da90e149f2fa8ee3fc0a8f297 create mode 100644 test/integration_new/commit/unstaged/expected/repo/.git_keep/objects/10/9e5843c76c640d7075c2897b5720f1714df776 delete mode 100644 test/integration_new/commit/unstaged/expected/repo/.git_keep/objects/ad/a5661567ddf0a64f589cad3cd0cffd7e79af99 delete mode 100644 test/integration_new/commit/unstaged/expected/repo/.git_keep/objects/d4/6951396fe8179592ec90aee0c0414fc0512fc5 create mode 100644 test/integration_new/commit/unstaged/expected/repo/.git_keep/objects/e7/bcdb57454dacf229e5be8122bb27bb56d78dba diff --git a/pkg/integration/tests/commit/staged.go b/pkg/integration/tests/commit/staged.go index 80de2bca9..715bc0eb2 100644 --- a/pkg/integration/tests/commit/staged.go +++ b/pkg/integration/tests/commit/staged.go @@ -6,21 +6,21 @@ import ( ) var Staged = NewIntegrationTest(NewIntegrationTestArgs{ - Description: "Staging a couple files, going in the staged files menu and committing", + Description: "Staging a couple files, going in the staged files menu, unstaging a line then committing", ExtraCmdArgs: "", Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { - shell.CreateFile("myfile", "myfile content") - shell.CreateFile("myfile2", "myfile2 content") + shell. + CreateFile("myfile", "myfile content\nwith a second line"). + CreateFile("myfile2", "myfile2 content") }, Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { assert.CommitCount(0) - input.PrimaryAction() - input.NextItem() input.PrimaryAction() input.Confirm() + input.PrimaryAction() input.PressKeys(keys.Files.CommitChanges) commitMessage := "my commit message" @@ -29,5 +29,6 @@ var Staged = NewIntegrationTest(NewIntegrationTestArgs{ assert.CommitCount(1) assert.MatchHeadCommitMessage(Equals(commitMessage)) + assert.CurrentWindowName("stagingSecondary") }, }) diff --git a/pkg/integration/tests/commit/unstaged.go b/pkg/integration/tests/commit/unstaged.go index 5dd396eec..aa8579e2b 100644 --- a/pkg/integration/tests/commit/unstaged.go +++ b/pkg/integration/tests/commit/unstaged.go @@ -6,20 +6,20 @@ import ( ) var Unstaged = NewIntegrationTest(NewIntegrationTestArgs{ - Description: "Staging a couple files, going in the unstaged files menu and committing", + Description: "Staging a couple files, going in the unstaged files menu, staging a line and committing", ExtraCmdArgs: "", Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { - shell.CreateFile("myfile", "myfile content") - shell.CreateFile("myfile2", "myfile2 content") + shell. + CreateFile("myfile", "myfile content\nwith a second line"). + CreateFile("myfile2", "myfile2 content") }, Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { assert.CommitCount(0) - input.PrimaryAction() - input.NextItem() input.Confirm() + input.PrimaryAction() input.PressKeys(keys.Files.CommitChanges) commitMessage := "my commit message" @@ -28,5 +28,6 @@ var Unstaged = NewIntegrationTest(NewIntegrationTestArgs{ assert.CommitCount(1) assert.MatchHeadCommitMessage(Equals(commitMessage)) + assert.CurrentWindowName("staging") }, }) diff --git a/test/integration_new/commit/staged/expected/repo/.git_keep/index b/test/integration_new/commit/staged/expected/repo/.git_keep/index index 193a6619c85c5c3d651b6fe2f70ca51ea7dfc7d7..6ca933f528d0ac98960957621bb5edbbdb829a4b 100644 GIT binary patch literal 137 zcmZ?q402{*U|<4bMj*xk8kZnTEV1eGDhZ)#%E7LM_QbFoM zf?QpJlq7?pf&rI~(VN}ncXw}y@OkypFi(?rd9ktjd@cJ837$3Ix4d5J9P%X6RFaWf F4FK=XAe#UH literal 209 zcmZ?q402{*U|<5_l14+ z26l)!MnFv=L9VVqN|M1y!GO!^(f!IGv&ScVHvU@VbXl##BEeL&@rKAx)%Wdxn-^KW N<+(l~ 1669566692 +0100 commit (initial): my commit message +0000000000000000000000000000000000000000 a0a4dfd8937f66345c93ee7ebf5f85d53e05e9e8 CI 1669569482 +0100 commit (initial): my commit message diff --git a/test/integration_new/commit/staged/expected/repo/.git_keep/logs/refs/heads/master b/test/integration_new/commit/staged/expected/repo/.git_keep/logs/refs/heads/master index 40d31f9ee..277243a2e 100644 --- a/test/integration_new/commit/staged/expected/repo/.git_keep/logs/refs/heads/master +++ b/test/integration_new/commit/staged/expected/repo/.git_keep/logs/refs/heads/master @@ -1 +1 @@ -0000000000000000000000000000000000000000 ef3197feca3fdc5b9f0170f483c6ff138d5cf186 CI 1669566692 +0100 commit (initial): my commit message +0000000000000000000000000000000000000000 a0a4dfd8937f66345c93ee7ebf5f85d53e05e9e8 CI 1669569482 +0100 commit (initial): my commit message diff --git a/test/integration_new/commit/staged/expected/repo/.git_keep/objects/2c/32ecbb77ddbbb0584ceae9316e290da7733327 b/test/integration_new/commit/staged/expected/repo/.git_keep/objects/2c/32ecbb77ddbbb0584ceae9316e290da7733327 new file mode 100644 index 0000000000000000000000000000000000000000..75197c7e913c978ccb4e12bcebe3e0bfb5d0a761 GIT binary patch literal 51 zcmbWfyEIKS{qBcl{tT_-wHN?jA|1xZp&@wy diff --git a/test/integration_new/commit/staged/expected/repo/.git_keep/objects/45/e15f2c1a4f47adeba3dbfc075e46a574f9b1fa b/test/integration_new/commit/staged/expected/repo/.git_keep/objects/45/e15f2c1a4f47adeba3dbfc075e46a574f9b1fa new file mode 100644 index 0000000000000000000000000000000000000000..8a26026cdeb2c107f8fd872a84da6573feb1d46b GIT binary patch literal 48 zcmV-00MGw;0ZYosPf{>8X2`8f%gjktNY2kINzE(aD$gv*P)JlLP6Z02DCA`3r2+sa Gd=7F6eH0J? literal 0 HcmV?d00001 diff --git a/test/integration_new/commit/staged/expected/repo/.git_keep/objects/97/04090f88911a4083ef7d5907e38b9f45e43b16 b/test/integration_new/commit/staged/expected/repo/.git_keep/objects/97/04090f88911a4083ef7d5907e38b9f45e43b16 deleted file mode 100644 index c4b48a2f084a86a8022e805a2a31d1f398d03f12..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 31 ncmbSW_Bm-0 \ No newline at end of file diff --git a/test/integration_new/commit/staged/expected/repo/.git_keep/objects/a4/de8e0658023fb43037b687b5052c1b5b2ab0c3 b/test/integration_new/commit/staged/expected/repo/.git_keep/objects/a4/de8e0658023fb43037b687b5052c1b5b2ab0c3 new file mode 100644 index 0000000000000000000000000000000000000000..d746db209b355034e77175036b466f51c7ccbd10 GIT binary patch literal 34 qcmbxm'Uԝ}M0 \ No newline at end of file diff --git a/test/integration_new/commit/staged/expected/repo/.git_keep/refs/heads/master b/test/integration_new/commit/staged/expected/repo/.git_keep/refs/heads/master index b44143ba4..8aa84085c 100644 --- a/test/integration_new/commit/staged/expected/repo/.git_keep/refs/heads/master +++ b/test/integration_new/commit/staged/expected/repo/.git_keep/refs/heads/master @@ -1 +1 @@ -ef3197feca3fdc5b9f0170f483c6ff138d5cf186 +a0a4dfd8937f66345c93ee7ebf5f85d53e05e9e8 diff --git a/test/integration_new/commit/staged/expected/repo/myfile b/test/integration_new/commit/staged/expected/repo/myfile index ada566156..45e15f2c1 100644 --- a/test/integration_new/commit/staged/expected/repo/myfile +++ b/test/integration_new/commit/staged/expected/repo/myfile @@ -1 +1,2 @@ -myfile content \ No newline at end of file +myfile content +with a second line \ No newline at end of file diff --git a/test/integration_new/commit/staging/expected/repo/.git_keep/COMMIT_EDITMSG b/test/integration_new/commit/staging/expected/repo/.git_keep/COMMIT_EDITMSG deleted file mode 100644 index 8a744b4fe..000000000 --- a/test/integration_new/commit/staging/expected/repo/.git_keep/COMMIT_EDITMSG +++ /dev/null @@ -1 +0,0 @@ -my commit message diff --git a/test/integration_new/commit/staging/expected/repo/.git_keep/FETCH_HEAD b/test/integration_new/commit/staging/expected/repo/.git_keep/FETCH_HEAD deleted file mode 100644 index e69de29bb..000000000 diff --git a/test/integration_new/commit/staging/expected/repo/.git_keep/HEAD b/test/integration_new/commit/staging/expected/repo/.git_keep/HEAD deleted file mode 100644 index cb089cd89..000000000 --- a/test/integration_new/commit/staging/expected/repo/.git_keep/HEAD +++ /dev/null @@ -1 +0,0 @@ -ref: refs/heads/master diff --git a/test/integration_new/commit/staging/expected/repo/.git_keep/MERGE_RR b/test/integration_new/commit/staging/expected/repo/.git_keep/MERGE_RR deleted file mode 100644 index e69de29bb..000000000 diff --git a/test/integration_new/commit/staging/expected/repo/.git_keep/config b/test/integration_new/commit/staging/expected/repo/.git_keep/config deleted file mode 100644 index 2b89b8630..000000000 --- a/test/integration_new/commit/staging/expected/repo/.git_keep/config +++ /dev/null @@ -1,12 +0,0 @@ -[core] - repositoryformatversion = 0 - filemode = true - bare = false - logallrefupdates = true -[user] - email = CI@example.com - name = CI -[commit] - gpgSign = false -[protocol "file"] - allow = always diff --git a/test/integration_new/commit/staging/expected/repo/.git_keep/description b/test/integration_new/commit/staging/expected/repo/.git_keep/description deleted file mode 100644 index 498b267a8..000000000 --- a/test/integration_new/commit/staging/expected/repo/.git_keep/description +++ /dev/null @@ -1 +0,0 @@ -Unnamed repository; edit this file 'description' to name the repository. diff --git a/test/integration_new/commit/staging/expected/repo/.git_keep/index b/test/integration_new/commit/staging/expected/repo/.git_keep/index deleted file mode 100644 index 3c44f83b5778461cfcfffb754547d358a3777c52..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 209 zcmZ?q402{*U|<5_ 1669566470 +0100 commit (initial): my commit message diff --git a/test/integration_new/commit/staging/expected/repo/.git_keep/logs/refs/heads/master b/test/integration_new/commit/staging/expected/repo/.git_keep/logs/refs/heads/master deleted file mode 100644 index 910749aff..000000000 --- a/test/integration_new/commit/staging/expected/repo/.git_keep/logs/refs/heads/master +++ /dev/null @@ -1 +0,0 @@ -0000000000000000000000000000000000000000 28f8e24755d8792e66738e36f193949a68021709 CI 1669566470 +0100 commit (initial): my commit message diff --git a/test/integration_new/commit/staging/expected/repo/.git_keep/objects/28/f8e24755d8792e66738e36f193949a68021709 b/test/integration_new/commit/staging/expected/repo/.git_keep/objects/28/f8e24755d8792e66738e36f193949a68021709 deleted file mode 100644 index cc6a8ec738cdbc068ec2dd881effc185383097a4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 125 zcmV-@0D}K`0ga783c@fD06pgwdlzJrO|~hB2tD-~Yr0jzCDKOF-&^nlUWXZ`RI_^n zpLo|6RUpwY&0U`Yu~NygT>LB&Vwfm!&XgG``Q+r)ZgqiSgyS%t^)2>%=%G|QfoJX$ fbLsUw@K4Kb!Q*=C1AR)a#i;Qvz{;YtX(^% diff --git a/test/integration_new/commit/staging/expected/repo/.git_keep/objects/3a/e2df795236e3c84cb1faa242d3268838603515 b/test/integration_new/commit/staging/expected/repo/.git_keep/objects/3a/e2df795236e3c84cb1faa242d3268838603515 deleted file mode 100644 index 57198442f6ad83fffd10538fa84ecee53ee8f023..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 76 zcmV-S0JHyi0V^p=O;s?nWH2-^Ff%bx$gNDv%t>WfyEIKS{qBcl{tT_-wHN?jA|1xZp&@wy diff --git a/test/integration_new/commit/staging/expected/repo/.git_keep/objects/97/04090f88911a4083ef7d5907e38b9f45e43b16 b/test/integration_new/commit/staging/expected/repo/.git_keep/objects/97/04090f88911a4083ef7d5907e38b9f45e43b16 deleted file mode 100644 index c4b48a2f084a86a8022e805a2a31d1f398d03f12..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 31 ncmbZ) zn6uXA!uh{-mFs6Ru;o^!W#*&;^)Q44xw--=Nd`j&11=ut%=<@UuE?(B6Pd5S;+_40 c6`!V?-%w!kf3aV!s5SH6i^YNZaw2x~0L}(5CIA2c diff --git a/test/integration_new/commit/unstaged/expected/repo/.git_keep/logs/HEAD b/test/integration_new/commit/unstaged/expected/repo/.git_keep/logs/HEAD index c2cf4bcdd..2889f13ff 100644 --- a/test/integration_new/commit/unstaged/expected/repo/.git_keep/logs/HEAD +++ b/test/integration_new/commit/unstaged/expected/repo/.git_keep/logs/HEAD @@ -1 +1 @@ -0000000000000000000000000000000000000000 d46951396fe8179592ec90aee0c0414fc0512fc5 CI 1669566705 +0100 commit (initial): my commit message +0000000000000000000000000000000000000000 109e5843c76c640d7075c2897b5720f1714df776 CI 1669569750 +0100 commit (initial): my commit message diff --git a/test/integration_new/commit/unstaged/expected/repo/.git_keep/logs/refs/heads/master b/test/integration_new/commit/unstaged/expected/repo/.git_keep/logs/refs/heads/master index c2cf4bcdd..2889f13ff 100644 --- a/test/integration_new/commit/unstaged/expected/repo/.git_keep/logs/refs/heads/master +++ b/test/integration_new/commit/unstaged/expected/repo/.git_keep/logs/refs/heads/master @@ -1 +1 @@ -0000000000000000000000000000000000000000 d46951396fe8179592ec90aee0c0414fc0512fc5 CI 1669566705 +0100 commit (initial): my commit message +0000000000000000000000000000000000000000 109e5843c76c640d7075c2897b5720f1714df776 CI 1669569750 +0100 commit (initial): my commit message diff --git a/test/integration_new/commit/unstaged/expected/repo/.git_keep/objects/00/e2463e8a06d3191bd825531e5dbf26bac22d6b b/test/integration_new/commit/unstaged/expected/repo/.git_keep/objects/00/e2463e8a06d3191bd825531e5dbf26bac22d6b new file mode 100644 index 0000000000000000000000000000000000000000..5bdcb3903da65756ce19935b40720e2a49776c17 GIT binary patch literal 31 ncmb9VK6i>Ff%bx$gNDv%t>WfyEIKS{qBcl{t Date: Mon, 28 Nov 2022 19:40:29 +0100 Subject: [PATCH 6/6] integration tests for commit without pre-commit hooks in staging files menu --- .../tests/commit/staged_without_hooks.go | 34 ++++++++++++++++++ .../tests/commit/unstaged_without_hooks.go | 33 +++++++++++++++++ pkg/integration/tests/tests.go | 2 ++ .../expected/repo/.git_keep/COMMIT_EDITMSG | 1 + .../expected/repo/.git_keep/FETCH_HEAD | 0 .../expected/repo/.git_keep/HEAD | 1 + .../expected/repo/.git_keep/MERGE_RR | 0 .../expected/repo/.git_keep/config | 12 +++++++ .../expected/repo/.git_keep/description | 1 + .../expected/repo/.git_keep/index | Bin 0 -> 137 bytes .../expected/repo/.git_keep/info/exclude | 6 ++++ .../expected/repo/.git_keep/logs/HEAD | 1 + .../repo/.git_keep/logs/refs/heads/master | 1 + .../2c/32ecbb77ddbbb0584ceae9316e290da7733327 | Bin 0 -> 51 bytes .../45/e15f2c1a4f47adeba3dbfc075e46a574f9b1fa | Bin 0 -> 48 bytes .../4a/33e6274dd3bc702442966e6774e7688bb7af64 | Bin 0 -> 129 bytes .../a4/de8e0658023fb43037b687b5052c1b5b2ab0c3 | Bin 0 -> 34 bytes .../expected/repo/.git_keep/refs/heads/master | 1 + .../staged_without_hooks/expected/repo/myfile | 2 ++ .../expected/repo/myfile2 | 1 + .../expected/repo/.git_keep/COMMIT_EDITMSG | 1 + .../expected/repo/.git_keep/FETCH_HEAD | 0 .../expected/repo/.git_keep/HEAD | 1 + .../expected/repo/.git_keep/MERGE_RR | 0 .../expected/repo/.git_keep/config | 12 +++++++ .../expected/repo/.git_keep/description | 1 + .../expected/repo/.git_keep/index | Bin 0 -> 137 bytes .../expected/repo/.git_keep/info/exclude | 6 ++++ .../expected/repo/.git_keep/logs/HEAD | 1 + .../repo/.git_keep/logs/refs/heads/master | 1 + .../00/e2463e8a06d3191bd825531e5dbf26bac22d6b | Bin 0 -> 31 bytes .../e7/bcdb57454dacf229e5be8122bb27bb56d78dba | 1 + .../eb/c03af0e92eb50f1ab1dec0697880ed9da9b02d | Bin 0 -> 129 bytes .../expected/repo/.git_keep/refs/heads/master | 1 + .../expected/repo/myfile | 2 ++ .../expected/repo/myfile2 | 1 + 36 files changed, 124 insertions(+) create mode 100644 pkg/integration/tests/commit/staged_without_hooks.go create mode 100644 pkg/integration/tests/commit/unstaged_without_hooks.go create mode 100644 test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/COMMIT_EDITMSG create mode 100644 test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/FETCH_HEAD create mode 100644 test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/HEAD create mode 100644 test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/MERGE_RR create mode 100644 test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/config create mode 100644 test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/description create mode 100644 test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/index create mode 100644 test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/info/exclude create mode 100644 test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/logs/HEAD create mode 100644 test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/logs/refs/heads/master create mode 100644 test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/objects/2c/32ecbb77ddbbb0584ceae9316e290da7733327 create mode 100644 test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/objects/45/e15f2c1a4f47adeba3dbfc075e46a574f9b1fa create mode 100644 test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/objects/4a/33e6274dd3bc702442966e6774e7688bb7af64 create mode 100644 test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/objects/a4/de8e0658023fb43037b687b5052c1b5b2ab0c3 create mode 100644 test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/refs/heads/master create mode 100644 test/integration_new/commit/staged_without_hooks/expected/repo/myfile create mode 100644 test/integration_new/commit/staged_without_hooks/expected/repo/myfile2 create mode 100644 test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/COMMIT_EDITMSG create mode 100644 test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/FETCH_HEAD create mode 100644 test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/HEAD create mode 100644 test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/MERGE_RR create mode 100644 test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/config create mode 100644 test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/description create mode 100644 test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/index create mode 100644 test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/info/exclude create mode 100644 test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/logs/HEAD create mode 100644 test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/logs/refs/heads/master create mode 100644 test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/objects/00/e2463e8a06d3191bd825531e5dbf26bac22d6b create mode 100644 test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/objects/e7/bcdb57454dacf229e5be8122bb27bb56d78dba create mode 100644 test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/objects/eb/c03af0e92eb50f1ab1dec0697880ed9da9b02d create mode 100644 test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/refs/heads/master create mode 100644 test/integration_new/commit/unstaged_without_hooks/expected/repo/myfile create mode 100644 test/integration_new/commit/unstaged_without_hooks/expected/repo/myfile2 diff --git a/pkg/integration/tests/commit/staged_without_hooks.go b/pkg/integration/tests/commit/staged_without_hooks.go new file mode 100644 index 000000000..e1466f8d2 --- /dev/null +++ b/pkg/integration/tests/commit/staged_without_hooks.go @@ -0,0 +1,34 @@ +package commit + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var StagedWithoutHooks = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Staging a couple files, going in the staged files menu, unstaging a line then committing without pre-commit hooks", + ExtraCmdArgs: "", + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell. + CreateFile("myfile", "myfile content\nwith a second line"). + CreateFile("myfile2", "myfile2 content") + }, + Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { + assert.CommitCount(0) + + input.PrimaryAction() + input.Confirm() + input.PrimaryAction() + input.PressKeys(keys.Files.CommitChangesWithoutHook) + + commitMessage := "my commit message" + input.Type(commitMessage) + input.Confirm() + + assert.CommitCount(1) + assert.MatchHeadCommitMessage(Equals("WIP" + commitMessage)) + assert.CurrentWindowName("stagingSecondary") + }, +}) diff --git a/pkg/integration/tests/commit/unstaged_without_hooks.go b/pkg/integration/tests/commit/unstaged_without_hooks.go new file mode 100644 index 000000000..442316f60 --- /dev/null +++ b/pkg/integration/tests/commit/unstaged_without_hooks.go @@ -0,0 +1,33 @@ +package commit + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var UnstagedWithoutHooks = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Staging a couple files, going in the unstaged files menu, staging a line and committing without pre-commit hooks", + ExtraCmdArgs: "", + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell. + CreateFile("myfile", "myfile content\nwith a second line"). + CreateFile("myfile2", "myfile2 content") + }, + Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { + assert.CommitCount(0) + + input.Confirm() + input.PrimaryAction() + input.PressKeys(keys.Files.CommitChangesWithoutHook) + + commitMessage := "my commit message" + input.Type(commitMessage) + input.Confirm() + + assert.CommitCount(1) + assert.MatchHeadCommitMessage(Equals("WIP" + commitMessage)) + assert.CurrentWindowName("staging") + }, +}) diff --git a/pkg/integration/tests/tests.go b/pkg/integration/tests/tests.go index 9b654ad80..6c4f60026 100644 --- a/pkg/integration/tests/tests.go +++ b/pkg/integration/tests/tests.go @@ -38,6 +38,8 @@ var tests = []*components.IntegrationTest{ commit.NewBranch, commit.Staged, commit.Unstaged, + commit.StagedWithoutHooks, + commit.UnstagedWithoutHooks, custom_commands.Basic, custom_commands.FormPrompts, custom_commands.MenuFromCommand, diff --git a/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/COMMIT_EDITMSG b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/COMMIT_EDITMSG new file mode 100644 index 000000000..4a4f03e0a --- /dev/null +++ b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/COMMIT_EDITMSG @@ -0,0 +1 @@ +WIPmy commit message diff --git a/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/FETCH_HEAD b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/FETCH_HEAD new file mode 100644 index 000000000..e69de29bb diff --git a/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/HEAD b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/MERGE_RR b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/MERGE_RR new file mode 100644 index 000000000..e69de29bb diff --git a/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/config b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/config new file mode 100644 index 000000000..2b89b8630 --- /dev/null +++ b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/config @@ -0,0 +1,12 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true +[user] + email = CI@example.com + name = CI +[commit] + gpgSign = false +[protocol "file"] + allow = always diff --git a/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/description b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/description new file mode 100644 index 000000000..498b267a8 --- /dev/null +++ b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/index b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/index new file mode 100644 index 0000000000000000000000000000000000000000..6ca933f528d0ac98960957621bb5edbbdb829a4b GIT binary patch literal 137 zcmZ?q402{*U|<4bMj*xk8kZnTEV1eGDhZ)#%E7LM_QbFoM zf?QpJlq7?pf&rI~(VN}ncXw}y@OkypFi(?rd9ktjd@cJ837$3Ix4d5J9P%X6RFaWf F4FK=XAe#UH literal 0 HcmV?d00001 diff --git a/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/info/exclude b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/info/exclude new file mode 100644 index 000000000..a5196d1be --- /dev/null +++ b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/info/exclude @@ -0,0 +1,6 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ diff --git a/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/logs/HEAD b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/logs/HEAD new file mode 100644 index 000000000..1c6b9a7b2 --- /dev/null +++ b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/logs/HEAD @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 4a33e6274dd3bc702442966e6774e7688bb7af64 CI 1669660775 +0100 commit (initial): WIPmy commit message diff --git a/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/logs/refs/heads/master b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/logs/refs/heads/master new file mode 100644 index 000000000..1c6b9a7b2 --- /dev/null +++ b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/logs/refs/heads/master @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 4a33e6274dd3bc702442966e6774e7688bb7af64 CI 1669660775 +0100 commit (initial): WIPmy commit message diff --git a/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/objects/2c/32ecbb77ddbbb0584ceae9316e290da7733327 b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/objects/2c/32ecbb77ddbbb0584ceae9316e290da7733327 new file mode 100644 index 0000000000000000000000000000000000000000..75197c7e913c978ccb4e12bcebe3e0bfb5d0a761 GIT binary patch literal 51 zcmb8X2`8f%gjktNY2kINzE(aD$gv*P)JlLP6Z02DCA`3r2+sa Gd=7F6eH0J? literal 0 HcmV?d00001 diff --git a/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/objects/4a/33e6274dd3bc702442966e6774e7688bb7af64 b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/objects/4a/33e6274dd3bc702442966e6774e7688bb7af64 new file mode 100644 index 0000000000000000000000000000000000000000..90e89ac27dd35c72948602d26ababbac5f4db72e GIT binary patch literal 129 zcmV-{0Dk{?0ga8j3IZ_@0Il;C+Y7QuOxD052Un%Dv(95t!6kB+1O0ms`~llxhABoYT$Vhxv^iE7O`qdOf7Ck|G7HUVoQvep_>Y3=tm!xUkd;>hnLuO}Z$lQU@V jgZD_}V2>J6ZFHM-{!>@ic##kMDiB_lbYt}ez#lQ!Y$iHP literal 0 HcmV?d00001 diff --git a/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/objects/a4/de8e0658023fb43037b687b5052c1b5b2ab0c3 b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/objects/a4/de8e0658023fb43037b687b5052c1b5b2ab0c3 new file mode 100644 index 0000000000000000000000000000000000000000..d746db209b355034e77175036b466f51c7ccbd10 GIT binary patch literal 34 qcmb 1669660788 +0100 commit (initial): WIPmy commit message diff --git a/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/logs/refs/heads/master b/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/logs/refs/heads/master new file mode 100644 index 000000000..59e73348a --- /dev/null +++ b/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/logs/refs/heads/master @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 ebc03af0e92eb50f1ab1dec0697880ed9da9b02d CI 1669660788 +0100 commit (initial): WIPmy commit message diff --git a/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/objects/00/e2463e8a06d3191bd825531e5dbf26bac22d6b b/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/objects/00/e2463e8a06d3191bd825531e5dbf26bac22d6b new file mode 100644 index 0000000000000000000000000000000000000000..5bdcb3903da65756ce19935b40720e2a49776c17 GIT binary patch literal 31 ncmboYU3r&0<1h-1y=YHegB4#rv{>xs}+A1Y;)-~HZZm=YYObmBG3>&g4l