Open khuyentran1401 opened 2 years ago
Hey, thanks for the bug report!
TL;DR: the absence of the rev
key is actually by design: I don't enforce versions on the built-in styles with pre-commit hooks, because I use https://pre-commit.ci/ for auto-updates on my projects.
Read further below for more details.
This problem should be fixed when #218 will be developed.
rev
key as "should be present" for every pre-commit hook in every built-in style.master
, main
, develop
... depends on each project).pre-commit autoupdate
after applying changes with nitpick fix
. The built-in styles will only enforce the presence of rev
and will not guarantee that the latest tag is being used.rev
key is not set on styles?I removed all rev
keys from the built-in styles because I didn't want to keep updating the styles manually every time a hook got upgraded by https://pre-commit.ci/.
I had to change docs, styles and tests whenever a hook was upgraded. Examples:
It was annoying and there were no auto-updates: I always had to intervene manually.
Hi @andreoliwa, thank you for proposing the solutions and for the explanation. I think using numbers 2 and 3 will solve this problem. I didn't know about pre-commit autoupdate
until now so it would be nice if you can include that in the documentation
I think using numbers 2 and 3 will solve this problem.
Awesome that these items unblock you. π₯³ But I will still keep this bug open until I am (or someone is) able to fix it for good.
I didn't know about
pre-commit autoupdate
until now so it would be nice if you can include that in the documentation
Good idea, I'll do that. ππ»
First of all, great project! Just want to say that I used the following layout
[[".pre-commit-config.yaml".repos]]
repo = "https://github.com/pre-commit/pre-commit-hooks"
rev = "" # run `pre-commit autoupdate`
Which worked well as a placeholder. Not sure if there are any downsides with this though!
If the built-in styles contain that they would work after running pre-commit autoupdate
.
Hi y'all!
I'm also running into this issue, and the proposed solution with pre-commit autoupdate
does not work in my case:
# nitpick style
[nitpick.files.present]
".pre-commit-config.yaml" = "Create the file with the contents below, then run 'pre-commit install'"
[[".pre-commit-config.yaml".repos]]
repo = "https://github.com/astral-sh/ruff-pre-commit"
[[".pre-commit-config.yaml".repos.hooks]]
id = "ruff"
Trying to run it on a repo without the .pre-commit-config.yaml
file
$ nitpick fix
.pre-commit-config.yaml:1: NIP103 should exist: Create the file with the contents below, then run 'pre-commit install'
.pre-commit-config.yaml:1: NIP361 was not found. Create it with this content:
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
hooks:
- id: ruff
Violations: β
1 fixed, β 1 to change manually.
$ nitpick fix
No violations found. β¨ π° β¨
$ pre-commit autoupdate
An error has occurred: InvalidConfigError:
==> File .pre-commit-config.yaml
==> At Config()
==> At key: repos
==> At Repository(repo='https://github.com/astral-sh/ruff-pre-commit')
=====> Missing required key: rev
Check the log at /home/valberg/.cache/pre-commit/pre-commit.log
pre-commit
expects there to be a rev
key. Or maybe I'm missing something?
I'm also running into this issue, and the proposed solution with
pre-commit autoupdate
does not work in my case:
Maybe it works if you add rev = "master"
on your style.
pre-commit
expects there to be arev
key. Or maybe I'm missing something?
You're correct.
The problem is that I can't add rev = "master"
or rev = ""
to the built-in styles.
Otherwise, they will be enforced by Nitpick.
This still depends on #218 being developed first as I mentioned in https://github.com/andreoliwa/nitpick/issues/472#issuecomment-1079692929. If you see any other solution, let me know.
Not sure if there are any downsides with this though! If the built-in styles contain that they would work after running
pre-commit autoupdate
.
@AntarktisZ11 Currently, if the style has rev = ""
then Nitpick will enforce it and erase existing revisions. π
so it would be nice if you can include that in the documentation
I updated the docs: https://nitpick.readthedocs.io/en/latest/troubleshooting.html#missing-rev-key-when-using-the-default-pre-commit-styles
Expected behavior
After running,
nitpick fix
, a.pre-commit-config.yaml
file was created. I expect to see the required keyrev
under all repos.Current behavior
No key
rev
is shown in the.pre-commit-config.yaml
file. Here is how the file looks like:Steps to reproduce
Run
nitpick fix
created a.pre-commit-config.yaml
fileContext
I can't commit because of the missing required key
rev
. Here is the messing I saw when committed:Your environment
nitpick
version used: 0.31.0