Add patch script support
This commit is contained in:
25
scripts/update.sh
Normal file → Executable file
25
scripts/update.sh
Normal file → Executable file
@ -1,6 +1,31 @@
|
|||||||
#!/bin/bash
|
#!/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
|
git reset --hard
|
||||||
|
|
||||||
|
# Pulls new commits
|
||||||
git pull
|
git pull
|
||||||
|
|
||||||
|
# Downloads or updates repo submodules
|
||||||
git submodule update --init --recursive
|
git submodule update --init --recursive
|
||||||
|
|
||||||
|
# Removes untracked files and directories
|
||||||
git clean -fd --force
|
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"
|
||||||
|
Reference in New Issue
Block a user