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

Merge branch 'feature/informative-commit-colors' of https://github.com/jesseduffield/lazygit into feature/informative-commit-colors

This commit is contained in:
Jesse Duffield
2018-09-25 20:11:36 +10:00
13 changed files with 194 additions and 145 deletions

View File

@ -543,26 +543,22 @@ func (c *GitCommand) Ignore(filename string) error {
}
// Show shows the diff of a commit
func (c *GitCommand) Show(sha string) string {
result, err := c.OSCommand.RunCommandWithOutput("git show --color " + sha)
if err != nil {
panic(err)
}
return result
func (c *GitCommand) Show(sha string) (string, error) {
return c.OSCommand.RunCommandWithOutput(fmt.Sprintf("git show --color %s", sha))
}
// Diff returns the diff of a file
func (c *GitCommand) Diff(file *File) string {
cachedArg := ""
trackedArg := "--"
fileName := c.OSCommand.Quote(file.Name)
if file.HasStagedChanges && !file.HasUnstagedChanges {
cachedArg = "--cached"
}
trackedArg := "--"
if !file.Tracked && !file.HasStagedChanges {
trackedArg = "--no-index /dev/null"
}
command := fmt.Sprintf("%s %s %s %s", "git diff --color ", cachedArg, trackedArg, fileName)
command := fmt.Sprintf("git diff --color %s %s %s", cachedArg, trackedArg, fileName)
// for now we assume an error means the file was deleted
s, _ := c.OSCommand.RunCommandWithOutput(command)