Run of fresh-snapshots for opam-file-format

Merge these changes:

git pull https://janitor.debian.net/git/opam-file-format fresh-snapshots/main
git pull https://janitor.debian.net/git/opam-file-format fresh-snapshots/pristine-tar
git pull https://janitor.debian.net/git/opam-file-format fresh-snapshots/upstream

Summary

Merged new upstream version: 2.1.4+git20220503.1.485e55c (was: 2.1.3).

Diff

Branch: main

diff --git a/CHANGES b/CHANGES
index 17f58e9..bf5c482 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,10 @@
-2.1.3 [???]
+2.1.5
+* Fix extra lines on non empty headers [#49 @hhugo]
+
+2.1.4 [12 April 2022]
+* Fix position in the sections parser [#46 @hhugo]
+
+2.1.3 [21 May 2021]
 * Fix module link order (broken by #37) [#41 @dra27]
 * opam-version: "2.1" must appear at most once and as the first non-comment
   item. If opam-version is at the start and is greater than the library version,
diff --git a/debian/changelog b/debian/changelog
index b3fc280..5803204 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+opam-file-format (2.1.4+git20220503.1.485e55c-1) UNRELEASED; urgency=low
+
+  * New upstream snapshot.
+
+ -- Debian Janitor <janitor@jelmer.uk>  Wed, 11 May 2022 04:24:26 -0000
+
 opam-file-format (2.1.3-1) unstable; urgency=medium
 
   * Team upload
diff --git a/opam-file-format.opam b/opam-file-format.opam
index 7e1c1a0..ef43fee 100644
--- a/opam-file-format.opam
+++ b/opam-file-format.opam
@@ -1,5 +1,5 @@
 opam-version: "2.0"
-version: "2.1.3"
+version: "2.1.4"
 synopsis: "Parser and printer for the opam file syntax"
 maintainer: "Louis Gesbert <louis.gesbert@ocamlpro.com>"
 authors: "Louis Gesbert <louis.gesbert@ocamlpro.com>"
diff --git a/src/opamBaseParser.mly b/src/opamBaseParser.mly
index 933676d..5ea4890 100644
--- a/src/opamBaseParser.mly
+++ b/src/opamBaseParser.mly
@@ -92,7 +92,7 @@ item:
   }
 }
 | IDENT STRING LBRACE items RBRACE {
-  { pos = get_pos_full 4;
+  { pos = get_pos_full 5;
     pelem =
       Section ({section_kind = { pos = get_pos 1; pelem = $1 };
                 section_name = Some { pos = get_pos 2; pelem = $2 };
diff --git a/src/opamPrinter.ml b/src/opamPrinter.ml
index 2fe25bb..a0fdb33 100644
--- a/src/opamPrinter.ml
+++ b/src/opamPrinter.ml
@@ -713,16 +713,13 @@ module FullPos = struct
           in
           List.rev_append acc remaining
       in
+      let body = String.concat "\n" (aux [] f orig) in
       let header =
         match orig with
-        | [] -> []
-        | h::_ ->
-          let header =
-            get_substring {filename=""; start=(1,0); stop=h.pos.start}
-          in
-          if header = "" then [] else [header]
+        | [] -> ""
+        | h::_ -> get_substring {filename=""; start=(1,0); stop=h.pos.start}
       in
-      String.concat "\n" (aux header f orig)
+      header ^ body
 
     let opamfile ?format_from f =
       let orig_file = match format_from with
diff --git a/tests/fullpos.ml b/tests/fullpos.ml
index d20f7e9..30e3b91 100644
--- a/tests/fullpos.ml
+++ b/tests/fullpos.ml
@@ -448,6 +448,28 @@ module Opamfile = struct
           (print_ofile (parse_ofile str)))
       t
 
+  let test_printer_preserved t () =
+    let write_tmp content ~f =
+      let file, oc = Filename.open_temp_file "opam-test-" ".opam" in
+      output_string oc content;
+      close_out oc;
+      let res = f file in
+      Sys.remove file;
+      res
+    in
+    let opamfile = OpamPrinter.FullPos.Preserved.opamfile in
+    List.iter (fun (name, str, _) ->
+        let file = parse_ofile str in
+        let content1 = write_tmp str ~f:(fun tmp ->
+            opamfile ~format_from:tmp file)
+        in
+        let content2 = write_tmp content1 ~f:(fun tmp ->
+            opamfile ~format_from:tmp file)
+        in
+        A.check A.string name content1 content2
+        )
+      t
+
   let positions () =
     let filename = Sys.getcwd () ^ "/sample.opam" in
     let spos start stop = {filename; start; stop } in
@@ -469,7 +491,7 @@ module Opamfile = struct
                { pos = spos (2, 8) (2, 13);
                  pelem = String "foo" });
         };
-        { pos = spos (4, 0) (5, 29);
+        { pos = spos (4, 0) (6, 1);
           pelem =
             Section
               { section_kind =
@@ -501,6 +523,7 @@ module Opamfile = struct
       "parser", test_parser (opamfiles @ opamfiles_comment);
       "printer", test_printer opamfiles;
       "parser-printer", test_parser_printer opamfiles;
+      "printer-preserved", test_printer_preserved opamfiles_comment;
       "positions-file", positions;
     ]
 

Branch: pristine-tar

diff --git a/opam-file-format_2.1.4+git20220503.1.485e55c.orig.tar.gz.delta b/opam-file-format_2.1.4+git20220503.1.485e55c.orig.tar.gz.delta
new file mode 100644
index 0000000..e6b3a01
Binary files /dev/null and b/opam-file-format_2.1.4+git20220503.1.485e55c.orig.tar.gz.delta differ
diff --git a/opam-file-format_2.1.4+git20220503.1.485e55c.orig.tar.gz.id b/opam-file-format_2.1.4+git20220503.1.485e55c.orig.tar.gz.id
new file mode 100644
index 0000000..30979c7
--- /dev/null
+++ b/opam-file-format_2.1.4+git20220503.1.485e55c.orig.tar.gz.id
@@ -0,0 +1 @@
+1797c77bd272ab5aac0e395df876b21fe091695a

Branch: upstream

Tag: 2.1.4+git20220503.1.485e55c
diff --git a/CHANGES b/CHANGES
index 17f58e9..bf5c482 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,10 @@
-2.1.3 [???]
+2.1.5
+* Fix extra lines on non empty headers [#49 @hhugo]
+
+2.1.4 [12 April 2022]
+* Fix position in the sections parser [#46 @hhugo]
+
+2.1.3 [21 May 2021]
 * Fix module link order (broken by #37) [#41 @dra27]
 * opam-version: "2.1" must appear at most once and as the first non-comment
   item. If opam-version is at the start and is greater than the library version,
diff --git a/opam-file-format.opam b/opam-file-format.opam
index 7e1c1a0..ef43fee 100644
--- a/opam-file-format.opam
+++ b/opam-file-format.opam
@@ -1,5 +1,5 @@
 opam-version: "2.0"
-version: "2.1.3"
+version: "2.1.4"
 synopsis: "Parser and printer for the opam file syntax"
 maintainer: "Louis Gesbert <louis.gesbert@ocamlpro.com>"
 authors: "Louis Gesbert <louis.gesbert@ocamlpro.com>"
diff --git a/src/opamBaseParser.mly b/src/opamBaseParser.mly
index 933676d..5ea4890 100644
--- a/src/opamBaseParser.mly
+++ b/src/opamBaseParser.mly
@@ -92,7 +92,7 @@ item:
   }
 }
 | IDENT STRING LBRACE items RBRACE {
-  { pos = get_pos_full 4;
+  { pos = get_pos_full 5;
     pelem =
       Section ({section_kind = { pos = get_pos 1; pelem = $1 };
                 section_name = Some { pos = get_pos 2; pelem = $2 };
diff --git a/src/opamPrinter.ml b/src/opamPrinter.ml
index 2fe25bb..a0fdb33 100644
--- a/src/opamPrinter.ml
+++ b/src/opamPrinter.ml
@@ -713,16 +713,13 @@ module FullPos = struct
           in
           List.rev_append acc remaining
       in
+      let body = String.concat "\n" (aux [] f orig) in
       let header =
         match orig with
-        | [] -> []
-        | h::_ ->
-          let header =
-            get_substring {filename=""; start=(1,0); stop=h.pos.start}
-          in
-          if header = "" then [] else [header]
+        | [] -> ""
+        | h::_ -> get_substring {filename=""; start=(1,0); stop=h.pos.start}
       in
-      String.concat "\n" (aux header f orig)
+      header ^ body
 
     let opamfile ?format_from f =
       let orig_file = match format_from with
diff --git a/tests/fullpos.ml b/tests/fullpos.ml
index d20f7e9..30e3b91 100644
--- a/tests/fullpos.ml
+++ b/tests/fullpos.ml
@@ -448,6 +448,28 @@ module Opamfile = struct
           (print_ofile (parse_ofile str)))
       t
 
+  let test_printer_preserved t () =
+    let write_tmp content ~f =
+      let file, oc = Filename.open_temp_file "opam-test-" ".opam" in
+      output_string oc content;
+      close_out oc;
+      let res = f file in
+      Sys.remove file;
+      res
+    in
+    let opamfile = OpamPrinter.FullPos.Preserved.opamfile in
+    List.iter (fun (name, str, _) ->
+        let file = parse_ofile str in
+        let content1 = write_tmp str ~f:(fun tmp ->
+            opamfile ~format_from:tmp file)
+        in
+        let content2 = write_tmp content1 ~f:(fun tmp ->
+            opamfile ~format_from:tmp file)
+        in
+        A.check A.string name content1 content2
+        )
+      t
+
   let positions () =
     let filename = Sys.getcwd () ^ "/sample.opam" in
     let spos start stop = {filename; start; stop } in
@@ -469,7 +491,7 @@ module Opamfile = struct
                { pos = spos (2, 8) (2, 13);
                  pelem = String "foo" });
         };
-        { pos = spos (4, 0) (5, 29);
+        { pos = spos (4, 0) (6, 1);
           pelem =
             Section
               { section_kind =
@@ -501,6 +523,7 @@ module Opamfile = struct
       "parser", test_parser (opamfiles @ opamfiles_comment);
       "printer", test_printer opamfiles;
       "parser-printer", test_parser_printer opamfiles;
+      "printer-preserved", test_printer_preserved opamfiles_comment;
       "positions-file", positions;
     ]
 

Publish Blockers

  • ☑ run was successful
  • ☑ package has not been removed from the archive
  • ☑ command has not changed
  • ☒ not yet reviewed, but review needed
  • ☑ 0 publish attempts so far.not currently attempting to back off
  • ☒ merge proposals for the package maintainer are currently being rate-limited (open: 1253, max open: 300)
  • ☑ change set 4b31be1e-4d55-4ab2-a14f-396fba596fc7 is ready

Resulting package

The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:

apt install -t fresh-snapshots libopam-file-format-ocaml-dev

Lintian Result

Full worker log Full build log