From 128e46aa48ab4a82c6734f17a00350c49bc385cc Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Tue, 2 Sep 2025 11:09:49 +0200 Subject: [PATCH] precommit: Add pre-commit hook to check copyright in ros2 files --- .github/workflows/pre-commit.yml | 3 +++ .pre-commit-config.yaml | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 94eaa3a319..bee3f93112 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -12,3 +12,6 @@ jobs: with: python-version: 3.x - uses: pre-commit/action@v3.0.1 + - run: python3 -m pip install --upgrade pip + - run: python3 -m pip install pytest + - run: PYTHONPATH="." pytest tests/test_pre_commit_copyright.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2a9d63d8f9..e9d0001879 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -78,6 +78,22 @@ repos: additional_dependencies: - tomli + - repo: local + hooks: + - id: check-copyright + name: check copyright notice in files + entry: Tools/gittools/pre_commit_copyright.py + language: python + files: | + (?x)^( + Tools/ros2/.*\.py + )$ + args: [ + --ignore=Tools/ros2/ardupilot_dds_tests/setup.py, + --ignore=Tools/ros2/ardupilot_dds_tests/test/test_pep257.py, + --ignore=Tools/ros2/ardupilot_dds_tests/test/test_copyright.py, + ] + # # Use to sort python imports by name and put system import first. # - repo: https://github.com/pycqa/isort # rev: 5.12.0