Compute and present the opam file differences as a unified diff #7
Loading…
Reference in a new issue
No description provided.
Delete branch "opam-diff-as-diff"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
f20227cfea
to420d049ff0
Thanks! This is a nice change. There are some things about temporary files and errors that I can look into myself. Otherwise good to go IMO.
@ -208,0 +182,4 @@
let opaml = OpamFile.OPAM.write_to_string l in
let opamr =
let o = OpamFile.make (OpamFilename.raw "opam") in
OpamFile.OPAM.to_string_with_preserved_format ~format_from_string:opaml o r
So this dance here is to try to get the same formatting as for
l
/opaml
? I think that makes sense. Maybe worth attaching a comment?I am curious what the behavior is if the two packages differ too much. I guess since
OpamFile.OPAM.write_to_string
is likely to use a fixed formatting style the style will be consistent even with a larger difference in packages? (this doesn't have to be answered IMO)in my experience, using the "with_preserved_format" is good -- apart from potentially dangling comments (in the last line). I also think a comment is worth it. Of course we can leave the opam files as is and do a direct diff, i.e. do not care about the "minimal" diff...
@ -227,2 +195,3 @@
in
{ pkg ; build ; install ; url ; otherwise_equal }
let diff =
let* tmpl = Bos.OS.File.tmp "opaml_%s" in
I think the files are only deleted
at_exit
. There are functionsBos.OS.File.with_tmp_output
/Bos.OS.File.with_tmp_oc
that ensure the file is deleted when the callback returns - maybe worth using one of them?The files are usually quite small so I imagine it would usually take years before the dangling temporary files become a problem.
Yes, you're right. I'll adapt.
@ -229,0 +203,4 @@
in
let diff = match diff with
| Ok (s, _) -> s
| Error `Msg m -> "error when comparing the opam files: " ^ m
Maybe we should log the error message instead? I think from a security point of view there could be error messages that we don't want to display to the client (e.g. information about the filesystem).
Indeed.
I pushed
b966836
-- does that solve your concerns?@ -229,0 +211,4 @@
with e ->
Error (`Msg ("exception " ^ Printexc.to_string e))
in
let diff = match diff with
I think we can write
match Result.join (Result.join diff) with
to avoid the nested matches, but this is fine, too.Thanks!