Skip to content

pre-push hooks are intentionally not run on ref deletion #3050

Description

@whophil

search you tried in the issue tracker

pre-push

describe your issue

I am attempting to write a pre-push hook which prevents tag deletion.

By way of print statements, I observe the following behavior.

When I install the pre-push hook via pre-commit:

  • I push a tag with git push origin tmptag, the hook is invoked.
  • I delete a tag with git push origin :tmptag, the hook is not invoked

In contrast, if I forgo pre-commit and manually put a pre-push file in my .git/hooks/ folder

  • I push a tag with git push origin tmptag, the hook is invoked.
  • I delete a tag with git push origin :tmptag, the hook is invoked

Am I misunderstanding how the pre-push hook of pre-commit is supposed to work? Or is there some logic within pre-commit to skip the execution of pre-push hooks under certain circumstances?

pre-commit --version

3.3.3

.pre-commit-config.yaml

- repo: local
    hooks:
      - id: prevent-tag-deletion
        name: prevent tag deletion
        entry: python
        language: system
        args: ['pre_push.py']
        stages: [pre-push]
        verbose: true

~/.cache/pre-commit/pre-commit.log (if present)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions