From cd130dfe8d742be8deab957c705d75b1e85b18a0 Mon Sep 17 00:00:00 2001 From: Devon R Date: Mon, 24 Apr 2023 15:02:57 +0900 Subject: [PATCH] Replace python-githooks with manual command (#1027) --- .githooks.ini | 7 ------- install.sh | 10 +++++----- tools/precommit_check_no_assets.sh | 6 ++++++ 3 files changed, 11 insertions(+), 12 deletions(-) delete mode 100644 .githooks.ini create mode 100755 tools/precommit_check_no_assets.sh diff --git a/.githooks.ini b/.githooks.ini deleted file mode 100644 index f1e9f479fd..0000000000 --- a/.githooks.ini +++ /dev/null @@ -1,7 +0,0 @@ -# To refresh this file: -# python3 -m python_githooks - -# Make sure dumped assets have not been unignored -# https://github.com/pmret/papermario/wiki/Asset-overrides -[pre-commit] # **** DO NOT REMOVE THIS!! **** -command = (git check-ignore assets/us -q && git check-ignore assets/jp -q && git check-ignore assets/ique -q && git check-ignore assets/pal -q) || (>&2 echo 'ERROR: You appear to be committing dumped assets!\nSee the following document for how to modify assets legally:\nhttps://github.com/pmret/papermario/wiki/Asset-overrides' && exit 1) diff --git a/install.sh b/install.sh index d33d5843ff..79cc1b38aa 100755 --- a/install.sh +++ b/install.sh @@ -33,7 +33,7 @@ if [[ "$uname" == "Darwin" ]]; then # Install packages brew install md5sha1sum ninja gcc nanaian/brew/mips-linux-gnu-binutils || exit 1 python3 -m pip install -U -r requirements.txt || exit 1 - python3 -m python_githooks || exit 1 + cp tools/precommit_check_no_assets.sh "$(git rev-parse --git-path hooks)/pre-commit" || exit 1 if [[ $1 == "--extra" ]]; then echo "Installing extra" @@ -50,7 +50,7 @@ if cat /etc/os-release | grep -E 'ID=debian|ID_LIKE=(.*)debian' &> /dev/null; th ${SUDO} apt install -y curl git python3 python3-pip python3-setuptools build-essential binutils-mips-linux-gnu zlib1g-dev libyaml-dev ninja-build cpp-mips-linux-gnu || exit 1 python3 -m pip install -U -r requirements.txt - python3 -m python_githooks || exit 1 + cp tools/precommit_check_no_assets.sh "$(git rev-parse --git-path hooks)/pre-commit" || exit 1 if [[ $1 == "--extra" ]]; then echo "Installing extra" @@ -71,7 +71,7 @@ if cat /etc/os-release | grep -E 'ID=arch|ID_LIKE=arch' &> /dev/null; then # Install dependencies ${SUDO} pacman -S --noconfirm --needed curl git python python-pip python-setuptools base-devel zlib libyaml ninja || exit 1 python3 -m pip install -U -r requirements.txt - python3 -m python_githooks || exit 1 + cp tools/precommit_check_no_assets.sh "$(git rev-parse --git-path hooks)/pre-commit" || exit 1 # Install binutils if required if ! command -v mips-linux-gnu-ar &> /dev/null; then @@ -126,7 +126,7 @@ if cat /etc/os-release | grep ID=opensuse &> /dev/null; then ${SUDO} ln -s /usr/bin/mips-suse-linux-strip /usr/bin/mips-linux-gnu-strip python3 -m pip install -U -r requirements.txt - python3 -m python_githooks || exit 1 + cp tools/precommit_check_no_assets.sh "$(git rev-parse --git-path hooks)/pre-commit" || exit 1 if [[ $1 == "--extra" ]]; then echo "Installing extra" @@ -149,7 +149,7 @@ if cat /etc/os-release | grep ID=alpine &> /dev/null; then # Install dependencies ${SUDO} apk add --no-cache bash curl wget git python3 python3-dev py3-pip build-base zlib-dev yaml-dev ninja python3 -m pip install -U -r requirements.txt - python3 -m python_githooks || exit 1 + cp tools/precommit_check_no_assets.sh "$(git rev-parse --git-path hooks)/pre-commit" || exit 1 # Install binutils if required if ! command -v mips-linux-gnu-ar &> /dev/null; then diff --git a/tools/precommit_check_no_assets.sh b/tools/precommit_check_no_assets.sh new file mode 100755 index 0000000000..d5a73bd99b --- /dev/null +++ b/tools/precommit_check_no_assets.sh @@ -0,0 +1,6 @@ +#!/bin/bash +# This script is copied into the pre-commit git hooks folder. +# It ensures that a commit is aborted if you try to accidentally commit game assets. +# install.sh will install this for you. + +(git check-ignore assets/us -q && git check-ignore assets/jp -q && git check-ignore assets/ique -q && git check-ignore assets/pal -q) || (>&2 echo -e 'ERROR: You appear to be committing dumped assets!\nSee the following document for how to modify assets legally:\nhttps://github.com/pmret/papermario/wiki/Asset-overrides' && exit 1)