From 95d93fde12c27f7855837065374c33026be1660d Mon Sep 17 00:00:00 2001 From: paspo Date: Sat, 10 Aug 2024 13:39:06 +0200 Subject: [PATCH] unwanted unicode --- .gitea/workflows/unicode_check.yaml | 5 ++++ .../workflows/unwanted_unicode_patterns.grep | 6 +++++ .gitea/workflows/unwanted_unicode_pr.sh | 23 +++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 .gitea/workflows/unwanted_unicode_patterns.grep create mode 100755 .gitea/workflows/unwanted_unicode_pr.sh diff --git a/.gitea/workflows/unicode_check.yaml b/.gitea/workflows/unicode_check.yaml index c94dad3..86b228a 100644 --- a/.gitea/workflows/unicode_check.yaml +++ b/.gitea/workflows/unicode_check.yaml @@ -20,6 +20,11 @@ jobs: entrypoint: /bin/sh args: -c 'apk -U add git bash ; bash .gitea/workflows/markdownlint_pr.sh ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}' + - name: check for unwanted unicode runes + run: | + bash .gitea/workflows/unwanted_unicode_pr.sh ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}' + + # - name: Getting changed files # id: file-lister # shell: bash diff --git a/.gitea/workflows/unwanted_unicode_patterns.grep b/.gitea/workflows/unwanted_unicode_patterns.grep new file mode 100644 index 0000000..2447505 --- /dev/null +++ b/.gitea/workflows/unwanted_unicode_patterns.grep @@ -0,0 +1,6 @@ +— +‘ +’ +“ +” +… diff --git a/.gitea/workflows/unwanted_unicode_pr.sh b/.gitea/workflows/unwanted_unicode_pr.sh new file mode 100755 index 0000000..e00ee2e --- /dev/null +++ b/.gitea/workflows/unwanted_unicode_pr.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +echo +echo "Initial commit: $1" +echo "Final commit: $2" +echo + +# recupera ogni file modificato in questa PR (tra le 2 commit) +# considera solo i file che terminano con .md +# ogni file viene controllato con grep, con i pattern definiti +# nel file di configurazione + +EXIT=0 + +while read -r LINE; do + if [ -r "$LINE" ] ; then + echo + echo "testing file: $LINE" + grep --color -f .gitea/workflows/unwanted_unicode_patterns.grep "$LINE" && EXIT=1 + fi +done < <(git diff --name-only "$1" "$2" content/ | grep \.md$) + +exit ${EXIT}