Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tag_and_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
branches:
- main
paths:
- "pre_commit_hooks/__init__.py"
- "pre_commit_jgstew/__init__.py"
- ".github/workflows/tag_and_release.yaml"

# creates git tags and GitHub releases (and uploads the wheel), so the job
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/test_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
run: if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Test python import from src
shell: bash
run: python -c "import pre_commit_hooks; print(pre_commit_hooks.__version__)"
run: python -c "import pre_commit_jgstew; print(pre_commit_jgstew.__version__)"
- name: Run pytest
shell: bash
run: |
Expand All @@ -65,22 +65,22 @@ jobs:
run: pip install $(find "dist" -type f -name "*.whl")
- name: Test python import
shell: bash
run: python -c "import pre_commit_hooks; print(pre_commit_hooks.__version__)"
run: python -c "import pre_commit_jgstew; print(pre_commit_jgstew.__version__)"
- name: Test pre-commit hook invoke
shell: bash
run: python -c "import pre_commit_hooks.git_clean; pre_commit_hooks.git_clean.main()"
run: python -c "import pre_commit_jgstew.git_clean; pre_commit_jgstew.git_clean.main()"
- name: Test pre-commit hook invoke
shell: bash
run: python -c "import pre_commit_hooks.minimum_changes; pre_commit_hooks.minimum_changes.main()"
run: python -c "import pre_commit_jgstew.minimum_changes; pre_commit_jgstew.minimum_changes.main()"
- name: Test pre-commit hook invoke
shell: bash
run: python -c "import pre_commit_hooks.regex_search_filter_replace; pre_commit_hooks.regex_search_filter_replace.main()"
run: python -c "import pre_commit_jgstew.regex_search_filter_replace; pre_commit_jgstew.regex_search_filter_replace.main()"
- name: Test pre-commit hook invoke
shell: bash
run: python -c "import pre_commit_hooks.revert_missing_change; pre_commit_hooks.revert_missing_change.main()"
run: python -c "import pre_commit_jgstew.revert_missing_change; pre_commit_jgstew.revert_missing_change.main()"
- name: Test pre-commit hook invoke
shell: bash
run: python -c "import pre_commit_hooks.validate_plist; pre_commit_hooks.validate_plist.main()"
run: python -c "import pre_commit_jgstew.validate_plist; pre_commit_jgstew.validate_plist.main()"
- name: pip install of pre-commit
shell: bash
run: pip install pre-commit
Expand Down
25 changes: 13 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ repos:
hooks:
- id: minimum-changes
args: [--min-changes=0]
stages: [manual]
- id: verify-files-are-ascii

- repo: https://github.com/python-jsonschema/check-jsonschema
Expand Down Expand Up @@ -105,7 +106,7 @@ repos:
stages: [manual]
- id: python-use-type-annotations
stages: [manual]
exclude: ^pre_commit_hooks/autopkg_recipe_check_conventions.py$
exclude: ^pre_commit_jgstew/autopkg_recipe_check_conventions.py$
- id: python-no-eval
stages: [manual]
- id: python-check-blanket-type-ignore
Expand All @@ -127,7 +128,7 @@ repos:
(?x)^(
README.md|
pyproject.toml|
pre_commit_hooks/__init__.py|
pre_commit_jgstew/__init__.py|
setup.cfg|
setup.py
)$
Expand Down Expand Up @@ -201,15 +202,15 @@ repos:
# - anyascii

