Skip to content

Commit

Permalink
Improve diff output by printing to stderr and use real filename
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikekre committed Jun 5, 2024
1 parent 80a9753 commit 6c9a8a8
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -286,13 +286,21 @@ function main(argv)
end
if diff
mktempdir() do dir
A = joinpath(dir, "A.jl")
B = joinpath(dir, "B.jl")
a = mkdir(joinpath(dir, "a"))
b = mkdir(joinpath(dir, "b"))
file = basename(inputfile)
A = joinpath(a, file)
B = joinpath(b, file)
write(A, ctx.src_str)
write(B, seekstart(ctx.fmt_io))
# ignorestatus because --no-index implies --exit-code
cmd = `$(git) --no-pager diff --no-index --color=always A.jl B.jl`
run(setenv(ignorestatus(cmd); dir = dir))
cmd = ```
$(git) --no-pager diff --color=always --no-index --no-prefix
$(relpath(A, dir)) $(relpath(B, dir))
```
# `ignorestatus` because --no-index implies --exit-code
cmd = setenv(ignorestatus(cmd); dir = dir)
cmd = pipeline(cmd, stdout = stderr, stderr = stderr)
run(cmd)
end
end

Expand Down

0 comments on commit 6c9a8a8

Please sign in to comment.