mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-02-09 13:47:11 +02:00
fix ignore feature
This commit is contained in:
parent
51558f51ab
commit
aa4d739577
@ -461,10 +461,8 @@ func (c *GitCommand) GetLog() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ignore adds a file to the gitignore for the repo
|
// Ignore adds a file to the gitignore for the repo
|
||||||
func (c *GitCommand) Ignore(filename string) {
|
func (c *GitCommand) Ignore(filename string) error {
|
||||||
if _, err := c.OSCommand.RunDirectCommand("echo '" + filename + "' >> .gitignore"); err != nil {
|
return c.OSCommand.AppendLineToFile(".gitignore", filename)
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show shows the diff of a commit
|
// Show shows the diff of a commit
|
||||||
|
@ -174,3 +174,14 @@ func (c *OSCommand) Unquote(message string) string {
|
|||||||
message = strings.Replace(message, `"`, "", -1)
|
message = strings.Replace(message, `"`, "", -1)
|
||||||
return message
|
return message
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (C *OSCommand) AppendLineToFile(filename, line string) error {
|
||||||
|
f, err := os.OpenFile(filename, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer f.Close()
|
||||||
|
|
||||||
|
_, err = f.WriteString("\n" + line)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
@ -142,7 +142,9 @@ func (gui *Gui) handleIgnoreFile(g *gocui.Gui, v *gocui.View) error {
|
|||||||
if file.Tracked {
|
if file.Tracked {
|
||||||
return gui.createErrorPanel(g, gui.Tr.SLocalize("CantIgnoreTrackFiles"))
|
return gui.createErrorPanel(g, gui.Tr.SLocalize("CantIgnoreTrackFiles"))
|
||||||
}
|
}
|
||||||
gui.GitCommand.Ignore(file.Name)
|
if err := gui.GitCommand.Ignore(file.Name); err != nil {
|
||||||
|
return gui.createErrorPanel(g, err.Error())
|
||||||
|
}
|
||||||
return gui.refreshFiles(g)
|
return gui.refreshFiles(g)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user