mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Merge pull request #6691 from jbampton/add-pre-commit-hook
pre-commit: add hook to ensure Makefiles are indented with tabs
This commit is contained in:
@@ -29,6 +29,15 @@ repos:
|
||||
additional_dependencies: ["prettier@3.7.4"]
|
||||
pass_filenames: false
|
||||
stages: [manual]
|
||||
- id: check-makefile-indentation
|
||||
name: check Makefiles are indented with tabs
|
||||
description: ensures that Makefiles are indented with tabs
|
||||
entry: ./scripts/check_makefiles_for_tabs.sh
|
||||
language: system
|
||||
files: "(?i)^makefile$"
|
||||
pass_filenames: true # <-- Crucial change: pass filenames to the script
|
||||
types: [file] # Ensure only regular files are passed, not directories
|
||||
stages: [manual]
|
||||
- id: check-zip-file-is-not-committed
|
||||
name: disallow zip files
|
||||
description: Zip files are not allowed in the repository
|
||||
|
||||
Executable
+13
@@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Iterate over all files passed as arguments by pre-commit
|
||||
for makefile in "$@"; do
|
||||
# Check if the file exists and is a regular file
|
||||
if [[ -f "$makefile" ]]; then
|
||||
if grep -P '^\s' "$makefile" | grep -vP '^\t' > /dev/null; then
|
||||
echo "Error: File '$makefile' contains spaces at the beginning of lines instead of tabs."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
exit 0
|
||||
Reference in New Issue
Block a user