# Local Hooks:
# https://towardsdatascience.com/getting-started-with-python-pre-commit-hooks-28be2b2d09d5
# https://towardsdatascience.com/getting-started-with-python-pre-commit-jgstew-28be2b2d09d5
# language: python -> pre-commit provisions an isolated venv, so bare `python`
# always resolves (no dependence on a system `python` shim). Third-party
# imports must be declared via additional_dependencies.
- repo: local
hooks:
- id: validate-bes-local
name: validate-bes-local
entry: python pre_commit_hooks/validate_bes.py
entry: python pre_commit_jgstew/validate_bes.py
language: python
# isolated venv: declare the third-party import used by validate_bes.py
additional_dependencies: [validate_bes_xml]
Expand All @@ -219,7 +220,7 @@ repos:
hooks:
- id: verify-files-contain-entry-local
name: verify-files-contain-entry-local
entry: python pre_commit_hooks/verify_files_contain_entry.py
entry: python pre_commit_jgstew/verify_files_contain_entry.py
language: python
pass_filenames: True
files: \.bes$
Expand All @@ -232,7 +233,7 @@ repos:
hooks:
- id: verify-files-contain-pattern-local
name: verify-files-contain-pattern-local
entry: python pre_commit_hooks/verify_files_contain_pattern.py
entry: python pre_commit_jgstew/verify_files_contain_pattern.py
language: python
pass_filenames: True
files: \.test_file$
Expand All @@ -241,7 +242,7 @@ repos:
hooks:
- id: minimum-changes-local
name: minimum-changes-local
entry: python pre_commit_hooks/minimum_changes.py
entry: python pre_commit_jgstew/minimum_changes.py
language: python
pass_filenames: True
args: [--min-changes=2]
Expand All @@ -250,14 +251,14 @@ repos:
hooks:
- id: git-clean
name: git-clean-local
entry: python pre_commit_hooks/git_clean.py
entry: python pre_commit_jgstew/git_clean.py
language: python
files: .test_file
# - repo: local
# hooks:
# - id: revert-missing-change
# name: revert-missing-change-local
# entry: python pre_commit_hooks/revert_missing_change.py
# entry: python pre_commit_jgstew/revert_missing_change.py
# language: python
# pass_filenames: True
# args: ['--change_regex=v[0-9]+(\.[0-9]+)*\s*</Title>']
Expand All @@ -266,7 +267,7 @@ repos:
hooks:
- id: github-action-set-output-fix
name: github-action-set-output-fix-local
entry: python pre_commit_hooks/github_action_set_output_fix.py
entry: python pre_commit_jgstew/github_action_set_output_fix.py
language: python
pass_filenames: True
args: ['--overwrite']
Expand All @@ -284,7 +285,7 @@ repos:
hooks:
- id: add-missing-docstrings
name: add-missing-docstrings
entry: python pre_commit_hooks/add_main_docstring.py
entry: python pre_commit_jgstew/add_main_docstring.py
language: python
pass_filenames: True
- repo: local
Expand All @@ -294,7 +295,7 @@ repos:
# `check-processor-conventions` hook; see README / jgstew-recipes.
- id: check-processor-conventions
name: check-processor-conventions-local
entry: python pre_commit_hooks/autopkg_processor_check_conventions.py
entry: python pre_commit_jgstew/autopkg_processor_check_conventions.py
language: python
pass_filenames: True
args: ["--auto-fix=no"]
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pre-commit-hooks
# pre-commit-jgstew

custom pre-commit hooks by JGStew.

