Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix format on projects that contain subprojects #2078

Merged
merged 2 commits into from
May 10, 2023

Conversation

paulcadman
Copy link
Collaborator

This PR fixes the behaviour of the format command when run on a project that contains subprojects. Files in subprojects must not be processed by the formatter.

The format issue was caused by a bug in the walkDirRel function that is used to traverse a file system tree:

In this function, the passed handler can return a function that determines if a candidate subdirectory should be traversed. The first argument of this function indicates if the candidate subdirectory contains a juvix.yaml file. In the formatter and the path resolver we use this argument to exclude such subdirectories from the traversal.

Previously the first argument was calculated from the files in the current directory instead of the candidate subdirectory - which was the source of the bug.

The callers of walkDirRel are also fixed to match the updated behaviour.

A function passed to RecurseFilter controls which subdirectories
should be traversed in the directory walk.

The first argument indicates if the candidate subdirectory contains a juvix.yaml
file and the second argument is the path of the candidate subdirectory.

Previously the first argument was calculated from the files in the
current directory - which was incorrect.

The callers of walkDirRel are also fixed. The intended behaviour is to
avoid traversing into hidden directories and into juvix
sub-projects (i.e subdirectories containing a juvix.yaml file).
@paulcadman paulcadman added this to the 0.3.4 milestone May 10, 2023
@paulcadman paulcadman self-assigned this May 10, 2023
Copy link
Collaborator

@janmasrovira janmasrovira left a comment

Choose a reason for hiding this comment

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

great!

@paulcadman paulcadman merged commit 11ebc4a into main May 10, 2023
@paulcadman paulcadman deleted the format-subproject-traversal branch May 10, 2023 17:34
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.

error when format run on a project containing a subproject
2 participants