1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-15 00:15:32 +02:00

Re-determine existing main branches if mainBranches config changed

This commit is contained in:
Stefan Haller
2024-07-30 19:38:36 +02:00
parent 3d6d677453
commit fd8e480363
2 changed files with 23 additions and 4 deletions

View File

@ -18,6 +18,8 @@ type MainBranches struct {
// depending on which one exists for a given bare name.
existingMainBranches []string
previousMainBranches []string
cmd oscommands.ICmdObjBuilder
mutex *deadlock.Mutex
}
@ -40,8 +42,11 @@ func (self *MainBranches) Get() []string {
self.mutex.Lock()
defer self.mutex.Unlock()
if self.existingMainBranches == nil {
self.existingMainBranches = self.determineMainBranches()
configuredMainBranches := self.c.UserConfig().Git.MainBranches
if self.existingMainBranches == nil || !utils.EqualSlices(self.previousMainBranches, configuredMainBranches) {
self.existingMainBranches = self.determineMainBranches(configuredMainBranches)
self.previousMainBranches = configuredMainBranches
}
return self.existingMainBranches
@ -71,11 +76,10 @@ func (self *MainBranches) GetMergeBase(refName string) string {
return ignoringWarnings(output)
}
func (self *MainBranches) determineMainBranches() []string {
func (self *MainBranches) determineMainBranches(configuredMainBranches []string) []string {
var existingBranches []string
var wg sync.WaitGroup
configuredMainBranches := self.c.UserConfig().Git.MainBranches
existingBranches = make([]string, len(configuredMainBranches))
for i, branchName := range configuredMainBranches {