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

distinguish between inline and non-inline merge conflicts

This commit is contained in:
Jesse Duffield 2019-03-03 15:55:19 +11:00
parent 7a2176f479
commit 0079015102
4 changed files with 24 additions and 22 deletions

View File

@ -5,14 +5,15 @@ import "github.com/fatih/color"
// File : A file from git status // File : A file from git status
// duplicating this for now // duplicating this for now
type File struct { type File struct {
Name string Name string
HasStagedChanges bool HasStagedChanges bool
HasUnstagedChanges bool HasUnstagedChanges bool
Tracked bool Tracked bool
Deleted bool Deleted bool
HasMergeConflicts bool HasMergeConflicts bool
DisplayString string HasInlineMergeConflicts bool
Type string // one of 'file', 'directory', and 'other' DisplayString string
Type string // one of 'file', 'directory', and 'other'
} }
// GetDisplayStrings returns the display string of a file // GetDisplayStrings returns the display string of a file

View File

@ -150,14 +150,15 @@ func (c *GitCommand) GetStatusFiles() []*File {
_, hasNoStagedChanges := map[string]bool{" ": true, "U": true, "?": true}[stagedChange] _, hasNoStagedChanges := map[string]bool{" ": true, "U": true, "?": true}[stagedChange]
file := &File{ file := &File{
Name: filename, Name: filename,
DisplayString: statusString, DisplayString: statusString,
HasStagedChanges: !hasNoStagedChanges, HasStagedChanges: !hasNoStagedChanges,
HasUnstagedChanges: unstagedChange != " ", HasUnstagedChanges: unstagedChange != " ",
Tracked: !untracked, Tracked: !untracked,
Deleted: unstagedChange == "D" || stagedChange == "D", Deleted: unstagedChange == "D" || stagedChange == "D",
HasMergeConflicts: change == "UU" || change == "AA" || change == "DU", HasMergeConflicts: change == "UU" || change == "AA" || change == "DU",
Type: c.OSCommand.FileType(filename), HasInlineMergeConflicts: change == "UU" || change == "AA",
Type: c.OSCommand.FileType(filename),
} }
files = append(files, file) files = append(files, file)
} }

View File

@ -67,7 +67,7 @@ func (gui *Gui) handleFileSelect(g *gocui.Gui, v *gocui.View, alreadySelected bo
return err return err
} }
if file.HasMergeConflicts { if file.HasInlineMergeConflicts {
return gui.refreshMergePanel() return gui.refreshMergePanel()
} }
@ -172,10 +172,10 @@ func (gui *Gui) handleEnterFile(g *gocui.Gui, v *gocui.View) error {
} }
return nil return nil
} }
if file.HasMergeConflicts { if file.HasInlineMergeConflicts {
return gui.handleSwitchToMerge(g, v) return gui.handleSwitchToMerge(g, v)
} }
if !file.HasUnstagedChanges { if !file.HasUnstagedChanges || file.HasMergeConflicts {
return gui.createErrorPanel(g, gui.Tr.SLocalize("FileStagingRequirements")) return gui.createErrorPanel(g, gui.Tr.SLocalize("FileStagingRequirements"))
} }
if err := gui.changeContext("main", "staging"); err != nil { if err := gui.changeContext("main", "staging"); err != nil {
@ -196,7 +196,7 @@ func (gui *Gui) handleFilePress(g *gocui.Gui, v *gocui.View) error {
return err return err
} }
if file.HasMergeConflicts { if file.HasInlineMergeConflicts {
return gui.handleSwitchToMerge(g, v) return gui.handleSwitchToMerge(g, v)
} }
@ -458,7 +458,7 @@ func (gui *Gui) handleSwitchToMerge(g *gocui.Gui, v *gocui.View) error {
} }
return nil return nil
} }
if !file.HasMergeConflicts { if !file.HasInlineMergeConflicts {
return gui.createErrorPanel(g, gui.Tr.SLocalize("FileNoMergeCons")) return gui.createErrorPanel(g, gui.Tr.SLocalize("FileNoMergeCons"))
} }
if err := gui.changeContext("main", "merging"); err != nil { if err := gui.changeContext("main", "merging"); err != nil {

View File

@ -179,7 +179,7 @@ func addEnglish(i18nObject *i18n.Bundle) error {
Other: "Fetching...", Other: "Fetching...",
}, &i18n.Message{ }, &i18n.Message{
ID: "FileNoMergeCons", ID: "FileNoMergeCons",
Other: "This file has no merge conflicts", Other: "This file has no inline merge conflicts",
}, &i18n.Message{ }, &i18n.Message{
ID: "SureResetHardHead", ID: "SureResetHardHead",
Other: "Are you sure you want to `reset --hard HEAD` and `clean -fd`? You may lose changes", Other: "Are you sure you want to `reset --hard HEAD` and `clean -fd`? You may lose changes",