Expand Down Expand Up @@ -48,21 +48,21 @@ The AutoPkg convention hooks (`check-processor-conventions`, `check-recipe-conve

## Test commands:

- test python import and version: `python -c "import pre_commit_hooks; print(pre_commit_hooks.__version__)"`
- test python import and version: `python -c "import pre_commit_jgstew; print(pre_commit_jgstew.__version__)"`
- test version defined through [setup.py](setup.py): `python setup.py --version`
- version defined in [setup.cfg](setup.cfg): `version = attr: pre_commit_hooks.__version__`
- version defined in [setup.cfg](setup.cfg): `version = attr: pre_commit_jgstew.__version__`
- test builds:
- `python ./setup.py build`
- `python -m build`
- test pre-commit locally: `pre-commit try-repo .`

## creating a new hook to add to this repo:

create python file in folder [pre_commit_hooks](pre_commit_hooks) with name of hook with underscores.py
create python file in folder [pre_commit_jgstew](pre_commit_jgstew) with name of hook with underscores.py

add entrypoint to the [setup.cfg](setup.cfg) file

add hook definition to the [.pre-commit-hooks.yaml](.pre-commit-hooks.yaml) file
add hook definition to the [.pre-commit-jgstew.yaml](.pre-commit-jgstew.yaml) file

add example hook to actually use in the [.pre-commit-config.yaml](.pre-commit-config.yaml) file

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
echo +(["']::set-output +name=(\S+?)::(.+?)["'])(?:$| \|)

Invoke this standalone:
python3 pre_commit_hooks/github_action_set_output_fix.py .github/workflows/tag_and_release.yaml
python3 pre_commit_jgstew/github_action_set_output_fix.py .github/workflows/tag_and_release.yaml
"""

import argparse
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ build-backend = "setuptools.build_meta"
ignore-words-list = "caf"

[tool.pytest.ini_options]
# Put the repo root on sys.path so `from pre_commit_hooks import ...` resolves
# Put the repo root on sys.path so `from pre_commit_jgstew import ...` resolves
# from source without the package being installed. Without this, running the
# bare `pytest` console script (as the pre-commit pytest hook does, in an
# isolated env where the package is not installed) fails to import the package.
Expand Down
36 changes: 18 additions & 18 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = pre-commit-hooks
version = attr: pre_commit_hooks.__version__
name = pre-commit-jgstew
version = attr: pre_commit_jgstew.__version__
author = JGStew
author_email = noreply@jgstew.com
description = custom Python based pre-commit hooks
Expand All @@ -22,7 +22,7 @@ classifiers =
[options]
package_dir =
= .
packages = pre_commit_hooks
packages = pre_commit_jgstew
python_requires = >=3.5
install_requires =
validate_bes_xml
Expand All @@ -38,18 +38,18 @@ test =

[options.entry_points]
console_scripts =
minimum-changes = pre_commit_hooks.minimum_changes:main
validate-bes = pre_commit_hooks.validate_bes:main
verify-files-contain-entry = pre_commit_hooks.verify_files_contain_entry:main
verify-files-contain-pattern = pre_commit_hooks.verify_files_contain_pattern:main
verify-files-are-ascii = pre_commit_hooks.verify_files_are_ascii:main
fix-files-to-ascii = pre_commit_hooks.fix_files_to_ascii:main
git-clean = pre_commit_hooks.git_clean:main
regex-search-filter-replace = pre_commit_hooks.regex_search_filter_replace:main
revert-missing-change = pre_commit_hooks.revert_missing_change:main
validate-plist = pre_commit_hooks.validate_plist:main
github-action-set-output-fix = pre_commit_hooks.github_action_set_output_fix:main
add-missing-docstrings = pre_commit_hooks.add_main_docstring:main
check-processor-conventions = pre_commit_hooks.autopkg_processor_check_conventions:main
check-recipe-conventions = pre_commit_hooks.autopkg_recipe_check_conventions:main
check-bes-conventions = pre_commit_hooks.bigfix_bes_check_conventions:main
minimum-changes = pre_commit_jgstew.minimum_changes:main
validate-bes = pre_commit_jgstew.validate_bes:main
verify-files-contain-entry = pre_commit_jgstew.verify_files_contain_entry:main
verify-files-contain-pattern = pre_commit_jgstew.verify_files_contain_pattern:main
verify-files-are-ascii = pre_commit_jgstew.verify_files_are_ascii:main
fix-files-to-ascii = pre_commit_jgstew.fix_files_to_ascii:main
git-clean = pre_commit_jgstew.git_clean:main
regex-search-filter-replace = pre_commit_jgstew.regex_search_filter_replace:main
revert-missing-change = pre_commit_jgstew.revert_missing_change:main
validate-plist = pre_commit_jgstew.validate_plist:main
github-action-set-output-fix = pre_commit_jgstew.github_action_set_output_fix:main
add-missing-docstrings = pre_commit_jgstew.add_main_docstring:main
check-processor-conventions = pre_commit_jgstew.autopkg_processor_check_conventions:main
check-recipe-conventions = pre_commit_jgstew.autopkg_recipe_check_conventions:main
check-bes-conventions = pre_commit_jgstew.bigfix_bes_check_conventions:main
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Shared pytest fixtures for the pre_commit_hooks test suite."""
"""Shared pytest fixtures for the pre_commit_jgstew test suite."""

import subprocess
from pathlib import Path
Expand Down
4 changes: 2 additions & 2 deletions tests/test_add_main_docstring.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Tests for pre_commit_hooks/add_main_docstring.py."""
"""Tests for pre_commit_jgstew/add_main_docstring.py."""

import sys

from pre_commit_hooks import add_main_docstring as hook
from pre_commit_jgstew import add_main_docstring as hook

MISSING = """\
def main():
Expand Down
4 changes: 2 additions & 2 deletions tests/test_autopkg_processor_check_conventions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
"""Tests for pre_commit_hooks/autopkg_processor_check_conventions.py.
"""Tests for pre_commit_jgstew/autopkg_processor_check_conventions.py.

These exercise the public helpers (processor detection, the stub heuristic,
discovery) and the check/auto-fix pipeline via check_file/check_files, plus the
Expand All @@ -16,7 +16,7 @@

import pytest

from pre_commit_hooks import autopkg_processor_check_conventions as checker
from pre_commit_jgstew import autopkg_processor_check_conventions as checker

# A fully convention-conforming processor (no E-codes expected). The class name
# must match the filename stem, so write this as `ExampleClean.py`.
Expand Down
4 changes: 2 additions & 2 deletions tests/test_autopkg_recipe_check_conventions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
"""Tests for pre_commit_hooks/autopkg_recipe_check_conventions.py.
"""Tests for pre_commit_jgstew/autopkg_recipe_check_conventions.py.

These exercise the recipe convention checks (W100-W123), their auto-fixers, the
file-level opt-out markers, and main()'s exit codes. Cross-file checks (duplicate
Expand All @@ -11,7 +11,7 @@

import pytest

from pre_commit_hooks import autopkg_recipe_check_conventions as checker
from pre_commit_jgstew import autopkg_recipe_check_conventions as checker

PLIST = """<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
Expand Down
4 changes: 2 additions & 2 deletions tests/test_bigfix_bes_check_conventions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
"""Tests for pre_commit_hooks/bigfix_bes_check_conventions.py.
"""Tests for pre_commit_jgstew/bigfix_bes_check_conventions.py.

These exercise the BES content checks (E200-E214, W200-W211), the auto-fixers
(DownloadSize, missing dates, blank-line collapse, CDATA wrap, Title trim,
Expand All @@ -11,7 +11,7 @@

import pytest

from pre_commit_hooks import bigfix_bes_check_conventions as checker
from pre_commit_jgstew import bigfix_bes_check_conventions as checker

FIXED_NOW = datetime(2026, 7, 14, 18, 32, 35, tzinfo=timezone.utc)

Expand Down
4 changes: 2 additions & 2 deletions tests/test_fix_files_to_ascii.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Tests for pre_commit_hooks/fix_files_to_ascii.py.
"""Tests for pre_commit_jgstew/fix_files_to_ascii.py.

Requires the `anyascii` package (installed via install_requires); skipped where
it is not available.
Expand All @@ -8,7 +8,7 @@

pytest.importorskip("anyascii")

from pre_commit_hooks import fix_files_to_ascii as hook # noqa: E402
from pre_commit_jgstew import fix_files_to_ascii as hook # noqa: E402


def write(tmp_path, name, text):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_git_clean.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Tests for pre_commit_hooks/git_clean.py."""
"""Tests for pre_commit_jgstew/git_clean.py."""

from pre_commit_hooks import git_clean as hook
from pre_commit_jgstew import git_clean as hook


def test_clean_repo_reports_zero(git_repo, monkeypatch):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_github_action_set_output_fix.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Tests for pre_commit_hooks/github_action_set_output_fix.py."""
"""Tests for pre_commit_jgstew/github_action_set_output_fix.py."""

from pre_commit_hooks import github_action_set_output_fix as hook
from pre_commit_jgstew import github_action_set_output_fix as hook

SET_OUTPUT_LINE = ' run: echo "::set-output name=version::1.2.3"\n'
SAVE_STATE_LINE = ' run: echo "::save-state name=foo::bar"\n'
Expand Down
4 changes: 2 additions & 2 deletions tests/test_minimum_changes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Tests for pre_commit_hooks/minimum_changes.py."""
"""Tests for pre_commit_jgstew/minimum_changes.py."""

from pre_commit_hooks import minimum_changes as hook
from pre_commit_jgstew import minimum_changes as hook


def test_small_staged_change_fails(git_repo, monkeypatch):
Expand Down
Loading
Loading