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

Spoom bump not ignoring files as expected #379

Closed
plvaldes opened this issue Jun 2, 2023 · 4 comments · Fixed by #383
Closed

Spoom bump not ignoring files as expected #379

plvaldes opened this issue Jun 2, 2023 · 4 comments · Fixed by #383
Labels
bug Something isn't working

Comments

@plvaldes
Copy link

plvaldes commented Jun 2, 2023

Describe the bug
The command spoom bump --from false --to true --dry is trying to bump files that I have in my ignore list in sorbet/config.

I am assuming that spoom config is picked from sorbet/config as I read in the docs. Actually, running bin/spoom config in my project lists all the ignore paths in that file (see link in steps to reproduce)

To Reproduce
Spoom version: '1.2.1'

Steps to reproduce the behavior:
There are more details about the context and what I did in this discourse thread, but the TL;DR should be:

  • in a file that has # typed: true, change it false
  • add that file to sorbet/config as --ignore=the_file.rb
  • run spoom bump --from false --to true --dry

Expected behavior
The file should be ignored and no errors should be displayed

@plvaldes plvaldes added the bug Something isn't working label Jun 2, 2023
@Morriar
Copy link
Collaborator

Morriar commented Jun 2, 2023

👋 Hey @plvaldes,

Do you mind posting your Sorbet config here please? That would help me fix the issue 🙏

@plvaldes
Copy link
Author

plvaldes commented Jun 5, 2023

Hey @Morriar ! 👋🏼 This is the file:

--dir
.
--ignore=/config/routes.rb
--ignore=/app/controllers/api
--ignore=/lib/generators/
--ignore=/test/lib/generators

It's in the melody repo

@ghost
Copy link

ghost commented Jun 5, 2023

Just saying we're hitting this as well. I'd love for spoom bump to support ignore

Morriar added a commit that referenced this issue Jun 6, 2023
We ignore files matching the paths ignored in the `sorbet/config` and
try to reproduce Sorbet behvior.

From Sorbet docs on `--ignore`:
> Ignores input files that contain the given string in their paths (relative to the input path passed to
> Sorbet). Strings beginning with / match against the prefix of these relative paths; others are substring
> matchs. Matches must be against whole folder and file names, so `foo` matches `/foo/bar.rb` and
> `/bar/foo/baz.rb` but not `/foo.rb` or `/foo2/bar.rb`.

To produce the same behavior, we match files using `File.fnmatch?` and we
were prefixing and suffixing the paths with `**`.

When the Sorbet config contains ignored files with extensions like this:

```
--ignore=foo.rb
```

This doesn't work as we are trying to match `foo.rb` with `**/foo.rb/**`.

To fix this problem, we only append `**` to the ignored path IF it does
contain a file extension.

Fixes #379.

Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
@Morriar
Copy link
Collaborator

Morriar commented Jun 6, 2023

@plvaldes and @shop-jsmestad I opened #383 that should fix this problem.

Do you mind pointing your Gemfile to the at-fix-bump-ignore branch and test with your app if Spoom behaves as you would expect?

Thanks! 🙏

Morriar added a commit that referenced this issue Jun 6, 2023
We ignore files matching the paths ignored in the `sorbet/config` and try to reproduce Sorbet behvior.

From Sorbet docs on `--ignore`:
> Ignores input files that contain the given string in their paths (relative to the input path passed to
> Sorbet). Strings beginning with / match against the prefix of these relative paths; others are substring
> matchs. Matches must be against whole folder and file names, so `foo` matches `/foo/bar.rb` and
> `/bar/foo/baz.rb` but not `/foo.rb` or `/foo2/bar.rb`.

To produce the same behavior, we match files using `File.fnmatch?` and we were prefixing and suffixing the paths with `**`.

When the Sorbet config contains ignored files with extensions like this:

```
--ignore=foo.rb
```

This doesn't work as we are trying to match `foo.rb` with `**/foo.rb/**`.

To fix this problem, we only append `**` to the ignored path IF it does contain a file extension.

Fixes #379.

Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
Morriar added a commit that referenced this issue Jun 6, 2023
We ignore files matching the paths ignored in the `sorbet/config` and try to reproduce Sorbet behvior.

From Sorbet docs on `--ignore`:
> Ignores input files that contain the given string in their paths (relative to the input path passed to
> Sorbet). Strings beginning with / match against the prefix of these relative paths; others are substring
> matchs. Matches must be against whole folder and file names, so `foo` matches `/foo/bar.rb` and
> `/bar/foo/baz.rb` but not `/foo.rb` or `/foo2/bar.rb`.

To produce the same behavior, we match files using `File.fnmatch?` and we were prefixing and suffixing the paths with `**`.

When the Sorbet config contains ignored files with extensions like this:

```
--ignore=foo.rb
```

This doesn't work as we are trying to match `foo.rb` with `**/foo.rb/**`.

To fix this problem, we only append `**` to the ignored path IF it does contain a file extension.

Fixes #379.

Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
Morriar added a commit that referenced this issue Jun 6, 2023
We ignore files matching the paths ignored in the `sorbet/config` and try to reproduce Sorbet behvior.

From Sorbet docs on `--ignore`:
> Ignores input files that contain the given string in their paths (relative to the input path passed to
> Sorbet). Strings beginning with / match against the prefix of these relative paths; others are substring
> matchs. Matches must be against whole folder and file names, so `foo` matches `/foo/bar.rb` and
> `/bar/foo/baz.rb` but not `/foo.rb` or `/foo2/bar.rb`.

To produce the same behavior, we match files using `File.fnmatch?` and we were prefixing and suffixing the paths with `**`.

When the Sorbet config contains ignored files with extensions like this:

```
--ignore=foo.rb
```

This doesn't work as we are trying to match `foo.rb` with `**/foo.rb/**`.

To fix this problem, we only append `**` to the ignored path IF it does contain a file extension.

Fixes #379.

Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants