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

Apply .gitignore correctly in every source entry #3336

Merged
merged 3 commits into from Nov 5, 2022

Commits on Nov 2, 2022

  1. Fix to use root gitignore in every source entry

    When passing multiple src directories, the root gitignore was only
    applied to the first processed source. The reason is that, in the
    first source, exclude is `None`, but then the value gets overridden by
    `re_compile_maybe_verbose(DEFAULT_EXCLUDES)`, so in the next iteration
    where the source is a directory, the condition is not met and sets the
    value of `gitignore` to `None`.
    
    To fix this problem, we store a boolean indicating if `exclude` is
    `None` and set the value of `exclude` to its default value if that's
    the case. This makes sure that the flow enters the correct condition on
    following iterations and also keeps the original value if the condition
    is not met.
    
    Also, the value of `gitignore` is initialized as `None` and overriden
    if necessary. The value of `root_gitignore` is always calculated to
    avoid using additional variables (at the small cost of additional
    computations).
    
    Signed-off-by: Antonio Ossa Guerra <aaossa@uc.cl>
    aaossa committed Nov 2, 2022
    Copy the full SHA
    14f2ba1 View commit details
    Browse the repository at this point in the history
  2. Test root gitignore behavior on multiple sources

    The test creates a fake context and collects the files from two
    sources. Both sources are directories in the root path, where a
    gitignore file ignores a filename that is present in both subdirs.
    
    Before the fix introduced in the previous commit, this test was
    expected to fail: a file that should be ignores was still visible for
    Black. Now, the test is passed.
    
    Signed-off-by: Antonio Ossa Guerra <aaossa@uc.cl>
    aaossa committed Nov 2, 2022
    Copy the full SHA
    f5c5372 View commit details
    Browse the repository at this point in the history
  3. Update CHANGES.md

    Add entry about fixed bug: .gitignore being skipped when more than one
    source directory was given
    
    Signed-off-by: Antonio Ossa Guerra <aaossa@uc.cl>
    aaossa committed Nov 2, 2022
    Copy the full SHA
    8475676 View commit details
    Browse the repository at this point in the history