Skip to content

Homogenize the behaviour of initial repository loads and subsequent loads from diff - #6924

Draft
kit-ty-kate wants to merge 3 commits into
ocaml:masterfrom
kit-ty-kate:fix-update-diff
Draft

Homogenize the behaviour of initial repository loads and subsequent loads from diff#6924
kit-ty-kate wants to merge 3 commits into
ocaml:masterfrom
kit-ty-kate:fix-update-diff

Conversation

@kit-ty-kate

@kit-ty-kate kit-ty-kate commented May 5, 2026

Copy link
Copy Markdown
Member

Alternative to #6871

This enforces:

Should be reviewed using Hide whitespace

Comment on lines +124 to 126
begin match read_package_opam ~repo_name ~repo_root full_path with
| Some opam -> OpamPackage.Map.add nv opam r
| None -> r

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We no longer have the error log "ERR: directory name not a valid package: ignored %s" in this version.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error cannot happen in the new version since we're checking using get_pkg_dir. Also i'm unable to find this debug log anywhere in our testsuite

if OpamFilename.Dir.Set.mem pkg_dir processed_dirs then
match OpamRepositoryPath.get_pkg_dir file with
| None ->
log "ERR: file name not a valid package: ignored %s"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
log "ERR: file name not a valid package: ignored %s"
log "ERR: directory name not a valid package: ignored %s"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well %s is not a directory but a file, so it should rather be

Suggested change
log "ERR: file name not a valid package: ignored %s"
log "ERR: file name is not part of a valid package directory: ignored %s"

| Some (nv, _pkg_dir) ->
(* NOTE: we ignore [pkg_dir] because load_opams_from_dir
will always scan parent directories before going deeper *)
begin match read_package_opam ~repo_name ~repo_root full_path with

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to check here if the file is "opam", otherwise we take ito account each file that has a valid opam file content (the extrafile did not change)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmh i don't think so. Do you have an example where it does that? read_package_opam fails if we give it anything but a directory containing a file named opam.

@@ -0,0 +1,628 @@
N0REP0

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to add the same test with load_from_dir

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and a test for files/files to see the change

Comment thread src/core/opamFilename.ml
Comment on lines +823 to +828
List.filter (fun seg ->
if seg = ".." then
invalid_arg "'..' is forbidden"
else
seg <> "" && not (String.equal current_dir_name seg))
x

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
List.filter (fun seg ->
if seg = ".." then
invalid_arg "'..' is forbidden"
else
seg <> "" && not (String.equal current_dir_name seg))
x
match
List.filter (fun seg ->
if seg = ".." then
invalid_arg "'..' is forbidden"
else
seg <> "" && not (String.equal current_dir_name seg))
x
with
| [] -> [current_dir_name] | x -> x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants