Commit a3a0f318 authored by Brad King's avatar Brad King 💬

Merge topic 'add-line-at-eof-formatter'

30489ab0 line-at-eof: add a formatter which adds newlines to the end of files
Reviewed-by: Brad King's avatarBrad King <brad.king@kitware.com>
Merge-request: !8
parents 4b2c35f4 30489ab0
...@@ -56,6 +56,7 @@ function (install_formatter name) ...@@ -56,6 +56,7 @@ function (install_formatter name)
endfunction () endfunction ()
add_subdirectory(c) add_subdirectory(c)
add_subdirectory(generic)
add_subdirectory(python) add_subdirectory(python)
add_subdirectory(rust) add_subdirectory(rust)
......
add_formatter(line-at-eof reformat)
#!/bin/sh
# This formatter ensures that non-empty files have a newline at the end of the
# file.
set -e
readonly path="$1"
shift
if ! [ -f "$path" ]; then
echo >&2 'error: could not find file to format: '"$path"
exit 4
fi
exec sed -i -e '$a\' "$path"
formatter_line-at-eof:
kind: "line-at-eof"
script: "@CMAKE_INSTALL_PREFIX@/bin/format.line-at-eof"
add_formatter_test(line-at-eof missing-eof missing-eof format)
add_formatter_test(line-at-eof have-eof have-eof pass)
add_formatter_test(line-at-eof empty empty pass)
This line has an EOL at the EOL.
This line has an EOL at the EOL.
This line has an EOL at the EOL.
This line is missing an EOL at the EOL.
\ No newline at end of file
This line is missing an EOL at the EOL.
\ No newline at end of file
This line is missing an EOL at the EOL.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment