Skip to content

Commit 1d990a9

Browse files
committed
CI: Improve message about ending with a newline
A newline in a text file serves as a terminator, not a separator. This means every line, including the last one, should end with a newline. If a file is committed without a trailing newline, editors that do add one will create an unnecessary diff when the file is later edited. These spurious diffs can clutter reviews, making it harder to identify actual changes, especially when many files are involved. A newline at the end of the file also facilitates file concatenation. Without it, the first line of the second file will merge with the last line of the first file, creating a single line. See https://stackoverflow.com/questions/729692/why-should-text-files-end-with-a-newline
1 parent 35ddf50 commit 1d990a9

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

.ci/check-newline.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ while IFS= read -rd '' f; do
1010
tail -c1 < "$f" | read -r _ || show=1
1111
if [ $show -eq 1 ]; then
1212
echo "Warning: No newline at end of file $f"
13+
echo "See https://stackoverflow.com/questions/729692/why-should-text-files-end-with-a-newline"
1314
ret=1
1415
show=0
1516
fi

0 commit comments

Comments
 (0)