diff --git a/.github/workflows/status_check.yml b/.github/workflows/status_check.yml index 3e89078..9d85ecc 100644 --- a/.github/workflows/status_check.yml +++ b/.github/workflows/status_check.yml @@ -7,11 +7,11 @@ jobs: matrix: os: [ ubuntu-latest, macos-latest, windows-latest ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v6 with: ref: ${{ github.head_ref }} fetch-depth: 0 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v6 with: python-version: "3.11" - name: Get the commit message diff --git a/README.md b/README.md index d8952d3..b9b08b9 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ exceeds a threshold. ## Usage ```yaml -- uses: ccdc-opensource/commit-hooks@v6 +- uses: ccdc-opensource/commit-hooks@v7 with: commitMessage: 'The commit message' ``` @@ -38,18 +38,18 @@ jobs: Pull-request-files-check: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v6 with: ref: ${{ github.head_ref }} fetch-depth: 0 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v6 with: - python-version: "3.7" + python-version: "3.11" - name: Get the commit message run: | echo "commit_message=$(git log --format=%B -n 1 ${{ github.event.after }})" >> $GITHUB_ENV shell: bash - - uses: ccdc-opensource/commit-hooks@v6 + - uses: ccdc-opensource/commit-hooks@v7 with: commitMessage: ${{ env.commit_message }} ``` diff --git a/main/commit-msg b/main/commit-msg index ddd3750..98190eb 100755 --- a/main/commit-msg +++ b/main/commit-msg @@ -1,18 +1,29 @@ #!/usr/bin/env bash -me=`basename "$0"` +me=$(basename "$0") case "$OSTYPE" in - msys) - echo "Running ${me} in MinGW" - PYTHON_EXECUTABLE=python - ;; + msys*|mingw*|cygwin*|win32*) + echo "Running ${me} on Windows" + if command -v python3 > /dev/null 2>&1; then + PYTHON_EXECUTABLE=(python3) + elif command -v python > /dev/null 2>&1; then + PYTHON_EXECUTABLE=(python) + else + echo "Error: Python not found or not runnable" + exit 1 + fi + ;; *) echo "Running ${me} on linux / mac / unix" if command -v python3 > /dev/null 2>&1; then - PYTHON_EXECUTABLE=python3 + PYTHON_EXECUTABLE=(python3) + elif command -v python > /dev/null 2>&1; then + PYTHON_EXECUTABLE=(python) else - PYTHON_EXECUTABLE=python + echo "Error: Python not found or not runnable" + exit 1 fi + ;; esac -${PYTHON_EXECUTABLE} "${BASH_SOURCE[0]%.*}.py" "$@" +"${PYTHON_EXECUTABLE[@]}" "${BASH_SOURCE[0]%.*}.py" "$@" diff --git a/main/pre-commit b/main/pre-commit index ddd3750..98190eb 100755 --- a/main/pre-commit +++ b/main/pre-commit @@ -1,18 +1,29 @@ #!/usr/bin/env bash -me=`basename "$0"` +me=$(basename "$0") case "$OSTYPE" in - msys) - echo "Running ${me} in MinGW" - PYTHON_EXECUTABLE=python - ;; + msys*|mingw*|cygwin*|win32*) + echo "Running ${me} on Windows" + if command -v python3 > /dev/null 2>&1; then + PYTHON_EXECUTABLE=(python3) + elif command -v python > /dev/null 2>&1; then + PYTHON_EXECUTABLE=(python) + else + echo "Error: Python not found or not runnable" + exit 1 + fi + ;; *) echo "Running ${me} on linux / mac / unix" if command -v python3 > /dev/null 2>&1; then - PYTHON_EXECUTABLE=python3 + PYTHON_EXECUTABLE=(python3) + elif command -v python > /dev/null 2>&1; then + PYTHON_EXECUTABLE=(python) else - PYTHON_EXECUTABLE=python + echo "Error: Python not found or not runnable" + exit 1 fi + ;; esac -${PYTHON_EXECUTABLE} "${BASH_SOURCE[0]%.*}.py" "$@" +"${PYTHON_EXECUTABLE[@]}" "${BASH_SOURCE[0]%.*}.py" "$@" diff --git a/main/pre-merge-commit b/main/pre-merge-commit index 81ebcd7..98190eb 100755 --- a/main/pre-merge-commit +++ b/main/pre-merge-commit @@ -1,18 +1,29 @@ #!/usr/bin/env bash -me=`basename "$0"` +me=$(basename "$0") case "$OSTYPE" in - msys) - echo "Running ${me} in MinGW" - PYTHON_EXECUTABLE=python - ;; + msys*|mingw*|cygwin*|win32*) + echo "Running ${me} on Windows" + if command -v python3 > /dev/null 2>&1; then + PYTHON_EXECUTABLE=(python3) + elif command -v python > /dev/null 2>&1; then + PYTHON_EXECUTABLE=(python) + else + echo "Error: Python not found or not runnable" + exit 1 + fi + ;; *) - echo "Running ${me} linux / mac / unix" + echo "Running ${me} on linux / mac / unix" if command -v python3 > /dev/null 2>&1; then - PYTHON_EXECUTABLE=python3 + PYTHON_EXECUTABLE=(python3) + elif command -v python > /dev/null 2>&1; then + PYTHON_EXECUTABLE=(python) else - PYTHON_EXECUTABLE=python + echo "Error: Python not found or not runnable" + exit 1 fi + ;; esac -${PYTHON_EXECUTABLE} "${BASH_SOURCE[0]%.*}.py" "$@" +"${PYTHON_EXECUTABLE[@]}" "${BASH_SOURCE[0]%.*}.py" "$@"