From 68ced830d708a8fa5fcd9a90681c8428b5ebc9f9 Mon Sep 17 00:00:00 2001 From: Vadym Zakovinko Date: Fri, 24 Feb 2023 21:14:05 +0200 Subject: [PATCH 1/2] add pre-commit plugin to check of license header in source files, fixes #562 --- .pre-commit-config.yaml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e0666ea8..ed3660fc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,3 +26,22 @@ repos: - id: check-added-large-files - id: check-shebang-scripts-are-executable exclude: "\\.mustache$" + - repo: https://github.com/Quard/license-header-checker + rev: v0.1 + hooks: + - id: license-header-checker + files: \.(c|h|dtsi|dts|overlay|keymap)$ + exclude: ^((app/boards/)|(app/tests/)) + args: + - --comment-style + - "/*| *| */" + - --license + - "\\nCopyright \\(c\\) \\d{4}(-\\d{4})? The ZMK Contributors\\n\\nSPDX-License-Identifier: MIT\\n" + - id: license-header-checker + files: (\.yaml)|(CMakeLists.txt)|(Kconfig)$ + exclude: ^((app/boards/)|(app/tests/)|(\.pre-commit-config.yaml)) + args: + - --comment-style + - "#" + - --license + - "Copyright \\(c\\) \\d{4}(-\\d{4})? The ZMK Contributors\\nSPDX-License-Identifier: MIT" From 92fe17851969c8181d15a463e13553f99822b9e1 Mon Sep 17 00:00:00 2001 From: Vadym Zakovinko Date: Thu, 25 May 2023 18:48:58 +0300 Subject: [PATCH 2/2] pre-commit header license checker with auto population --- .pre-commit-config.yaml | 8 ++++++-- .pre-commit/license_header.tmpl | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 .pre-commit/license_header.tmpl diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ed3660fc..1ab56b11 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -27,7 +27,7 @@ repos: - id: check-shebang-scripts-are-executable exclude: "\\.mustache$" - repo: https://github.com/Quard/license-header-checker - rev: v0.1 + rev: v0.2.1 hooks: - id: license-header-checker files: \.(c|h|dtsi|dts|overlay|keymap)$ @@ -37,6 +37,8 @@ repos: - "/*| *| */" - --license - "\\nCopyright \\(c\\) \\d{4}(-\\d{4})? The ZMK Contributors\\n\\nSPDX-License-Identifier: MIT\\n" + - --auto-populate + - .pre-commit/license_header.tmpl - id: license-header-checker files: (\.yaml)|(CMakeLists.txt)|(Kconfig)$ exclude: ^((app/boards/)|(app/tests/)|(\.pre-commit-config.yaml)) @@ -44,4 +46,6 @@ repos: - --comment-style - "#" - --license - - "Copyright \\(c\\) \\d{4}(-\\d{4})? The ZMK Contributors\\nSPDX-License-Identifier: MIT" + - "\\s*Copyright \\(c\\) \\d{4}(-\\d{4})? The ZMK Contributors\\n\\s*SPDX-License-Identifier: MIT" + - --auto-populate + - .pre-commit/license_header.tmpl diff --git a/.pre-commit/license_header.tmpl b/.pre-commit/license_header.tmpl new file mode 100644 index 00000000..88af9ad1 --- /dev/null +++ b/.pre-commit/license_header.tmpl @@ -0,0 +1,3 @@ +Copyright (c) {YEAR} The ZMK Contributors + +SPDX-License-Identifier: MIT \ No newline at end of file