Skip to content

redirect repo #2003

Closed
Closed

Description

@frnmst

Hello,

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-toc
  name: Update markdown table-of-contents
  description: 'Replace TOC marker with a table of contents'
  language: python
  types: [markdown]  # as detected by pre-commit with identify-cli
  entry: md_toc
  args: [-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?

Activity

  1. asottile commented on Aug 9, 2021

    @asottile
    Member

    there's a couple of issues:

    • 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

    what do you think?

  2. frnmst commented on Aug 9, 2021

    @frnmst
    Author

    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

  3. asottile commented on Aug 9, 2021

    @asottile
    Member

    I'd rather not add a new file just for this.

    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

  4. frnmst commented on Aug 10, 2021

    @frnmst
    Author

    Thank you I'll try that.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions