Browse Source

Add pre-commit whitespace check hook

Add a shared Git hook to reject trailing whitespace in staged changes.
Document how developers enable the hook locally. Keep the GitHub
Actions check as a server-side safeguard for pull requests.

Signed-off-by: Robin Getz <rgetz503@gmail.com>
chirpmodem-v8.0.0
Robin Getz 1 month ago
parent
commit
98bd57006c
No known key found for this signature in database
GPG Key ID: 51C7231FFED0E060
  1. 8
      .githooks/pre-commit
  2. 20
      FIXME-notes.md

8
.githooks/pre-commit

@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
#!/bin/sh
#fail if trailing spaces
if ! git diff --cached --check -- \
':(attr:text)' ':(attr:text=auto)'; then
echo "Error: Remove trailing whitespace from staged changes."
exit 1
fi

20
FIXME-notes.md

@ -1,3 +1,23 @@ @@ -1,3 +1,23 @@
## Enable Git pre-commit hooks
SDRangel provides a Git pre-commit hook to check staged changes for trailing
whitespace before a commit is created. The hook is maintained in
`.githooks/pre-commit` and uses `.gitattributes` to determine which files to
check.
To enable the hook, run the following command from your repository root:
```bash
git config core.hooksPath .githooks
```
This configuration is local to your clone and only needs to be set once.
After enabling it, Git automatically runs the hook before each commit. If
trailing whitespace is detected, the commit is rejected. Correct the affected
lines, stage the changes, and try again.
The hook is shared through the repository, but enabling it is a per-clone setup
step. GitHub Actions also checks pull requests for trailing whitespace, providing
a server-side check independent of the local hook.
## meshtasticdemodgui.cpp - checkbox signal pattern
All checkboxes currently use stateChanged(int) pattern.
Consider refactoring all to clicked(bool) for simplicity in a future cleanup commit.

Loading…
Cancel
Save