From a39375604b1f50bc1d5267dfa5f2cff899fa66fa Mon Sep 17 00:00:00 2001 From: Habu Date: Wed, 12 Jun 2024 19:33:12 +0900 Subject: [PATCH] =?utf8?q?[Chore]=20=E6=94=B9=E8=A1=8C=E3=82=B3=E3=83=BC?= =?utf8?q?=E3=83=89=E3=81=8CLF=E3=81=A7=E3=81=82=E3=82=8B=E3=81=93?= =?utf8?q?=E3=81=A8=E3=82=92=E3=83=81=E3=82=A7=E3=83=83=E3=82=AF=E3=81=99?= =?utf8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit プルリクエストのCIによるチェックで、すべてのテキストファイルの改行 コードがCRLFではなくLFであることをチェックする。 ただし、./VisualStudio/ 以下のファイルは Visual Studio が自動的にCRLFで 上書き保存するので、混乱を避けるためチェックから除外する。 --- .github/scripts/check-newline.sh | 16 ++++++++++++++++ .github/workflows/pull-request-status-check.yml | 7 +++++++ 2 files changed, 23 insertions(+) create mode 100644 .github/scripts/check-newline.sh diff --git a/.github/scripts/check-newline.sh b/.github/scripts/check-newline.sh new file mode 100644 index 000000000..05107c962 --- /dev/null +++ b/.github/scripts/check-newline.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +# ./VisualStudio/ 以下のファイルはVisual StudioがCRLFで上書きするため除外 +CHECK_FILES=$(find . -type f -not -path './.git/*' -and -not -path './VisualStudio/*' -and -not -name \*.wav -and -not -name \*.mp3) + +STATUS=0 + +for file in $CHECK_FILES; do + file $file | grep "CRLF" >/dev/null + if [ $? -eq 0 ]; then + echo "$file: newline is CRLF." + STATUS=1 + fi +done + +exit $STATUS diff --git a/.github/workflows/pull-request-status-check.yml b/.github/workflows/pull-request-status-check.yml index b148e047c..eaf42f5e6 100644 --- a/.github/workflows/pull-request-status-check.yml +++ b/.github/workflows/pull-request-status-check.yml @@ -15,6 +15,13 @@ jobs: - uses: actions/checkout@v3 - run: sh ./.github/scripts/check-bom.sh + check_newline: + name: Check the newline of files + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - run: sh ./.github/scripts/check-newline.sh + check_format: name: Check the format of the source files runs-on: ubuntu-latest -- 2.11.0