Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the behaviour of promotion when files are missings #1775

Merged
2 commits merged into from Jan 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ unreleased
`.merlin` with `S`-directives pointed to original source locations and thus
allowing merlin to see those.

- Improve the behavior of `dune promote` when the files to be promoted have been
deleted. (#1775, fixes #1772, @diml)

- unstable-fmt: preserve comments (#1766, @emillon)

1.6.2 (05/12/2018)
Expand Down
15 changes: 11 additions & 4 deletions src/promotion.ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,17 @@ module File = struct
let register t = db := t :: !db

let promote { src; dst } =
Errors.print_to_console (Format.sprintf "Promoting %s to %s.@."
(Path.to_string_maybe_quoted src)
(Path.to_string_maybe_quoted dst));
Io.copy_file ~src ~dst ()
let src_exists = Path.exists src in
Errors.print_to_console
(Format.sprintf
(if src_exists then
"Promoting %s to %s.@."
else
"Skipping promotion of %s to %s as the file is missing.@.")
(Path.to_string_maybe_quoted src)
(Path.to_string_maybe_quoted dst));
if src_exists then
Io.copy_file ~src ~dst ()
end

let clear_cache () =
Expand Down
16 changes: 16 additions & 0 deletions test/blackbox-tests/test-cases/promote/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,19 @@ Test single file promotion
$ dune promote x y
Warning: Nothing to promote for x.
Warning: Nothing to promote for y.

Reproduction case for #1772
---------------------------

$ printf a > x
$ printf a > y
$ dune build --display short @blah @blah2
File "x", line 1, characters 0-0:
Files _build/default/x and _build/default/x.gen differ.
File "y", line 1, characters 0-0:
Files _build/default/y and _build/default/y.gen differ.
[1]
$ rm -f _build/default/x.gen
$ dune promote
Skipping promotion of _build/default/x.gen to x as the file is missing.
Promoting _build/default/y.gen to y.