diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-06-05 15:56:50 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-06-06 09:12:49 +1000 |
commit | 9fdf92b226032d39503dbf40ef931d5d017b4235 (patch) | |
tree | 469a401c8b7df10d2ccb7f2b6ba59607c2029042 /pkg/commands/models | |
parent | 93bf691fd66cfd19702db2a674c73fbefc244467 (diff) |
more refactoring
WIP
WIP
Diffstat (limited to 'pkg/commands/models')
-rw-r--r-- | pkg/commands/models/branch.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/pkg/commands/models/branch.go b/pkg/commands/models/branch.go index c95e335f9..3b8268bff 100644 --- a/pkg/commands/models/branch.go +++ b/pkg/commands/models/branch.go @@ -24,3 +24,26 @@ func (b *Branch) ID() string { func (b *Branch) Description() string { return b.RefName() } + +// this method does not consider the case where the git config states that a branch is tracking the config. +// The Pullables value here is based on whether or not we saw an upstream when doing `git branch` +func (b *Branch) IsTrackingRemote() bool { + return b.IsRealBranch() && b.Pullables != "?" +} + +func (b *Branch) MatchesUpstream() bool { + return b.IsRealBranch() && b.Pushables == "0" && b.Pullables == "0" +} + +func (b *Branch) HasCommitsToPush() bool { + return b.IsRealBranch() && b.Pushables != "0" +} + +func (b *Branch) HasCommitsToPull() bool { + return b.IsRealBranch() && b.Pullables != "0" +} + +// for when we're in a detached head state +func (b *Branch) IsRealBranch() bool { + return b.Pushables != "" && b.Pullables != "" +} |