Skip to content

Commit

Permalink
Merge pull request #1 from alma/improve-pre-commit
Browse files Browse the repository at this point in the history
Some improvements
  • Loading branch information
rodo authored Jul 29, 2021
2 parents c364ff0 + 07a6a3b commit f4f7b34
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -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]
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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/)
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit f4f7b34

Please sign in to comment.