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) @@ -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

Loading…
Cancel
Save