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: Respect exclude option in config file #111

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

danielhollas
Copy link

@danielhollas danielhollas commented May 27, 2021

As explained in #110, the exclude option given via the config file did not work.
Here's the fix, a bit of a refactor, and a bunch of new tests.

If this change looks good to you, I would do a bit more refactoring since right now we're needlessly re-parsing the config files for each FORTRAN file, instead of just parsing it once per directory. I didn't want to do it right away to make the initial review easier.

I build this PR on top of #98 since it touched the same code. I am happy to rebase if it gets merged first.

Closes #110.

CC @pseewald

sidenote: Instead of the exclude option, it would be nice to support something like the .gitignore file. For example, ESLint has .eslintignore.

@danielhollas danielhollas changed the title WIP FIX: exclude option in config files not respected FIX: Respect exclude option in config file May 27, 2021
jhrmnn and others added 3 commits May 27, 2021 18:13
@danielhollas danielhollas marked this pull request as ready for review May 27, 2021 16:16
@@ -2046,6 +2056,19 @@ def build_ws_dict(args):
ws_dict['intrinsics'] = args.whitespace_intrinsics
return ws_dict

def build_case_dict(args):
Copy link
Author

@danielhollas danielhollas May 27, 2021

Choose a reason for hiding this comment

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

Just a bit of unrelated refactor to make this consistent with build_ws_dict().

" does not exist!\n")
sys.exit(1)
if not os.path.isfile(directory) and directory != '-' and not args.recursive:
sys.stderr.write("file " + directory + " does not exist!\n")
if os.path.isdir(directory) and not args.recursive:
Copy link
Author

Choose a reason for hiding this comment

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

I think this is a bit clearer. Also the directory != '-' condition was redundant here.

# Prune excluded patterns from list of child directories
# https://stackoverflow.com/a/19859907
Copy link
Author

Choose a reason for hiding this comment

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

I was fairly confused by this code so added a link.

@@ -2077,35 +2101,34 @@ def build_ws_dict(args):

for dirpath, dirnames, files in os.walk(directory,topdown=True):

file_args = args
Copy link
Author

Choose a reason for hiding this comment

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

This is the actual fix.

else:
self.removeTmpDir()

def test_config_stdin(self):
Copy link
Author

Choose a reason for hiding this comment

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

This is a test for the fix in #98.

p1.wait()

check_output_file(alien_file, outstring_with_config)
# Excluded files and directories should not be touched at all.
Copy link
Author

Choose a reason for hiding this comment

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

This part of the test would fail before the fix.

@danielhollas
Copy link
Author

@pseewald friendly ping. 😊 LMK if you want me to split this PR into smaller pieces to make it easier to review.

@danielhollas
Copy link
Author

@gnikit @awvwgk I've merged in latest master. Would you mind approving the GHA workflow run? Thanks!

@gnikit
Copy link
Member

gnikit commented Aug 8, 2023

I've approved the run but I won't have time until the end of the year to become familiar with this PR and review changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exclude option ignored in config file
3 participants