32 lines
776 B
Bash
Executable File
32 lines
776 B
Bash
Executable File
#!/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"
|