summaryrefslogtreecommitdiffstats
path: root/pkg/gui/context/branches_context.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/gui/context/branches_context.go')
-rw-r--r--pkg/gui/context/branches_context.go32
1 files changed, 21 insertions, 11 deletions
diff --git a/pkg/gui/context/branches_context.go b/pkg/gui/context/branches_context.go
index a3e404fdb..f0d356a15 100644
--- a/pkg/gui/context/branches_context.go
+++ b/pkg/gui/context/branches_context.go
@@ -11,22 +11,21 @@ type BranchesContext struct {
*ListContextTrait
}
-var _ types.IListContext = (*BranchesContext)(nil)
+var (
+ _ types.IListContext = (*BranchesContext)(nil)
+ _ types.DiffableContext = (*BranchesContext)(nil)
+)
func NewBranchesContext(
getModel func() []*models.Branch,
view *gocui.View,
getDisplayStrings func(startIdx int, length int) [][]string,
- onFocus func(types.OnFocusOpts) error,
- onRenderToMain func() error,
- onFocusLost func(opts types.OnFocusLostOpts) error,
-
c *types.HelperCommon,
) *BranchesContext {
viewModel := NewBasicViewModel(getModel)
- return &BranchesContext{
+ self := &BranchesContext{
BasicViewModel: viewModel,
ListContextTrait: &ListContextTrait{
Context: NewSimpleContext(NewBaseContext(NewBaseContextOpts{
@@ -35,16 +34,14 @@ func NewBranchesContext(
Key: LOCAL_BRANCHES_CONTEXT_KEY,
Kind: types.SIDE_CONTEXT,
Focusable: true,
- }), ContextCallbackOpts{
- OnFocus: onFocus,
- OnFocusLost: onFocusLost,
- OnRenderToMain: onRenderToMain,
- }),
+ }), ContextCallbackOpts{}),
list: viewModel,
getDisplayStrings: getDisplayStrings,
c: c,
},
}
+
+ return self
}
func (self *BranchesContext) GetSelectedItemId() string {
@@ -63,3 +60,16 @@ func (self *BranchesContext) GetSelectedRef() types.Ref {
}
return branch
}
+
+func (self *BranchesContext) GetDiffTerminals() []string {
+ // for our local branches we want to include both the branch and its upstream
+ branch := self.GetSelected()
+ if branch != nil {
+ names := []string{branch.ID()}
+ if branch.IsTrackingRemote() {
+ names = append(names, branch.ID()+"@{u}")
+ }
+ return names
+ }
+ return nil
+}