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 wonder if it's possible to redirect a repo URL in the pre-commit-config file: this might be useful if the developer of a hook
moves the repo home repository, for example from github to gitlab. Can this be implemented by adding a redirect_repo key
(or something) in the .pre-commit-hooks.yaml file of the old repository? As a reference here is one of my hooks with the new key:
- id: md-tocname: Update markdown table-of-contentsdescription: 'Replace TOC marker with a table of contents'language: pythontypes: [markdown] # as detected by pre-commit with identify-clientry: md_tocargs: [-p, github]redirect_repo: https://some.other.url/frnmst/md-toc
This feature should work with the autoupdate command. Things like infinite redirects must be avoided of course.
What do you think?
there's only hook-level in .pre-commit-hooks.yaml and no good place to put the value (would probably need to move to top-level map which is a big change)
the infinite redirects thing is very tricky, I don't really know of a good way to solve it (without actually tracing the redirect)
in the past this has been handled with documentation and a small allowlist for https://pre-commit.ci -- as the case is pretty rare I'm not sure the complexity is worth the change
Yes it's tricky. What about something simpler: adding an option that prints a notice (something like: "the repo url has changed to https://x.y.z please change your configuration") when autoupdate is run? As you say, if .pre-commit-hooks.yaml is not the right place maybe a new file like .pre-commit-updates.yaml is. A developer could add a notice not just when a repository is migrated, but also if a major change in a configuration file used by a hook is to be done
what I've done in the past for this is use the name field of hooks to communicate deprecation -- and then when fully sunset change them to language: fail hooks -- pre-commit/pre-commit-hooks did this for example
Activity
asottile commentedon Aug 9, 2021
there's a couple of issues:
.pre-commit-hooks.yamland no good place to put the value (would probably need to move to top-level map which is a big change)what do you think?
frnmst commentedon Aug 9, 2021
Yes it's tricky. What about something simpler: adding an option that prints a notice (something like: "the repo url has changed to https://x.y.z please change your configuration") when autoupdate is run? As you say, if
.pre-commit-hooks.yamlis not the right place maybe a new file like.pre-commit-updates.yamlis. A developer could add a notice not just when a repository is migrated, but also if a major change in a configuration file used by a hook is to be doneasottile commentedon Aug 9, 2021
I'd rather not add a new file just for this.
what I've done in the past for this is use the
namefield of hooks to communicate deprecation -- and then when fully sunset change them tolanguage: failhooks -- pre-commit/pre-commit-hooks did this for examplefrnmst commentedon Aug 10, 2021
Thank you I'll try that.