mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-30 03:23:08 +03:00
Move types/enums/enums.go to working_tree_state.go
It looks like enums.go was supposed to be file that collects a bunch of enums, but actually there's only one in there, and since it has methods, it deserves to be in a file of its own, named after the type.
This commit is contained in:
63
pkg/commands/models/working_tree_state.go
Normal file
63
pkg/commands/models/working_tree_state.go
Normal file
@ -0,0 +1,63 @@
|
||||
package models
|
||||
|
||||
import "github.com/jesseduffield/lazygit/pkg/i18n"
|
||||
|
||||
type WorkingTreeState int
|
||||
|
||||
const (
|
||||
// this means we're neither rebasing nor merging
|
||||
WORKING_TREE_STATE_NONE WorkingTreeState = iota
|
||||
WORKING_TREE_STATE_REBASING
|
||||
WORKING_TREE_STATE_MERGING
|
||||
)
|
||||
|
||||
func (self WorkingTreeState) IsMerging() bool {
|
||||
return self == WORKING_TREE_STATE_MERGING
|
||||
}
|
||||
|
||||
func (self WorkingTreeState) IsRebasing() bool {
|
||||
return self == WORKING_TREE_STATE_REBASING
|
||||
}
|
||||
|
||||
func (self WorkingTreeState) Title(tr *i18n.TranslationSet) string {
|
||||
switch self {
|
||||
case WORKING_TREE_STATE_REBASING:
|
||||
return tr.RebasingStatus
|
||||
case WORKING_TREE_STATE_MERGING:
|
||||
return tr.MergingStatus
|
||||
default:
|
||||
// should never actually display this
|
||||
return "none"
|
||||
}
|
||||
}
|
||||
|
||||
func (self WorkingTreeState) LowerCaseTitle(tr *i18n.TranslationSet) string {
|
||||
switch self {
|
||||
case WORKING_TREE_STATE_REBASING:
|
||||
return tr.LowercaseRebasingStatus
|
||||
case WORKING_TREE_STATE_MERGING:
|
||||
return tr.LowercaseMergingStatus
|
||||
default:
|
||||
// should never actually display this
|
||||
return "none"
|
||||
}
|
||||
}
|
||||
|
||||
func (self WorkingTreeState) OptionsMenuTitle(tr *i18n.TranslationSet) string {
|
||||
if self == WORKING_TREE_STATE_MERGING {
|
||||
return tr.MergeOptionsTitle
|
||||
}
|
||||
return tr.RebaseOptionsTitle
|
||||
}
|
||||
|
||||
func (self WorkingTreeState) CommandName() string {
|
||||
switch self {
|
||||
case WORKING_TREE_STATE_MERGING:
|
||||
return "merge"
|
||||
case WORKING_TREE_STATE_REBASING:
|
||||
return "rebase"
|
||||
default:
|
||||
// shouldn't be possible to land here
|
||||
return ""
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user