From 1d21b7fc7f5c18536b2cde9b3772097b49c73e48 Mon Sep 17 00:00:00 2001 From: Jakub Marciniak Date: Tue, 22 Apr 2025 21:05:58 +0200 Subject: [PATCH 1/8] add git actions --- .github/workflows/check-line-endings.yml | 29 ++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/check-line-endings.yml diff --git a/.github/workflows/check-line-endings.yml b/.github/workflows/check-line-endings.yml new file mode 100644 index 0000000..4f0728a --- /dev/null +++ b/.github/workflows/check-line-endings.yml @@ -0,0 +1,29 @@ +name: Check Line Endings + +on: + pull_request: + paths: + - '**/*.sh' + push: + paths: + - '**/*.sh' + +jobs: + check_line_endings: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Find files with CRLF line endings + run: | + echo "🔍 Checking for CRLF endings..." + CRLF_FILES=$(grep -Ilr $'\r' . --exclude-dir=.git --include='*.sh') + if [[ -n "$CRLF_FILES" ]]; then + echo "🚫 The following files contain CRLF (Windows-style) line endings:" + echo "$CRLF_FILES" + echo "" + echo "💡 Please convert them to LF endings (e.g., using 'dos2unix')." + exit 1 + fi + echo "✅ All shell scripts have correct LF endings." From 636da796403c85a9d03bdb22ec58aec3ef10d710 Mon Sep 17 00:00:00 2001 From: Jakub Marciniak Date: Tue, 22 Apr 2025 21:11:03 +0200 Subject: [PATCH 2/8] test 1 check --- commands/clean_files.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/clean_files.sh b/commands/clean_files.sh index 7de5a3b..e15e2bf 100644 --- a/commands/clean_files.sh +++ b/commands/clean_files.sh @@ -6,7 +6,7 @@ source ./lib/utils.sh show_help() { - echo "Usage:" + echo "Usage: " echo " shellman clean_files [options]" echo "" echo "Description:" From ff5d090fde75c43bdc55978674de024de56ec6e6 Mon Sep 17 00:00:00 2001 From: Jakub Marciniak Date: Tue, 22 Apr 2025 21:12:13 +0200 Subject: [PATCH 3/8] test 2 --- commands/clean_files.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/clean_files.sh b/commands/clean_files.sh index e15e2bf..7de5a3b 100644 --- a/commands/clean_files.sh +++ b/commands/clean_files.sh @@ -6,7 +6,7 @@ source ./lib/utils.sh show_help() { - echo "Usage: " + echo "Usage:" echo " shellman clean_files [options]" echo "" echo "Description:" From 482ffd4fd45c8f89ab7b6d2b2b5be18a3e3c4371 Mon Sep 17 00:00:00 2001 From: Jakub Marciniak Date: Tue, 22 Apr 2025 21:17:37 +0200 Subject: [PATCH 4/8] secpnd version --- .github/workflows/check-line-endings.yml | 24 ++++++++++++++++-------- VERSION | 2 +- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/.github/workflows/check-line-endings.yml b/.github/workflows/check-line-endings.yml index 4f0728a..4e562af 100644 --- a/.github/workflows/check-line-endings.yml +++ b/.github/workflows/check-line-endings.yml @@ -15,15 +15,23 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - - name: Find files with CRLF line endings + - name: Find shell scripts with CRLF line endings + shell: bash run: | - echo "🔍 Checking for CRLF endings..." - CRLF_FILES=$(grep -Ilr $'\r' . --exclude-dir=.git --include='*.sh') - if [[ -n "$CRLF_FILES" ]]; then - echo "🚫 The following files contain CRLF (Windows-style) line endings:" - echo "$CRLF_FILES" + echo "🔍 Checking for CRLF endings in shell scripts..." + + # Szukamy plików .sh zawierających CRLF + mapfile -t crlf_files < <(find . -type f -name "*.sh" -exec grep -Il $'\r' {} +) + + if (( ${#crlf_files[@]} > 0 )); then + echo "" + echo "🚫 The following .sh files contain CRLF (Windows-style) line endings:" + for file in "${crlf_files[@]}"; do + echo " • $file" + done echo "" - echo "💡 Please convert them to LF endings (e.g., using 'dos2unix')." + echo "💡 Please convert them to LF endings using 'dos2unix' or 'shellman line_endings'." exit 1 + else + echo "✅ All .sh files use correct LF line endings." fi - echo "✅ All shell scripts have correct LF endings." diff --git a/VERSION b/VERSION index 100435b..ee94dd8 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.8.2 +0.8.3 From 4ad5e25ddd3ed2123ba0c33eff0ea6e0753de84e Mon Sep 17 00:00:00 2001 From: Jakub Marciniak Date: Tue, 22 Apr 2025 21:20:45 +0200 Subject: [PATCH 5/8] test 3 --- commands/checksum_files.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commands/checksum_files.sh b/commands/checksum_files.sh index d9f9722..cf0ef02 100644 --- a/commands/checksum_files.sh +++ b/commands/checksum_files.sh @@ -1,12 +1,12 @@ #!/usr/bin/env bash # # Generate or verify checksums for many files. -# Default algo: sha256. Other supported: md5, sha1. +# Default algo: sha256. Other supported: md5, sha1. source ./lib/utils.sh show_help() { - echo "Usage:" + echo "Usage: " echo " shellman checksum_files [options]" echo "" echo "Description:" From a086c2a7bafb3bf1df81d342223db9b7f2375ae3 Mon Sep 17 00:00:00 2001 From: Jakub Marciniak Date: Tue, 22 Apr 2025 21:27:04 +0200 Subject: [PATCH 6/8] version 3 --- .github/workflows/check-line-endings.yml | 41 +++++++++++++----------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/.github/workflows/check-line-endings.yml b/.github/workflows/check-line-endings.yml index 4e562af..01a977c 100644 --- a/.github/workflows/check-line-endings.yml +++ b/.github/workflows/check-line-endings.yml @@ -1,37 +1,42 @@ -name: Check Line Endings +name: Check Shell Script Line Endings on: - pull_request: - paths: - - '**/*.sh' push: - paths: - - '**/*.sh' + pull_request: jobs: - check_line_endings: + check_crlf_in_sh: + name: Check for CRLF in .sh files runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 + with: + unix-newlines: false - - name: Find shell scripts with CRLF line endings + - name: Scan all *.sh files for CRLF endings shell: bash run: | - echo "🔍 Checking for CRLF endings in shell scripts..." + echo "🔍 Scanning all *.sh files for CRLF endings..." - # Szukamy plików .sh zawierających CRLF - mapfile -t crlf_files < <(find . -type f -name "*.sh" -exec grep -Il $'\r' {} +) + mapfile -t all_sh_files < <(find . -type f -name "*.sh") - if (( ${#crlf_files[@]} > 0 )); then - echo "" - echo "🚫 The following .sh files contain CRLF (Windows-style) line endings:" - for file in "${crlf_files[@]}"; do - echo " • $file" + bad_files=() + + for file in "${all_sh_files[@]}"; do + if grep -q $'\r' "$file"; then + bad_files+=("$file") + fi + done + + if (( ${#bad_files[@]} > 0 )); then + echo "🚫 Found ${#bad_files[@]} shell script(s) with CRLF endings:" + for f in "${bad_files[@]}"; do + echo " • $f" done echo "" - echo "💡 Please convert them to LF endings using 'dos2unix' or 'shellman line_endings'." + echo "💡 Please convert these files to LF using 'dos2unix ' or 'shellman line_endings --file --to lf'" exit 1 else - echo "✅ All .sh files use correct LF line endings." + echo "✅ All .sh files use proper LF line endings." fi From e0d10df879e4d1f64df6ff4ad287e93a0c31502a Mon Sep 17 00:00:00 2001 From: Jakub Marciniak Date: Tue, 22 Apr 2025 21:28:50 +0200 Subject: [PATCH 7/8] test 4 --- commands/clean_files.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/clean_files.sh b/commands/clean_files.sh index 7de5a3b..e7bd3b6 100644 --- a/commands/clean_files.sh +++ b/commands/clean_files.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # # Remove unwanted / temporary files from a tree. -# Supports dry‑run preview and age filter. +# Supports dry‑run preview and age filter. source ./lib/utils.sh From ba78b18284a19061ce25f92003a26704a10c4d7b Mon Sep 17 00:00:00 2001 From: Jakub Marciniak Date: Tue, 22 Apr 2025 21:35:57 +0200 Subject: [PATCH 8/8] version 4 --- .github/workflows/.gitattributes | 1 + .github/workflows/check-line-endings.yml | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/.gitattributes diff --git a/.github/workflows/.gitattributes b/.github/workflows/.gitattributes new file mode 100644 index 0000000..b7bdc48 --- /dev/null +++ b/.github/workflows/.gitattributes @@ -0,0 +1 @@ +*.sh text eol=crlf diff --git a/.github/workflows/check-line-endings.yml b/.github/workflows/check-line-endings.yml index 01a977c..47f8990 100644 --- a/.github/workflows/check-line-endings.yml +++ b/.github/workflows/check-line-endings.yml @@ -1,20 +1,24 @@ name: Check Shell Script Line Endings on: - push: pull_request: + push: jobs: check_crlf_in_sh: name: Check for CRLF in .sh files runs-on: ubuntu-latest steps: - - name: Checkout code + - name: Checkout code (with original line endings) uses: actions/checkout@v3 with: - unix-newlines: false + fetch-depth: 0 + + - name: Create .gitattributes to enforce LF + run: | + echo "*.sh text eol=lf" > .gitattributes - - name: Scan all *.sh files for CRLF endings + - name: Check for CRLF in .sh files shell: bash run: | echo "🔍 Scanning all *.sh files for CRLF endings..." @@ -35,8 +39,8 @@ jobs: echo " • $f" done echo "" - echo "💡 Please convert these files to LF using 'dos2unix ' or 'shellman line_endings --file --to lf'" + echo "💡 Convert them using: dos2unix or shellman line_endings --file --to lf" exit 1 else - echo "✅ All .sh files use proper LF line endings." + echo "✅ All .sh files use proper LF endings." fi