summaryrefslogtreecommitdiffstats
path: root/pkg/commands/git_commands/status.go
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2023-07-12 08:47:50 +0200
committerStefan Haller <stefan@haller-berlin.de>2023-07-31 08:34:01 +0200
commit092d5dd608e997ea8be0aeda03be166987a0ca7b (patch)
tree4501e5091ac3215bf53804a38a4c78dd6d935548 /pkg/commands/git_commands/status.go
parente9bbd816de073d4d9250af2aa16876eec54e6de3 (diff)
Add CheckedOutBranch to Model struct
Diffstat (limited to 'pkg/commands/git_commands/status.go')
-rw-r--r--pkg/commands/git_commands/status.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/pkg/commands/git_commands/status.go b/pkg/commands/git_commands/status.go
index 13ff02cc0..784ddb424 100644
--- a/pkg/commands/git_commands/status.go
+++ b/pkg/commands/git_commands/status.go
@@ -1,6 +1,7 @@
package git_commands
import (
+ "os"
"path/filepath"
"strconv"
"strings"
@@ -71,3 +72,14 @@ func IsBareRepo(osCommand *oscommands.OSCommand) (bool, error) {
func (self *StatusCommands) IsInMergeState() (bool, error) {
return self.os.FileExists(filepath.Join(self.repoPaths.WorktreeGitDirPath(), "MERGE_HEAD"))
}
+
+// Full ref (e.g. "refs/heads/mybranch") of the branch that is currently
+// being rebased, or empty string when we're not in a rebase
+func (self *StatusCommands) BranchBeingRebased() string {
+ for _, dir := range []string{"rebase-merge", "rebase-apply"} {
+ if bytesContent, err := os.ReadFile(filepath.Join(self.repoPaths.WorktreeGitDirPath(), dir, "head-name")); err == nil {
+ return strings.TrimSpace(string(bytesContent))
+ }
+ }
+ return ""
+}