Actually look for conflict markers in GetHasInlineMergeConflicts

So far, lazygit has always auto-staged files as soon as the conflict markers
disappeared from them, which means that we could rely on any file that still had
a status of "UU" to still contain conflict markers.

We are going to make the auto-staging optional in the next commit, and in that
case the user will want to manually stage "UU" files; so we must now check
whether the file contains conflict markers, and disallow the staging in that
case.
This commit is contained in:
Stefan Haller 2024-08-28 22:17:17 +02:00
parent 2f01af49e8
commit 1191aca60f

View file

@ -1,6 +1,9 @@
package filetree
import "github.com/jesseduffield/lazygit/pkg/commands/models"
import (
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/gui/mergeconflicts"
)
// FileNode wraps a node and provides some file-specific methods for it.
type FileNode struct {
@ -44,7 +47,13 @@ func (self *FileNode) GetHasStagedChanges() bool {
}
func (self *FileNode) GetHasInlineMergeConflicts() bool {
return self.SomeFile(func(file *models.File) bool { return file.HasInlineMergeConflicts })
return self.SomeFile(func(file *models.File) bool {
if !file.HasInlineMergeConflicts {
return false
}
hasConflicts, _ := mergeconflicts.FileHasConflictMarkers(file.Name)
return hasConflicts
})
}
func (self *FileNode) GetIsTracked() bool {