summaryrefslogtreecommitdiffstats
path: root/pkg/gui/controllers/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/gui/controllers/helpers')
-rw-r--r--pkg/gui/controllers/helpers/helpers.go2
-rw-r--r--pkg/gui/controllers/helpers/patch_building_helper.go33
2 files changed, 35 insertions, 0 deletions
diff --git a/pkg/gui/controllers/helpers/helpers.go b/pkg/gui/controllers/helpers/helpers.go
index 2ca4fbd40..2a7c43ff0 100644
--- a/pkg/gui/controllers/helpers/helpers.go
+++ b/pkg/gui/controllers/helpers/helpers.go
@@ -10,6 +10,7 @@ type Helpers struct {
MergeAndRebase *MergeAndRebaseHelper
CherryPick *CherryPickHelper
Host *HostHelper
+ PatchBuilding *PatchBuildingHelper
}
func NewStubHelpers() *Helpers {
@@ -23,5 +24,6 @@ func NewStubHelpers() *Helpers {
MergeAndRebase: &MergeAndRebaseHelper{},
CherryPick: &CherryPickHelper{},
Host: &HostHelper{},
+ PatchBuilding: &PatchBuildingHelper{},
}
}
diff --git a/pkg/gui/controllers/helpers/patch_building_helper.go b/pkg/gui/controllers/helpers/patch_building_helper.go
new file mode 100644
index 000000000..efb8ec671
--- /dev/null
+++ b/pkg/gui/controllers/helpers/patch_building_helper.go
@@ -0,0 +1,33 @@
+package helpers
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/commands"
+ "github.com/jesseduffield/lazygit/pkg/commands/types/enums"
+ "github.com/jesseduffield/lazygit/pkg/gui/types"
+)
+
+type IPatchBuildingHelper interface {
+ ValidateNormalWorkingTreeState() (bool, error)
+}
+
+type PatchBuildingHelper struct {
+ c *types.HelperCommon
+ git *commands.GitCommand
+}
+
+func NewPatchBuildingHelper(
+ c *types.HelperCommon,
+ git *commands.GitCommand,
+) *PatchBuildingHelper {
+ return &PatchBuildingHelper{
+ c: c,
+ git: git,
+ }
+}
+
+func (self *PatchBuildingHelper) ValidateNormalWorkingTreeState() (bool, error) {
+ if self.git.Status.WorkingTreeState() != enums.REBASE_MODE_NONE {
+ return false, self.c.ErrorMsg(self.c.Tr.CantPatchWhileRebasingError)
+ }
+ return true, nil
+}