Skip to content

forbid-new-submodules marked not applicable on repo w/o submodules #707

@ChiefGokhlayeh

Description

@ChiefGokhlayeh

This might be intended behavior, but I'd like to get confirmation.

Since 4.1.0, meta-hook check-hooks-apply marks forbid-new-submodules as "does not apply", if the repo does not contain any submodules.

The hook forbid-new-submodules itself correctly warns when adding submodules to a previously empty repo, so it technically does apply.

This might have to do with the changes introduced in #619.

Steps to reproduce:

  1. Create new repo
    $ git init issue-707 && cd issue-707
  2. Create .pre-commit-config.yaml with following content:
    repos:
      - repo: https://github.com/pre-commit/pre-commit-hooks
        rev: v4.1.0
        hooks:
          - id: forbid-new-submodules
      - repo: meta
        hooks:
          - id: check-hooks-apply
  3. Commit .pre-commit-config.yaml
    $ git add .pre-commit-config.yaml && git commit -m "Add pre-commit config"
  4. Run the following:
    $ pre-commit run --all
    forbid new submodules................................(no files to check)Skipped
    Check hooks apply to the repository......................................Failed
    - hook id: check-hooks-apply
    - exit code: 1
    
    forbid-new-submodules does not apply to this repository
  5. Add submodule and force-commit
    $ git submodule add https://github.com/pre-commit/pre-commit-hooks.git
    $ git commit -m "Add some submodule" -n
  6. Run the following:
    $ pre-commit run --all
    forbid new submodules....................................................Passed
    Check hooks apply to the repository......................................Passed

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