Add patch script support

This commit is contained in:
2023-06-20 21:41:19 -05:00
parent 4f83cf2d0f
commit acd746d711

25
scripts/update.sh Normal file → Executable file
View File

@ -1,6 +1,31 @@
#!/bin/bash
# If repo isn't out of date, abort update
if [[ -z "$(git remote show origin | grep "out of date")" ]]; then
exit 0
fi
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
last_hash=$( git rev-parse HEAD )
recent_hashes=$( git log --format=format:%H | grep -B 100 $last_hash)
# Resets the repo to last state
git reset --hard
# Pulls new commits
git pull
# Downloads or updates repo submodules
git submodule update --init --recursive
# Removes untracked files and directories
git clean -fd --force
# Runs patch scripts to ensure machine state
# is up to date
while IFS= read -r hash; do
short_hash=$( echo $hash | cut -c -7 )
/usr/bin/bash "$SCRIPT_DIR"/../patches/*-"$short_hash".sh 2>/dev/null
done <<< "$recent_hashes"