Skip to content

pre-commit.ci autoupdate PR asks to downgrade revision from commit SHA to older tag #1957

@scottclowe

Description

@scottclowe

Setup

I'm using rev: some_commit_sha in .pre-commit-config.yaml.

I can't use a tag because the latest tag doesn't contain a feature I need. I would rather use a stable revision over the unstable pointer to the master/main branch because this is better practice and ensures everyone using the repository is working with the same pre-commit hooks.

Problem

The autoupdate feature of [pre-commit.ci] is issuing a PR asking to upgrade the revision to the latest tag. However the latest tag is older than the revision I have pinned, so moving to the latest tag would actually be a downgrade not an upgrade.

Full example

I'm using black_nbconvert to automatically blacken notebooks. It's a great tool, but not seen any updates in the last 2 years. The latest release (v0.2.0, Oct 2019) can't handle notebook cells containing cell magic, whereas the bleeding-edge version can.

Contents of .pre-commit-config.yaml:

repos:
  - repo: https://github.com/dfm/black_nbconvert
    rev: dcd7789
    hooks:
      - id: black_nbconvert

PRs issued by pre-commit.ci here rochefort-lab/fissa#196 and rochefort-lab/fissa#216 both want to do github.com/dfm/black_nbconvert: dcd7789 → v0.2.0 which is a downgrade.
If you reverse the comparison you can see the two commits which are being dropped by the autoupdate PR.

I've asked the author of black_nbconvert to release a new tag with cell magic support (dfm/black_nbconvert#3), which would solve things for this one pre-commit hook but not the problem in general.

What is the best solution? Maybe autoupdate should never try to change revisions which have been pinned to a tag, but to never change revisions pinned to a commit SHA? I'm not sure if this is best, but what seems clear is that autoupdate should not issue a PR asking for a revision to be changed to one that corresponds to an older revision which loses commits without adding any new ones.

Apologies if this is not the right place for pre-commit.ci autoupdate issues. I couldn't see somewhere else to put this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions