diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index a79dff6..f879abf 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -1,6 +1,6 @@ -- id: cloc - name: Count comment in files - description: Check if file contain at least more than 0% of comment - entry: pre_commit_hooks/cloc.sh +- id: check-comments + name: Count comments in files + description: Check if file contains at least more than 0% of comments + entry: pre_commit_hooks/check-comments.sh language: script types: [python] diff --git a/README.md b/README.md index 49fc934..4a365a0 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,21 @@ # pre-commit-cloc -A pre-commit hook to check comments in file + +A `pre-commit` hook to check comments in file. + +## Installation + +Add the following to your + +``` + - repo: https://github.com/alma/pre-commit-cloc + rev: v0.0.5 + hooks: + - id: check-comments +``` + +## Dependencies + +The hook relies on: + +* [cloc](https://github.com/AlDanial/cloc) +* [jq](https://stedolan.github.io/jq/) diff --git a/pre_commit_hooks/cloc.sh b/pre_commit_hooks/check-comments.sh similarity index 88% rename from pre_commit_hooks/cloc.sh rename to pre_commit_hooks/check-comments.sh index 1f0ad1a..ef2a2c0 100755 --- a/pre_commit_hooks/cloc.sh +++ b/pre_commit_hooks/check-comments.sh @@ -18,8 +18,8 @@ if ! command which jq &>/dev/null; then fi if [[ "$(cloc --json "$@" | jq '.SUM.comment')" -eq 0 ]]; then - >&2 echo "file $@ contains 0 comment" - exit 1 + >&2 echo "File $@ contains 0 comments" + exit 1 fi exit 0