summaryrefslogtreecommitdiffstats
path: root/pkg/commands
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2023-09-18 10:50:07 +0200
committerStefan Haller <stefan@haller-berlin.de>2023-09-18 10:50:19 +0200
commit70bfeddc907037d1aa6ae9fc869441f3429c388a (patch)
tree2666e3af174f8482559a00ef22567da66c3fec8e /pkg/commands
parente2a966443bcc4c71d6c83f1bee90288c22c57ddb (diff)
Add StatusCommands.IsInNormalRebase and IsInInteractiveRebase
... and implement RebaseMode in terms of these.
Diffstat (limited to 'pkg/commands')
-rw-r--r--pkg/commands/git_commands/status.go23
1 files changed, 14 insertions, 9 deletions
diff --git a/pkg/commands/git_commands/status.go b/pkg/commands/git_commands/status.go
index 784ddb424..65b29deef 100644
--- a/pkg/commands/git_commands/status.go
+++ b/pkg/commands/git_commands/status.go
@@ -25,19 +25,16 @@ func NewStatusCommands(
// RebaseMode returns "" for non-rebase mode, "normal" for normal rebase
// and "interactive" for interactive rebase
func (self *StatusCommands) RebaseMode() (enums.RebaseMode, error) {
- exists, err := self.os.FileExists(filepath.Join(self.repoPaths.WorktreeGitDirPath(), "rebase-apply"))
- if err != nil {
- return enums.REBASE_MODE_NONE, err
- }
- if exists {
+ ok, err := self.IsInNormalRebase()
+ if err == nil && ok {
return enums.REBASE_MODE_NORMAL, nil
}
- exists, err = self.os.FileExists(filepath.Join(self.repoPaths.WorktreeGitDirPath(), "rebase-merge"))
- if exists {
+ ok, err = self.IsInInteractiveRebase()
+ if err == nil && ok {
return enums.REBASE_MODE_INTERACTIVE, err
- } else {
- return enums.REBASE_MODE_NONE, err
}
+
+ return enums.REBASE_MODE_NONE, err
}
func (self *StatusCommands) WorkingTreeState() enums.RebaseMode {
@@ -68,6 +65,14 @@ func IsBareRepo(osCommand *oscommands.OSCommand) (bool, error) {
return strconv.ParseBool(strings.TrimSpace(res))
}
+func (self *StatusCommands) IsInNormalRebase() (bool, error) {
+ return self.os.FileExists(filepath.Join(self.repoPaths.WorktreeGitDirPath(), "rebase-apply"))
+}
+
+func (self *StatusCommands) IsInInteractiveRebase() (bool, error) {
+ return self.os.FileExists(filepath.Join(self.repoPaths.WorktreeGitDirPath(), "rebase-merge"))
+}
+
// IsInMergeState states whether we are still mid-merge
func (self *StatusCommands) IsInMergeState() (bool, error) {
return self.os.FileExists(filepath.Join(self.repoPaths.WorktreeGitDirPath(), "MERGE_HEAD"))