summaryrefslogtreecommitdiffstats
path: root/pkg/gui/controllers/helpers/patch_building_helper.go
blob: efb8ec671ae4edb4f726e01e500a8251c24a92fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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
}