diff options
author | Fedja Beader <fedja@protonmail.ch> | 2024-08-19 06:40:54 +0000 |
---|---|---|
committer | Fedja Beader <fedja@protonmail.ch> | 2024-08-19 06:40:54 +0000 |
commit | d4b0b5c2de0219819ee05670bdf47259de9a0318 (patch) | |
tree | 357903c06d06f2ca76cb731f89eb930cc9da323d | |
parent | 4aad7d4f1a07deb5baacaf293cf47ed4681131b9 (diff) | |
download | serverdata-d4b0b5c2de0219819ee05670bdf47259de9a0318.tar.gz serverdata-d4b0b5c2de0219819ee05670bdf47259de9a0318.tar.bz2 serverdata-d4b0b5c2de0219819ee05670bdf47259de9a0318.tar.xz serverdata-d4b0b5c2de0219819ee05670bdf47259de9a0318.zip |
Make spaces script pretty-print file, line number and problem line
****
serverdata!160
-rw-r--r-- | .gitlab-ci.yml | 2 | ||||
-rwxr-xr-x | .tools/jobs/spaces.sh | 21 |
2 files changed, 18 insertions, 5 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0ea171bf3..42d69bcef 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -101,7 +101,7 @@ spaces: - cd npc - ../.tools/jobs/spaces.sh image: debian:buster - allow_failure: true + allow_failure: true # I don't want this to be critical on TMW2 artifacts: untracked: true when: always diff --git a/.tools/jobs/spaces.sh b/.tools/jobs/spaces.sh index 4460cfb78..62cfd273a 100755 --- a/.tools/jobs/spaces.sh +++ b/.tools/jobs/spaces.sh @@ -4,8 +4,21 @@ find -H . -type f -name "*.txt" -exec sed -i 's/[[:blank:]]*$//' {} \; export RES=$(git diff --name-only) if [[ -n "${RES}" ]]; then - echo "Extra spaces before new lines detected in files:" - git diff --name-only - # I don't want this to be critical on TMW2 - exit 1 + echo "Extra spaces before new lines detected in files:" + + # Don't know if this is possible to do via git alone: + line_number=0 + file_path="unknown" + while read -r line; do + if [[ $line =~ ^"--- "(.*) ]]; then + file_path="${BASH_REMATCH[1]}" + file_path="${file_path#*a/}" + elif [[ $line =~ ^"@@ -"([0-9]*).* ]]; then + line_number="${BASH_REMATCH[1]}" + elif [[ $line =~ ^"-"(.*) ]]; then + old_line="${BASH_REMATCH[1]}" + printf "%s:%s %s\n" "$file_path" "$line_number" "$old_line" + fi + done < <(git diff --unified=0) + exit 1 fi |