Fix some function errors.

This commit is contained in:
bigfroggit 2026-09-11 20:04:56 +08:00
parent 22a78ccec9
commit 193f9d4eed
3 changed files with 40 additions and 11 deletions

View file

@ -387,7 +387,7 @@ func (self *SvnCommands) CheckBranchStatus(task gocui.Task, refType string) (map
break
}
}
if isSubPath {
if !isSubPath {
continue
}
for ref := range localRefs {

View file

@ -1915,7 +1915,7 @@ func (self *RefreshHelper) checkSvnTagStatusAsync() {
return true
}
relPath := strings.TrimPrefix(t.FullRefName(), refsPrefix)
return prunedSet[relPath]
return !prunedSet[relPath]
})
}

View file

@ -13,6 +13,7 @@ import (
"github.com/jesseduffield/lazygit/pkg/gui/style"
"github.com/jesseduffield/lazygit/pkg/gui/types"
"github.com/jesseduffield/lazygit/pkg/utils"
"github.com/samber/lo"
)
type RemotesController struct {
@ -414,21 +415,49 @@ func (self *RemotesController) notGitSvnRemote() *types.DisabledReason {
func (self *RemotesController) checkSvnBranchStatusAsync() {
self.c.WithWaitingStatus(self.c.Tr.CheckingSvnStatus, func (task gocui.Task) error {
statuses, err := self.c.Git().Svn.CheckBranchStatus(task, "branches")
svnRemoteName := self.c.Git().Svn.GetSvnRemoteName()
pruned, err := self.c.Git().Svn.PruneStaleRefs("branches")
if err != nil {
return err
}
prunedSet := make(map[string]bool)
for _, p := range pruned {
prunedSet[p] = true
}
missing, err := self.c.Git().Svn.GetMissingRefs("branches")
if err != nil {
return err
}
self.c.OnUIThread(func() error {
for _, branch := range self.c.Model().RemoteBranches {
if branch.RemoteName != "git-svn" {
continue
}
// key 为 ref 相对路径,与 RemoteBranch.Name 格式一致
if status, ok := statuses[branch.Name]; ok {
branch.StaleStatus = status
if len(prunedSet) > 0 {
self.c.Model().RemoteBranches = lo.Filter(self.c.Model().RemoteBranches, func(b *models.RemoteBranch, _ int) bool {
if b.RemoteName != svnRemoteName {
return true
}
return !prunedSet[b.Name]
})
}
existingNames := make(map[string]bool)
for _, b := range self.c.Model().RemoteBranches {
if b.RemoteName == svnRemoteName {
existingNames[b.Name] = true
}
}
// 仅重绘视图,不 Refresh 重建模型(避免 StaleStatus 被冲掉)
for _, m := range missing {
if !existingNames[m] {
self.c.Model().RemoteBranches = append(self.c.Model().RemoteBranches,
&models.RemoteBranch{
Name: m,
RemoteName: svnRemoteName,
StaleStatus: models.SvnBranchStatusMissing,
})
}
}
self.c.PostRefreshUpdate(self.c.Contexts().RemoteBranches)
return nil
})