You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I keep on finding pre-commit configs in various projects which are pointed at https://gitlab.com/pycqa/flake8
It would be awesome if I could turn on a hook which checks for hooks from that repo and flags them as needing an update to the github repo. The same holds for many repos like black which have moved/renamed, and which only work because of github redirects.
I don't know if this is a common case other than flake8, or if it's so common that such a hook would be a huge pain to maintain. But it just needs to be able to read the pre-commit config and pull out the repos, not the rest of the config. It can skip support for old configs (top-level list) and make other simplifying assumptions as necessary.
I'd suggest putting it in a separate project (I'd just go off and write it myself), but it's such a "pre-commit checks pre-commit config" hook that I almost suggested it as one of the "meta" hooks in pre-commit itself.
Would you be interested in this as a part of pre-commit? It could be made part of the behavior of autoupdate to check for redirects. I thought it would be easier to implement as a hook, but after reading your points, it seems like auotupdate might be the right place for it.
Looking for a past issue or PR, I see this comment. I'm not clear if the pre-commit.ci feature mentioned there is the normalization of which you spoke here.
That issue mentions git behavior being complicated (presumably autoupdate starts by cloning). I was considering something doing an HTTP GET, even if autoupdate is not doing that already.
Perhaps this makes more sense as a flag to autoupdate, like --check-http-redirects? Or maybe I'm still underestimating the complexity.
If this issue was dead-on-arrival, let's just close. I'm happy to help if there's a feature I could work on, but if not, there's no point spending more time on this topic. :-)
I do not like that, but it's all I can think of if we don't add to config. 😿
But even without an ignore mechanism, this would be handy for the majority of users.
As another alternative direction, allow the command to consume some kind of listing of user specified known repo moves. And check redirects (optionally) without trying to follow them.
e.g.
$ cat moves.json
{"https://gitlab.com/pycqa/flake8": "https://github.com/pycqa/flake8"}
$ check-pre-commit-repo-moves --repo-moves-file moves.json --check-redirects
Errors found prior to running update:
Redirect found in repo URL
https://github.com/ambv/black
has moved to
https://github.com/psf/black
Known repo move detected:
https://gitlab.com/pycqa/flake8
has moved to
https://github.com/pycqa/flake8
There's no redirect looping or following issue because it doesn't follow redirects.
We don't get stymied trying to track repo moves.
It can be added as a hook as long as it gets skipped in pre-commit.ci config.
I don't really want to introduce pre-commit.com or pre-commit.ci as a critical-path component for pre-commit's operation -- part of the current design is it's entirely "distributed" and doesn't have any phone-home
I'm still trying to think up a reasonable way of handling this. (Should I not? You can close as far as I'm concerned if you think the problem doesn't have a good, tractable solution.)
How 👍/👎 would you be on the idea of a new key in hook config which states the "canonical repo" of a hook? The hook owner can then "publish" their rename. That might also help in the case of a hook moving between repos.
It's not perfect, but it avoids centralizing the information.
Activity
asottile commentedon Feb 4, 2022
yeah I agree it's a good idea but I also agree with this bit :(
and that's why it's not been generically implemented
pre-commit.ci has a bit of this implemented for normalization purposes -- but doing this generically is a hard problem:
sirosen commentedon Feb 4, 2022
I'd suggest putting it in a separate project (I'd just go off and write it myself), but it's such a "pre-commit checks pre-commit config" hook that I almost suggested it as one of the "meta" hooks in
pre-commititself.Would you be interested in this as a part of
pre-commit? It could be made part of the behavior ofautoupdateto check for redirects. I thought it would be easier to implement as a hook, but after reading your points, it seems likeauotupdatemight be the right place for it.asottile commentedon Feb 4, 2022
I've already declined such a feature in pre-commit itself because of the reasons above
sirosen commentedon Feb 4, 2022
Looking for a past issue or PR, I see this comment. I'm not clear if the pre-commit.ci feature mentioned there is the normalization of which you spoke here.
That issue mentions
gitbehavior being complicated (presumablyautoupdatestarts by cloning). I was considering something doing an HTTP GET, even ifautoupdateis not doing that already.Perhaps this makes more sense as a flag to
autoupdate, like--check-http-redirects? Or maybe I'm still underestimating the complexity.If this issue was dead-on-arrival, let's just close. I'm happy to help if there's a feature I could work on, but if not, there's no point spending more time on this topic. :-)
asottile commentedon Feb 4, 2022
ah yeah it was discussed further here: pre-commit/pre-commit#2003
sirosen commentedon Feb 4, 2022
Just thinking about possibilities, is it possible to use the same yaml conf for https://pre-commit.com/hooks somehow?
I'd be perfectly well satisfied with
--warn-unknown-hooks:This easily could get very annoying if you have hooks which aren't on the site, unless an ignore mechanism is added.
I do not like that, but it's all I can think of if we don't add to config. 😿
But even without an ignore mechanism, this would be handy for the majority of users.
As another alternative direction, allow the command to consume some kind of listing of user specified known repo moves. And check redirects (optionally) without trying to follow them.
e.g.
There's no redirect looping or following issue because it doesn't follow redirects.
We don't get stymied trying to track repo moves.
It can be added as a hook as long as it gets skipped in pre-commit.ci config.
asottile commentedon Feb 4, 2022
I don't really want to introduce
pre-commit.comorpre-commit.cias a critical-path component for pre-commit's operation -- part of the current design is it's entirely "distributed" and doesn't have any phone-homesirosen commentedon Feb 28, 2022
I'm still trying to think up a reasonable way of handling this. (Should I not? You can close as far as I'm concerned if you think the problem doesn't have a good, tractable solution.)
How 👍/👎 would you be on the idea of a new key in hook config which states the "canonical repo" of a hook? The hook owner can then "publish" their rename. That might also help in the case of a hook moving between repos.
It's not perfect, but it avoids centralizing the information.
asottile commentedon Feb 28, 2022
yeah I kinda wrote that off here -- the hook config is a top-level list so there isn't a good place to put it pre-commit/pre-commit#2003 (comment)
I'm going to close this 👍