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
feat: prevent blankline commits #3858
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
.husky/pre-commit
Outdated
@@ -1,5 +1,12 @@ | |||
#!/bin/sh | |||
. "$(dirname "$0")/_/husky.sh" | |||
|
|||
if [ -z "$(git diff --cached --ignore-blank-lines --unified=0 | grep -E '^[+-]\s' | grep -vE '^[+-]\s*$')" ]; then | |||
echo "Error: commit must contain new content." | |||
exit 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The commits with empty lines are generated by automated workflow scripts:
https://github.com/heyxyz/hey/blob/main/.github/workflows/i18n-extract.yml
https://github.com/heyxyz/hey/blob/main/.github/workflows/crowdin-download.yml
So if we just do a pre-commit hook, the scripts would fail, I assume?
I think that this issue needs to be solved by configuring the workflow scripts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exactly we need to solve in crowdin config imo, they might have something there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems like crowdin-download.yml adds extra newlines to the end of .po files, and i18n-extract.yml removes them again :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for these insights, will do the needful asap 👍
.husky/pre-commit
Outdated
@@ -1,5 +1,12 @@ | |||
#!/bin/sh | |||
. "$(dirname "$0")/_/husky.sh" | |||
|
|||
if [ -z "$(git diff --cached --ignore-blank-lines --unified=0 | grep -E '^[+-]\s' | grep -vE '^[+-]\s*$')" ]; then | |||
echo "Error: commit must contain new content." | |||
exit 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exactly we need to solve in crowdin config imo, they might have something there
Please review the changes @bigint |
|
||
- name: Remove last empty lines from translations | ||
run: | | ||
find '/**/locales/' -type f -name '*.po' -exec sed -i -e '${/^$/d;}' {} \; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have you tested this? if we add here how it will remove after the file is being pushed on previous step?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think instead of creating a pull request during the Download from Crowdin ⬇️
step, we should be creating a pull request at the end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you fix the workflow?
@melsonic reopen this PR again 🙇🏼 |
note: our default standard in this repo to add new line to EOF, so it is expected to have blank line at the end |
is #3807 fixed ? |
@TouchstoneTheGreat not yet! |
we reverted the changes |
What does this PR do?
It prevents commits that contain only blank lines.
Related issues
Fixes # 3807
/claim #3807
Type of change
Explanation of the changes
Emoji
✅ ✅ ✅