Skip to content

Commit

Permalink
fix: apply @Leonidas-from-XIV suggestion
Browse files Browse the repository at this point in the history
Signed-off-by: Etienne Marais <dev@maiste.fr>
  • Loading branch information
maiste committed Feb 5, 2025
1 parent 8c64e1e commit e2ec89b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 19 deletions.
16 changes: 8 additions & 8 deletions src/dune_pkg/mount.ml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ let of_opam_url loc url =
>>= (function
| Error message_opt ->
let message =
match message_opt with
| Some message -> message
| None ->
User_message.make
[ Pp.textf
"Failed to retrieve source archive from: %s"
(OpamUrl.to_string url)
]
Option.value
~default:
(User_message.make
[ Pp.textf
"Failed to retrieve source archive from: %s"
(OpamUrl.to_string url)
])
message_opt
in
raise (User_error.E message)
| Ok output ->
Expand Down
6 changes: 4 additions & 2 deletions src/dune_pkg/opamUrl0.ml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ let is_version_control t =
let is_local t = String.equal t.transport "file"

let is_tarball t =
let supported_compress_format = [ "tar.gz"; "tgz"; "tar.bz2"; "tbz" ] in
List.exists ~f:(fun suffix -> String.is_suffix ~suffix t.path) supported_compress_format
let supported_compress_format = [ ".tar"; ".tar.gz"; ".tgz"; ".tar.bz2"; ".tbz" ] in
List.exists
~f:(fun suffix -> Filename.check_suffix t.path suffix)
supported_compress_format
;;

let local_or_git_or_tar_only url loc =
Expand Down
14 changes: 8 additions & 6 deletions src/dune_pkg/source.ml
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@ let fetch_and_hash_archive_cached (url_loc, url) =
| Ok target -> Some (Dune_digest.file target |> Checksum.of_dune_digest)
| Error message_opt ->
let message =
match message_opt with
| Some message -> message
| None ->
User_message.make
[ Pp.textf "Failed to retrieve source archive from: %s" (OpamUrl.to_string url)
]
Option.value
~default:
(User_message.make
[ Pp.textf
"Failed to retrieve source archive from: %s"
(OpamUrl.to_string url)
])
message_opt
in
User_warning.emit_message message;
None
Expand Down
6 changes: 3 additions & 3 deletions test/blackbox-tests/test-cases/pkg/pin-depends.t
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,10 @@ Pin to an HTTP archive work
$ cat > _source/bar.opam << EOF
> opam-version: "2.0"
> EOF
$ tar -czf tarball.tgz -C _source bar.opam
$ echo tarball.tgz > fake-curls
$ tar cf tarball.tar -C _source bar.opam
$ echo tarball.tar > fake-curls
$ PORT=1
$ runtest "http://0.0.0.0:$PORT/tarball.tgz"
$ runtest "http://0.0.0.0:$PORT/tarball.tar"
Solution for dune.lock:
- bar.1.0.0
(version 1.0.0)
Expand Down

0 comments on commit e2ec89b

Please sign in to comment.