forked from TrueCloudLab/frostfs-api
[#58] pre-commit: Add pre-commit and related Makefile targets
Signed-off-by: Aleksey Savchuk <a.savchuk@yadro.com>
This commit is contained in:
parent
54812ba857
commit
6b0f3b01e0
3 changed files with 52 additions and 1 deletions
24
.pre-commit-config.yaml
Normal file
24
.pre-commit-config.yaml
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
repos:
|
||||||
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
rev: v4.6.0
|
||||||
|
hooks:
|
||||||
|
- id: check-added-large-files
|
||||||
|
- id: check-case-conflict
|
||||||
|
- id: check-executables-have-shebangs
|
||||||
|
- id: check-shebang-scripts-are-executable
|
||||||
|
- id: check-merge-conflict
|
||||||
|
- id: check-json
|
||||||
|
- id: check-xml
|
||||||
|
- id: check-yaml
|
||||||
|
- id: trailing-whitespace
|
||||||
|
args: [--markdown-linebreak-ext=md]
|
||||||
|
- id: end-of-file-fixer
|
||||||
|
exclude: ".svg$"
|
||||||
|
|
||||||
|
- repo: local
|
||||||
|
hooks:
|
||||||
|
- id: make-fmt
|
||||||
|
name: Run make fmt
|
||||||
|
entry: make fmt
|
||||||
|
language: system
|
||||||
|
pass_filenames: false
|
18
Makefile
18
Makefile
|
@ -1,7 +1,10 @@
|
||||||
#!/usr/bin/make -f
|
#!/usr/bin/make -f
|
||||||
SHELL=bash
|
SHELL=bash
|
||||||
|
|
||||||
.PHONY: doc
|
include help.mk
|
||||||
|
|
||||||
|
.PHONY: doc fmt pre-commit unpre-commit pre-commit-run
|
||||||
|
|
||||||
# Regenerate documentation for proto files:
|
# Regenerate documentation for proto files:
|
||||||
doc:
|
doc:
|
||||||
@for f in `find . -type f -name '*.proto' -exec dirname {} \; | sort -u `; do \
|
@for f in `find . -type f -name '*.proto' -exec dirname {} \; | sort -u `; do \
|
||||||
|
@ -12,8 +15,21 @@ doc:
|
||||||
--doc_out=proto-docs/ $${f}/*.proto; \
|
--doc_out=proto-docs/ $${f}/*.proto; \
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Run clang-format
|
||||||
fmt:
|
fmt:
|
||||||
@for f in `ls **/*.proto`; do \
|
@for f in `ls **/*.proto`; do \
|
||||||
echo "⇒ Formatting $$f"; \
|
echo "⇒ Formatting $$f"; \
|
||||||
clang-format -i $$f; \
|
clang-format -i $$f; \
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Activate pre-commit hooks
|
||||||
|
pre-commit:
|
||||||
|
pre-commit install --hook-type pre-commit
|
||||||
|
|
||||||
|
# Deactivate pre-commit hooks
|
||||||
|
unpre-commit:
|
||||||
|
pre-commit uninstall --hook-type pre-commit
|
||||||
|
|
||||||
|
# Run pre-commit hooks
|
||||||
|
pre-commit-run:
|
||||||
|
@pre-commit run --all-files --hook-stage manual
|
||||||
|
|
11
help.mk
Normal file
11
help.mk
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
.PHONY: help
|
||||||
|
|
||||||
|
# Show this help prompt
|
||||||
|
help:
|
||||||
|
@echo ' Usage:'
|
||||||
|
@echo ''
|
||||||
|
@echo ' make <target>'
|
||||||
|
@echo ''
|
||||||
|
@echo ' Targets:'
|
||||||
|
@echo ''
|
||||||
|
@awk '/^#/{ comment = substr($$0,3) } /^[a-zA-Z][a-zA-Z0-9_-]+:/{ print " ", $$1, comment; comment = "" }' $(MAKEFILE_LIST) | column -t -s ':' | grep -v 'IGNORE' | sort | uniq
|
Loading…
Reference in a new issue