Skip to content
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
2 changes: 2 additions & 0 deletions doc/changes/fixed/16623.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Do not report unrelated git remote errors as "revision does not exist"
(#16623, fixes #16466, @mefyl)
22 changes: 14 additions & 8 deletions src/dune_pkg/opamUrl0.ml
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,22 @@ type resolve =
| Resolved of Rev_store.Object.resolved
| Unresolved of Rev_store.Object.t

let not_found ~loc ~git_output t =
let url = base_url t in
let rev = rev t in
let not_found ~loc t revision =
Error
(User_message.make
~loc
[ Pp.textf "revision %S not found in %s" revision (base_url t) ])
;;

let fetch_failed ~loc ~git_output t obj =
let git_output = List.map ~f:Pp.verbatim git_output in
Error
(User_message.make ~loc
@@ git_output
@ [ (match rev with
| None -> Pp.textf "default branch not found in %s" url
| Some rev -> Pp.textf "revision %S not found in %s" rev url)
@ [ Pp.textf
"could not fetch revision %S from %s"
(Rev_store.Object.to_hex obj)
(base_url t)
])
;;

Expand Down Expand Up @@ -74,7 +80,7 @@ let resolve t ~loc rev_store =
| `Ref revision ->
Rev_store.resolve_revision rev_store remote ~revision
>>| (function
| None -> not_found ~loc ~git_output:[] t
| None -> not_found ~loc t revision
| Some o -> Ok (Resolved o))
;;

Expand All @@ -86,7 +92,7 @@ let fetch_revision t ~loc resolve rev_store =
| Unresolved o ->
Rev_store.fetch_object rev_store remote o
>>| (function
| Error git_output -> not_found ~loc ~git_output t
| Error git_output -> fetch_failed ~loc ~git_output t o
| Ok rev -> Ok rev)
;;

Expand Down
4 changes: 2 additions & 2 deletions test/blackbox-tests/test-cases/pkg/commit-hash-references.t
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ Depend on foo from the repo

Which foo will we get?

$ dune pkg lock 2>&1 | grep "not found" | dune_cmd subst "$AMBIGUOUS_REF" '$AMBIGUOUS_REF'
revision "$AMBIGUOUS_REF" not found in
$ dune pkg lock 2>&1 | grep "could not fetch" | dune_cmd subst "$AMBIGUOUS_REF" '$AMBIGUOUS_REF'
could not fetch revision "$AMBIGUOUS_REF" from
[1]
Loading