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

Exclude files in .gitignore #595

Closed
krisleech opened this issue Oct 31, 2013 · 24 comments
Closed

Exclude files in .gitignore #595

krisleech opened this issue Oct 31, 2013 · 24 comments
Assignees

Comments

@krisleech
Copy link

I think this would be a nice feature, the easiest implimention would be to run the rubocop.yml through erb so that you could have something like:

 Excludes:
   <% `git whatever`.each_line do |path| %>
    - <%= path %>
   < % end %>

I'd be happy to look at a PR if you think this is useful.

@jonas054
Copy link
Collaborator

👍 I think it's a neat idea. It doesn't change anything for people who don't use erb pre-processing, and it's versatile, can be used for other things things than excludes based on .gitignore.

@yujinakayama
Copy link
Collaborator

I'm not against this feature. But if the new redesigned configuration that I'm planning (yeah I must propose the new design quickly :) ) is introduced, there will be some overlapped features.

@krisleech
Copy link
Author

@yujinakayama Having the config do this would be a much better solution since it can parse .gitignore easily.

This could be a solution in the meantime and get ripped out later when the new config is in place. Depends when the configuration is expected. Happy either way.

@bbatsov
Copy link
Collaborator

bbatsov commented Dec 3, 2013

@yujinakayama How's that redesigned configuration coming along?

@yujinakayama
Copy link
Collaborator

Sorry for the late. I'll post a draft on this weekend.

@mikegee
Copy link
Contributor

mikegee commented Jan 26, 2014

Any news here?

@bbatsov
Copy link
Collaborator

bbatsov commented Mar 30, 2014

@yujinakayama Ping :-)

@yujinakayama
Copy link
Collaborator

OK, I'll really do in a few days. :)

@bbatsov
Copy link
Collaborator

bbatsov commented Apr 12, 2014

@yujinakayama Great!

@bbatsov
Copy link
Collaborator

bbatsov commented Jun 12, 2014

@yujinakayama Any news here?

@yujinakayama
Copy link
Collaborator

Shame on me. 😵 Will do in this weekend.

@bbatsov
Copy link
Collaborator

bbatsov commented Jun 15, 2014

Closing this in favour of #1151.

@bbatsov bbatsov closed this as completed Jun 15, 2014
@kowal
Copy link

kowal commented Apr 18, 2016

@bbatsov #1151 is closed now. Does it mean that excluding files form .gitignore won't be supported any time soon?

@kowal
Copy link

kowal commented Nov 9, 2016

@yujinakayama just wanted to ask if excluding files from .gitignore is somewhere in your roadmap?

thanks

@AlexWayfer
Copy link
Contributor

I think this issue should be re-opened due to closed #1151.

@AlexWayfer
Copy link
Contributor

Please, @bbatsov or @yujinakayama

@bbatsov bbatsov reopened this Dec 4, 2018
@bbatsov
Copy link
Collaborator

bbatsov commented Dec 4, 2018

PRs welcome. :-) I guess we're back to the erb idea, as it seems unlikely we'll ever move away from yml.

@AlexWayfer
Copy link
Contributor

I'm not sure about ERB or Regexps in YAML, but I think, that files from .gitignore can be excluded by default. If somebody will want to include them — we can make an option later, but it doesn't seem normal.

AlexWayfer added a commit to AlexWayfer/rubocop that referenced this issue Dec 14, 2018
@kisai
Copy link

kisai commented Apr 23, 2020

I know this is closed, but what about files in .git/info/exclude, or more generally $GIT_DIR/info/exclude ?

this file is local to the repository clone, so is available for individual clones only. is described in the official git documentation

I'm using it to exclude a file that I use to help me with my personal workflow, that the rest of the team doesn't want on the repo.

@AlexWayfer
Copy link
Contributor

AlexWayfer commented Apr 23, 2020

I'm using global gitignore, because files and directories specific for me are common. It's uncomfortable to duplicate the same paths in relatives .git/info/exclude.

@jonas054
Copy link
Collaborator

I'll implement the ERB idea, and push it as a solution for this issue.

@jonas054 jonas054 reopened this Apr 30, 2020
@koic koic closed this as completed in 663abb9 May 1, 2020
koic added a commit that referenced this issue May 1, 2020
…ation

[Fix #595] Add ERB pre-processing for configuration files
@sandstrom
Copy link

In case anyone finds this issue because they want to ignore all files/directories from .gitignore automatically, here is the relevant link for how to do it:

https://docs.rubocop.org/rubocop/1.27/configuration.html#pre-processing

@maxim
Copy link

maxim commented Jul 9, 2023

The comment by @sandstrom links to an older version of rubocop docs. It has since been updated with a fix for ignored directories:

https://docs.rubocop.org/rubocop/configuration.html#pre-processing

@AlexWayfer
Copy link
Contributor

Just be careful that if there are no ignored files (git status --ignored --porcelain returns nothing), like in CI, empty AllCops/Exclude: will cause an internal RuboCop error. In such case you should additionally wrap this cycle into some condition.

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

No branches or pull requests

10 participants