Skip to content

feat: ✨ add godoc-hl #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,10 @@
files: '\.go$'
language: "script"
description: "Runs `go-ruleguard`, install https://github.com/quasilyte/go-ruleguard"

- id: go-dochl
name: "go-dochl"
entry: run-go-dochl.sh
files: '\.go$'
language: "script"
description: "Runs go-dochl, to extract comment before commit"
21 changes: 21 additions & 0 deletions run-go-dochl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh

if ! command -v go-dochl 2>&1 /dev/null
then
echo "Error: go-dochl not found. Please install it by running 'go get -u github.com/diontr00/dochl@latest' and ensure it is in your PATH."
exit 1
fi

KEY="$1"

# Run dochl with provided arguments or default
dochl_output=$(go-dochl -keys="$KEY" "$@")

# Check if dochl found any matching comments
if [ -n "$dochl_output" ]; then
echo "You have work todo. Commit rejected."
go-dochl -keys="$KEY" "$@"
exit 1
else
exit 0
fi