-
Notifications
You must be signed in to change notification settings - Fork 157
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
When running reuse via pre-commit, ignore untracked files (or: create lint-file
)
#578
Comments
Tempted to mark this wontfix as feature creep. |
Fine, then please update the documentation to provide the complete set of steps needed to accomplish this. Assume I didn't know anything about pre-commit before discovering the reuse tool. |
To clarify: I have set up pre-commit to the best of my ability following the directions currently in the reuse documentation. Pre-commit runs the reuse tool when I commit anything. It prevents any commit from going through if there are any files in the directory that don't have proper license information, even if those files are untracked and are not part of the commit. |
Ah, you may be right. pre-commit stashes and unstashes unstaged tracked files. We'll need to look at this issue some time then. I'm inclined towards a solution that doesn't introduce git-specific interactions into the tool. I think the solution might be to only lint the files tracked by pre-commit. There's an issue open for only linting specified files, but I'm on my phone and can't easily find it. |
It has those already: Lines 78 to 98 in 61a2d74
Looking at the
This issue is about exactly this set of files: Not tracked by git (yet), but also not on any ignore list. Unfortunately, simply dropping
I presume the latter might become a memory issue on very large repos, but then again those probably have a lot of ignored files laying around as well anyways. |
For reference I think @carmenbianca was referring to issue #512 |
Hi! Is there any news about this issue? I had opened a PR which resolves this in #626, but there has been no movement on it for over a month now. |
We just had out first maintainers call this year and discussed the issue in length. First of all, let me say that we all feel the pain by linters vs. untracked files that you actually never want to track. So thank you for making us think about it and even proposing a PR! But we are convinced that somehow ignoring it would lead to more issues that it solves.
Ad 5., here is how we would make one's life easier with this specific issue:
All of this said, we'd like to close #626 as well. |
I fully understand the reasoning behind this decision. As for fixing the problem, I went with option 3: A wrapper script around the git hook that asks whether I want to ignore the errors and continue anyway. This has served me well both with REUSE complaints as well as several other occasional false-positives. (It's as simple as |
@Wuestengecko Interesting! Normally when I encounter an issue like this with failing lints/tests because of unstaged files, I run (And if I use |
I really disagree with the conclusions. Just cause some other linters behave this way, that doesn't mean reuse should. The key difference between typical "linters" and reuse is that reuse applies to all files. So, while you can easily have other random files lying around, and not have that bother other linters, with reuse that isn't doable. Regarding 5 - a. Stashing does not affect untracked files. So doing a stash doesn't do anything. None of your alternatives really work. Regardless, you've made your decision. My complaints aren't going to change your mind. Please remember, the more difficult a tool is to use, the lower the chance that someone is going to adopt it or evangelize it. |
@carmenbianca I used to do it like this too, but having to remember to add It's also convenient when I have a bunch of relatively unrelated changes in the work tree and want to split them into two or three different commits. If I see it's just the untracked files again for the second commit, and everything else was successful, I don't have to re-run at all. And if I do mess up, I can rely on the CI as well. :)
@vHanda Use |
I need to apologize for the slightly annoyed message. I didn't realize that Again, my apologies for the slightly hostile message, and thank you for working on this. |
Well, I don't completely understand yet, and still don't know how to accomplish what I want. What I want is: I commit changes to my git repository. The pre-commit hook runs You speak of |
Ah. Let's re-open this. There's a subtle detail here that I think we overlooked when closing this. Other linters, pylint etc, when run via pre-commit, only run against staged/tracked files. This is a behaviour of pre-commit, which passes (I think) a list of files to the linters. reuse differs here, because there's presently no way to run the linter against a subset of files. I think the solution lies not in ignoring untracked files; it lies in enabling the prior behaviour. I think there's an issue for this, but I can't find it. I'll rename this issue. |
lint-file
)
I'm quite interested in this since I've started using pre-commit as well. I agree that I don't think having a different behavior for I even think the opposite, |
I tried I found that I needed to do While this works, it's annoying. Is there a simpler way to accomplish the same thing?
FWIW, this is exactly the behavior I want (and expected) too. I just want any modified/untracked files to be ignored by the pre-commit hook, and only staged files in the git index to be checked for compliance. |
Well, there is already an open PR for this, which you could just use ;) I do that in some repos, so I can confirm that it actually works. Just change your - repo: https://github.com/Wuestengecko/reuse-tool
rev: 7d19244ab46b6a125d1a4dbe4a3ebb9ca767ab1a
hooks:
- id: reuse Do note that you'll have to revert back to the official repo once the PR (or whatever other solution) gets merged, as I'll eventually delete my fork then. |
I decided to use a pinned version that doesn't lint untracked files, for details see fsfe/reuse-tool#578 (comment)
I decided to use a pinned version that doesn't lint untracked files, for details see fsfe/reuse-tool#578 (comment)
I decided to use a pinned version that doesn't lint untracked files, for details see fsfe/reuse-tool#578 (comment)
I decided to use a pinned version that doesn't lint untracked files, for details see fsfe/reuse-tool#578 (comment)
Implemented in #1055, will release one of these days. Thank you! |
I decided to use a pinned version that doesn't lint untracked files, for details see fsfe/reuse-tool#578 (comment)
I decided to use a pinned version that doesn't lint untracked files, for details see fsfe/reuse-tool#578 (comment)
I decided to use a pinned version that doesn't lint untracked files, for details see fsfe/reuse-tool#578 (comment)
I decided to use a pinned version that doesn't lint untracked files, for details see fsfe/reuse-tool#578 (comment)
Hello.
I sometimes have some random files which I haven't committed and don't necessarily plan to, but I don't want to add them to the '.gitignore'. Reuse complains about those files.
It would be awesome if I could run reuse with a
--ignore-untracked
option, which ignores all files which aren't in git index.comment by @carmenbianca :
Let's create
lint-file
to lint a subset of files, and then allow the pre-commit to be configured to use that instead oflint
.The text was updated successfully, but these errors were encountered: