-
Notifications
You must be signed in to change notification settings - Fork 437
Add "dune promotion diff" to display changes only #6160
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
43dfdfd
Add promotion diff to just display changes
emillon 4fcc9bf
Better names
emillon e0e5868
Document (and rename) Return
emillon a1ad49e
Map in parallel
emillon a398527
Dune promotion apply
emillon ebff55f
Make promote a command alias
emillon ed041e6
Changelog
emillon 17a623b
Simplify types in Job
emillon 02146c8
Return a result
emillon 6296673
Mention promotion diff in the manual
emillon cdf0938
Add cmdliner docs
emillon 5dfa8e7
Rename Job
emillon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
open Stdune | ||
open Import | ||
|
||
let files_to_promote ~common files : Diff_promotion.files_to_promote = | ||
match files with | ||
| [] -> All | ||
| _ -> | ||
let files = | ||
List.map files ~f:(fun fn -> | ||
Path.Source.of_string (Common.prefix_target common fn)) | ||
in | ||
let on_missing fn = | ||
User_warning.emit | ||
[ Pp.textf "Nothing to promote for %s." | ||
(Path.Source.to_string_maybe_quoted fn) | ||
] | ||
in | ||
These (files, on_missing) | ||
|
||
module Apply = struct | ||
let info = | ||
let doc = "Promote files from the last run" in | ||
let man = | ||
[ `S Cmdliner.Manpage.s_description | ||
; `P | ||
{|Considering all actions of the form $(b,(diff a b)) that failed | ||
in the last run of dune, $(b,dune promotion apply) does the following: | ||
|
||
If $(b,a) is present in the source tree but $(b,b) isn't, $(b,b) is | ||
copied over to $(b,a) in the source tree. The idea behind this is that | ||
you might use $(b,(diff file.expected file.generated)) and then call | ||
$(b,dune promote) to promote the generated file. | ||
|} | ||
; `Blocks Common.help_secs | ||
] | ||
in | ||
Cmd.info ~doc ~man "apply" | ||
|
||
let term = | ||
let+ common = Common.term | ||
and+ files = | ||
Arg.(value & pos_all Cmdliner.Arg.file [] & info [] ~docv:"FILE") | ||
in | ||
let _config = Common.init common in | ||
let files_to_promote = files_to_promote ~common files in | ||
Diff_promotion.promote_files_registered_in_last_run files_to_promote | ||
|
6D47
tr>
||
let command = Cmd.v info term | ||
end | ||
|
||
module Diff = struct | ||
let info = Cmd.info ~doc:"List promotions to be applied" "diff" | ||
|
||
let term = | ||
let+ common = Common.term | ||
and+ files = | ||
Arg.(value & pos_all Cmdliner.Arg.file [] & info [] ~docv:"FILE") | ||
in | ||
let config = Common.init common in | ||
let files_to_promote = files_to_promote ~common files in | ||
Scheduler.go ~common ~config (fun () -> | ||
Diff_promotion.display files_to_promote) | ||
|
||
let command = Cmd.v info term | ||
end | ||
|
||
let info = | ||
Cmd.info ~doc:"Control how changes are propagated back to source code." | ||
"promotion" | ||
|
||
let group = Cmd.group info [ Apply.command; Diff.command ] | ||
|
||
let promote = | ||
command_alias ~orig_name:"promotion apply" Apply.command Apply.term "promote" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
open Import | ||
|
||
val group : unit Cmd.t | ||
|
||
val promote : unit Cmd.t |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not entirely related to this PR, but we should change the API away from the ugly callback.