Skip to content

Add trailing newline and whitespace checks #11

Draft
BKPepe wants to merge 2 commits intoGeorgeSapkin:mainfrom
BKPepe:feat/content-checks
Draft

Add trailing newline and whitespace checks #11
BKPepe wants to merge 2 commits intoGeorgeSapkin:mainfrom
BKPepe:feat/content-checks

Conversation

@BKPepe
Copy link
Contributor

@BKPepe BKPepe commented Jan 11, 2026

This time, I let the AI to write this.

Will need to check this.

BKPepe added 2 commits January 9, 2026 12:00
This adds a new check to verify GPG/SSH signatures on commits.
The check reports the signature status (Good, Bad, Unknown, etc.) and
validates it:

- Good (G): PASS
- Bad (B), Revoked (R), Error (E): FAIL
- Unknown (U), Expired (X, Y): WARN
- None (N): SKIP

The test suite has been updated to cover these changes and to enforce
commit.gpgsign=false within the test environment to ensure deterministic
results.

Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
This commit introduces two new checks for file content formality:

1. Trailing Newline Check (Mandatory):
   - Ensures that all modified files end with a newline character.
   - Files missing a newline at the end will fail the check.
   - Configurable via 'check_trailing_newline' input (default: true).

2. Trailing Whitespace Check (Warning):
   - Checks for trailing whitespace on lines in modified files.
   - Uses 'git show --check' to detect whitespace issues.
   - Issues a warning but does not fail the check by default.
   - Configurable via 'check_trailing_whitespace' input (default: true).

Updates:
- src/check_formalities.sh: Implements the 'check_content' function and integrates it into the main loop.
- src/test.sh: Adds support for injecting custom file content in test commits and adds 4 new test cases covering the new checks. Updates all existing test expectations.
- README.md: Documents the new rules and configuration inputs.
@github-actions
Copy link

Warning

Some formality checks failed.

Consider (re)reading submissions guidelines.

Failed checks

Issues marked with an ❌ are failing checks.

Commit c4d5a2c

  • ❌ Commit subject must be <= 60 (and should be <= 50) characters long
    Actual: subject is 61 characters long
    $\textsf{check_formalities: add trailing newline and whites\color{yellow}{pace check}\color{red}{s}}$
  • Signed-off-by must match author
    Actual: missing or doesn't match author
    Expected: Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
  • 🔶 Commit message lines should be <= 75 characters long
    Actual: line 16 is 105 characters long
    $\textsf{- src/check_formalities.sh: Implements the 'check_content' function and int\color{red}{egrates it into the main loop.}}$
    Actual: line 17 is 168 characters long
    $\textsf{- src/test.sh: Adds support for injecting custom file content in test commi\color{red}{ts and adds 4 new test cases covering the new checks. Updates all existing test expectations.}}$

For more details, see the full job log.

Something broken? Consider providing feedback.

echo "Summary: $pass_count/$test_count tests passed"

[ "$pass_count" != "$test_count" ] \
[ "$pass_count" -ne "$test_count" ] \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't -ne only for numeric values, but these are surrounded in quotes and therefore are strings, so this should be left as != ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we discuss it here #10 ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just read it. If it solves an issue and works, then makes sense to keep it.

@danielfdickinson
Copy link

danielfdickinson commented Jan 12, 2026

@BKPepe One question: Were you intending to have this also enforce \n as the line ending?

@GeorgeSapkin
Copy link
Owner

I think content checks go a bit outside of formalities: they should be optional, behind a flag and probably in some kind of an extension system. Same goes for OpenWrt-specific checks, e.g. package version, release, hash, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants