Browse Source

Improve diff output by printing to stderr and use real filename

pull/19/head
Fredrik Ekre 2 years ago
parent
commit
6c9a8a8c58
No known key found for this signature in database
GPG Key ID: DE82E6D5E364C0A2
  1. 18
      src/main.jl

18
src/main.jl

@ -286,13 +286,21 @@ function main(argv)
end end
if diff if diff
mktempdir() do dir mktempdir() do dir
A = joinpath(dir, "A.jl") a = mkdir(joinpath(dir, "a"))
B = joinpath(dir, "B.jl") b = mkdir(joinpath(dir, "b"))
file = basename(inputfile)
A = joinpath(a, file)
B = joinpath(b, file)
write(A, ctx.src_str) write(A, ctx.src_str)
write(B, seekstart(ctx.fmt_io)) write(B, seekstart(ctx.fmt_io))
# ignorestatus because --no-index implies --exit-code cmd = ```
cmd = `$(git) --no-pager diff --no-index --color=always A.jl B.jl` $(git) --no-pager diff --color=always --no-index --no-prefix
run(setenv(ignorestatus(cmd); dir = dir)) $(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
end end

Loading…
Cancel
Save