From 0cf964b16d67b69372124830706fe153889d9864 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sun, 1 Nov 2020 14:59:45 +1000 Subject: [PATCH] trailing newline .ftl check can happen at build time Removes the need to build ripgrep for CI --- .github/scripts/trailing-newlines.sh | 19 ------------------- rslib/build/mergeftl.rs | 3 +++ rslib/src/i18n.rs | 3 +-- 3 files changed, 4 insertions(+), 21 deletions(-) delete mode 100755 .github/scripts/trailing-newlines.sh diff --git a/.github/scripts/trailing-newlines.sh b/.github/scripts/trailing-newlines.sh deleted file mode 100755 index e1170c0f1..000000000 --- a/.github/scripts/trailing-newlines.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -set -eu -o pipefail ${SHELLFLAGS} - -# Checking version to force it fail the build if rg is not installed. -# Because `set -e` does not work inside the subshell $() -if ! rg --version > /dev/null 2>&1; -then - echo "Error: ripgrep is not installed!"; - exit 1; -fi; - -files=$(rg -l '[^\n]\z' -g '!*.{png,svg,scss,json,sql}' || true) - -if [ "$files" != "" ]; then - echo "the following files are missing a newline on the last line:" - echo $files - exit 1 -fi diff --git a/rslib/build/mergeftl.rs b/rslib/build/mergeftl.rs index 1b9552559..4ed571790 100644 --- a/rslib/build/mergeftl.rs +++ b/rslib/build/mergeftl.rs @@ -88,6 +88,9 @@ fn get_ftl_data_from_provided_files(sources: String) -> FTLData { let path = Path::new("..").join(path); std::fs::read_to_string(path).unwrap() }); + if !entry.ends_with("\n") { + panic!(".ftl file should end with a newline: {}", path); + } match (first_parent, second_parent) { // templates in the rslib translation repo are ignored, as their canonical // form is part of this source tree diff --git a/rslib/src/i18n.rs b/rslib/src/i18n.rs index 476bc7ed9..1b05ade9c 100644 --- a/rslib/src/i18n.rs +++ b/rslib/src/i18n.rs @@ -79,8 +79,7 @@ macro_rules! ftl_path { }; } -/// Get the template/English resource text for the given group. -/// These are embedded in the binary. +/// Get the template/English resource text. fn ftl_template_text() -> &'static str { ftl_path!("template.ftl") }