diff --git a/.github/file_format.sh b/.github/file_format.sh index 75e21b80..2f902849 100755 --- a/.github/file_format.sh +++ b/.github/file_format.sh @@ -1,14 +1,16 @@ #!/usr/bin/env bash + # This script ensures proper POSIX text file formatting and a few other things. + set -uo pipefail IFS=$'\n\t' -# Function to process a single file. -process_file() { - local f="$1" +# Loops through all text files tracked by Git. +git grep -zIl '' | +while IFS= read -rd '' f; do # Exclude some types of files. if [[ "$f" == *"svg" ]]; then - return + continue fi # Ensure that files are UTF-8 formatted. recode UTF-8 "$f" 2> /dev/null @@ -20,31 +22,28 @@ process_file() { # Remove the character sequence "== true" if it has a leading space. perl -i -pe 's/\x20== true//g' "$f" # We don't want to change lines around braces in godot/tscn files. - if [[ "$f" == *"godot" ]] || [[ "$f" == *"tscn" ]]; then - return + if [[ "$f" == *"godot" ]]; then + continue + elif [[ "$f" == *"tscn" ]]; then + continue fi # Disallow empty lines after the opening brace. sed -z -i 's/\x7B\x0A\x0A/\x7B\x0A/g' "$f" # Disallow some empty lines before the closing brace. sed -z -i 's/\x0A\x0A\x7D/\x0A\x7D/g' "$f" -} - -# Process all files passed as arguments. -for file in "$@"; do - if [ -f "$file" ]; then - process_file "$file" - fi done git diff > patch.patch FILESIZE="$(stat -c%s patch.patch)" MAXSIZE=5 + # If no patch has been generated all is OK, clean up, and exit. if (( FILESIZE < MAXSIZE )); then printf "Files in this commit comply with the formatting rules.\n" rm -f patch.patch exit 0 fi + # A patch has been created, notify the user, clean up, and exit. printf "\n*** The following differences were found between the code " printf "and the formatting rules:\n\n" diff --git a/.github/workflows/export-optimized.yml b/.github/workflows/export-optimized.yml index 948a7dd3..8eba12c7 100644 --- a/.github/workflows/export-optimized.yml +++ b/.github/workflows/export-optimized.yml @@ -4,10 +4,10 @@ on: workflow_dispatch: env: - GODOT_VERSION: 4.2.2 + GODOT_VERSION: 4.3 PROJECT_NAME: GodSVG GODOT_REPO: https://github.com/godotengine/godot.git - GODOT_COMMIT_HASH: 15073af + GODOT_COMMIT_HASH: 77dcf97 BUILD_OPTIONS: target=template_release lto=full production=yes deprecated=no minizip=no brotli=no vulkan=no openxr=no use_volk=no disable_3d=yes modules_enabled_by_default=no module_freetype_enabled=yes module_gdscript_enabled=yes module_svg_enabled=yes module_jpg_enabled=yes module_text_server_adv_enabled=yes graphite=no module_webp_enabled=yes jobs: diff --git a/.github/workflows/static-checks.yml b/.github/workflows/static-checks.yml new file mode 100644 index 00000000..601ee2e2 --- /dev/null +++ b/.github/workflows/static-checks.yml @@ -0,0 +1,18 @@ +name: Static Checks +on: [pull_request] + +jobs: + format: + name: File formatting (file_format.sh) + runs-on: ubuntu-24.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install dependencies + run: sudo apt-get update -qq && sudo apt-get install -yq --no-install-recommends dos2unix recode + + - name: File formatting checks (file_format.sh) + run: bash ./.github/file_format.sh diff --git a/.github/workflows/static_checks.yml b/.github/workflows/static_checks.yml deleted file mode 100644 index 48a35340..00000000 --- a/.github/workflows/static_checks.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Static Checks -on: [pull_request] - -jobs: - format: - name: File formatting (file_format.sh) - runs-on: ubuntu-24.04 - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Install dependencies - run: | - sudo apt-get update -qq - sudo apt-get install -qq dos2unix recode - - - name: Get changed files - id: changed-files - uses: tj-actions/changed-files@v35 - - - name: File formatting checks (file_format.sh) - run: | - if [ -n "${{ steps.changed-files.outputs.all_changed_files }}" ]; then - bash ./.github/file_format.sh ${{ steps.changed-files.outputs.all_changed_files }} - else - echo "No files changed" - fi diff --git a/src/config_classes/Formatter.gd b/src/config_classes/Formatter.gd index 462a5c05..2eb1b269 100644 --- a/src/config_classes/Formatter.gd +++ b/src/config_classes/Formatter.gd @@ -144,7 +144,7 @@ func _init(new_title := "") -> void: title = new_title # Connects to the _on_changed function once all initial file loading is done. # This way the config is saved only once on launch. - changed.connect(changed.connect.bind(_on_changed), CONNECT_DEFERRED | CONNECT_ONE_SHOT) + changed.connect(func(): changed.connect(_on_changed), CONNECT_DEFERRED | CONNECT_ONE_SHOT) func _on_changed() -> void: if self == GlobalSettings.savedata.editor_formatter: