Skip to content
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

Add check for multiple consecutive empty lines #12754

Closed
wants to merge 3 commits into from
Closed
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
6 changes: 6 additions & 0 deletions .github/ghprcomment.yml
Original file line number Diff line number Diff line change
@@ -91,6 +91,12 @@

Please [merge `upstream/main`](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork#syncing-a-fork-branch-from-the-command-line) with your code.
For a step-by-step guide to resolve merge conflicts, see <https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-using-the-command-line>.
- jobName: 'No multiple consecutive empty lines'
message: >
Some files contain multiple consecutive empty lines.


Please ensure that only one empty line is used as separation.
- jobName: 'Submodules not modified'
message: >
Your pull request modified git submodules.
33 changes: 33 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -367,6 +367,39 @@ jobs:
- name: Merge Conflict finder
uses: olivernybroe/[email protected]


no-multiple-consecutive-empty-lines:
if: github.event_name == 'pull_request'
name: No multiple consecutive empty lines
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- run: |
error_found=0
for file in $(git ls-files); do
if [ "$file" = "ghcomment.yml" ]; then
continue
fi
if file "$file" | grep -q 'text'; then
if ! awk 'BEGIN { count=0 }
/^[[:space:]]*$/ { count++; if (count>=2) exit 1 }
/^[^[:space:]]/ { count=0 }
END { exit 0 }' "$file"; then
echo "❌ $file contains multiple consecutive empty lines."
error_found=1
fi
fi
done
if [ $error_found -eq 0 ]; then
echo "✅ No files contain multiple consecutive empty lines."
else
echo "❌ Files contain multiple consecutive empty lines."
exit 1
fi

no-force-push:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
Loading