Keep indented stderr when copying git output from the command log

Hook and linter output often uses leading spaces for stack traces and
continuations. Those lines are visible in the log but were dropped on
copy
because every two-space-prefixed line was treated as lazygit log noise.
This commit is contained in:
tmwatchanan 2026-06-20 18:43:09 +07:00
parent 224f8e7e50
commit a2b21978c6
No known key found for this signature in database
GPG key ID: F4D43507B7A7F4AC
2 changed files with 15 additions and 3 deletions

View file

@ -119,9 +119,6 @@ func gitOutputLinesAfterHeader(lines []string, startIdx int, gitOutputHeader str
if isCopyToClipboardLogLine(line) {
continue
}
if strings.HasPrefix(line, " ") {
continue
}
if isStartOfNewCommandLogEntry(lines, i) {
break
}

View file

@ -23,6 +23,21 @@ func TestGitOutputBlocksFromCommandLogLines(t *testing.T) {
assert.Equal(t, []string{"Push\n git push\n\nGit output:\nline1\nline2"}, gitOutputBlocksFromCommandLogLines(lines, gitOutputHeader))
}
func TestGitOutputBlocksIncludeIndentedStderr(t *testing.T) {
t.Parallel()
lines := []string{
"Push",
" git push",
gitOutputHeader,
" at foo.go:10",
" at bar.go:20",
"hook failed",
}
assert.Equal(t, []string{"Push\n git push\n\nGit output:\n at foo.go:10\n at bar.go:20\nhook failed"}, gitOutputBlocksFromCommandLogLines(lines, gitOutputHeader))
}
func TestGitOutputBlocksSkipCopyNotifications(t *testing.T) {
t.Parallel()