blob: bb3caf7b3ce1a3450c152625133d305885316612 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#!/bin/bash
# check that the dotfiles repository is up-to-date and clean
# otherwise create the dirty stamp file
script_path=$(realpath "$0")
script_dir=$(dirname "${script_path}")
dotfiles_dir=$(realpath "${script_dir}/..")
dirty_stamp=~/.local/var/dotfiles/dirty
if [ ! -d "${dotfiles_dir}" ]; then
echo "no dotfiles dir"
exit 1
fi
git -C "${dotfiles_dir}" fetch -q --all || (echo "error updating remote" && exit 1)
count=$(git -C "${dotfiles_dir}" rev-list --left-right --count '@{upstream}'...HEAD 2>/dev/null | grep -v '^0\s0$')
git -C "${dotfiles_dir}" diff --exit-code >/dev/null
repo_dirty=$?
if [[ -n "${count}" || $repo_dirty -ne 0 ]]; then
touch "${dirty_stamp}"
else
rm -f "${dirty_stamp}"
fi
|