mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-28 16:02:01 +03:00
Store Common instead of just the list of configured main branches in MainBranches
This will make it possible to change the configured main branches at runtime. We'll support this in the next commit.
This commit is contained in:
@ -324,7 +324,7 @@ func TestGetCommits(t *testing.T) {
|
|||||||
|
|
||||||
common.UserConfig().Git.MainBranches = scenario.mainBranches
|
common.UserConfig().Git.MainBranches = scenario.mainBranches
|
||||||
opts := scenario.opts
|
opts := scenario.opts
|
||||||
opts.MainBranches = NewMainBranches(scenario.mainBranches, cmd)
|
opts.MainBranches = NewMainBranches(common, cmd)
|
||||||
commits, err := builder.GetCommits(opts)
|
commits, err := builder.GetCommits(opts)
|
||||||
|
|
||||||
assert.Equal(t, scenario.expectedCommits, commits)
|
assert.Equal(t, scenario.expectedCommits, commits)
|
||||||
|
@ -5,17 +5,17 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/common"
|
||||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||||
"github.com/samber/lo"
|
"github.com/samber/lo"
|
||||||
"github.com/sasha-s/go-deadlock"
|
"github.com/sasha-s/go-deadlock"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MainBranches struct {
|
type MainBranches struct {
|
||||||
// List of main branches configured by the user. Just the bare names.
|
c *common.Common
|
||||||
configuredMainBranches []string
|
// Which of the configured main branches actually exist in the repository. Full
|
||||||
// Which of these actually exist in the repository. Full ref names, and it
|
// ref names, and it could be either "refs/heads/..." or "refs/remotes/origin/..."
|
||||||
// could be either "refs/heads/..." or "refs/remotes/origin/..." depending
|
// depending on which one exists for a given bare name.
|
||||||
// on which one exists for a given bare name.
|
|
||||||
existingMainBranches []string
|
existingMainBranches []string
|
||||||
|
|
||||||
cmd oscommands.ICmdObjBuilder
|
cmd oscommands.ICmdObjBuilder
|
||||||
@ -23,14 +23,14 @@ type MainBranches struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewMainBranches(
|
func NewMainBranches(
|
||||||
configuredMainBranches []string,
|
cmn *common.Common,
|
||||||
cmd oscommands.ICmdObjBuilder,
|
cmd oscommands.ICmdObjBuilder,
|
||||||
) *MainBranches {
|
) *MainBranches {
|
||||||
return &MainBranches{
|
return &MainBranches{
|
||||||
configuredMainBranches: configuredMainBranches,
|
c: cmn,
|
||||||
existingMainBranches: nil,
|
existingMainBranches: nil,
|
||||||
cmd: cmd,
|
cmd: cmd,
|
||||||
mutex: &deadlock.Mutex{},
|
mutex: &deadlock.Mutex{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,9 +75,10 @@ func (self *MainBranches) determineMainBranches() []string {
|
|||||||
var existingBranches []string
|
var existingBranches []string
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
|
|
||||||
existingBranches = make([]string, len(self.configuredMainBranches))
|
configuredMainBranches := self.c.UserConfig().Git.MainBranches
|
||||||
|
existingBranches = make([]string, len(configuredMainBranches))
|
||||||
|
|
||||||
for i, branchName := range self.configuredMainBranches {
|
for i, branchName := range configuredMainBranches {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go utils.Safe(func() {
|
go utils.Safe(func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
|
@ -456,7 +456,7 @@ func (gui *Gui) resetState(startArgs appTypes.StartArgs) types.Context {
|
|||||||
BisectInfo: git_commands.NewNullBisectInfo(),
|
BisectInfo: git_commands.NewNullBisectInfo(),
|
||||||
FilesTrie: patricia.NewTrie(),
|
FilesTrie: patricia.NewTrie(),
|
||||||
Authors: map[string]*models.Author{},
|
Authors: map[string]*models.Author{},
|
||||||
MainBranches: git_commands.NewMainBranches(gui.UserConfig().Git.MainBranches, gui.os.Cmd),
|
MainBranches: git_commands.NewMainBranches(gui.c.Common, gui.os.Cmd),
|
||||||
},
|
},
|
||||||
Modes: &types.Modes{
|
Modes: &types.Modes{
|
||||||
Filtering: filtering.New(startArgs.FilterPath, ""),
|
Filtering: filtering.New(startArgs.FilterPath, ""),
|
||||||
|
Reference in New Issue
Block a user