chore: restore final newline in Makefiles after mbake-format#5
Merged
Merged
Conversation
Copilot created this pull request from a session on behalf of
andrewferrier
June 13, 2026 06:09
View session
Owner
|
@copilot please keep the scope of the hook narrow, only makefiles . Also it only adds new lines when they are missing, right? |
Contributor
Author
Both are already the case:
|
andrewferrier
marked this pull request as ready for review
June 13, 2026 06:16
There was a problem hiding this comment.
Pull request overview
This PR adds a post-mbake-format pre-commit step to restore the final newline in Makefiles, preventing follow-on hooks (e.g. editorconfig-checker) from failing repeatedly due to missing EOF newlines.
Changes:
- Add a
localpre-commit hook (makefile-final-newline) intended to append a newline to Makefiles that don’t end with\n. - Position the hook after
mbake-format/mbake-validateto repair formatting side-effects.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| hooks: | ||
| - id: makefile-final-newline | ||
| name: Restore final newline stripped by mbake-format | ||
| entry: bash -c 'for f in "$@"; do [ -n "$(tail -c1 "$f")" ] && printf "\n" >> "$f"; done' -- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
mbake-formatstrips the trailing newline from Makefiles, which causes subsequent hooks (e.g.editorconfig-checker) to fail on every run.Changes
.pre-commit-config.yaml: Adds alocalhook (makefile-final-newline) that runs aftermbake-format/mbake-validateand appends a newline to any Makefile missing one.The entry uses
$(tail -c1 "$f")in a command substitution — which strips trailing newlines — so the condition is false when the file already ends with\n, making the hook a no-op on well-formed files: