blob: d8b617acb166e5347cfbb530d046df8e587de417 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#!/bin/bash
# check that the dotfiles repository is up-to-date and clean
# otherwise create the dirty stamp file
dotfiles_dir=~/.config/dotfiles
dirty_stamp=~/.local/var/dotfiles/dirty
[ -d "${dotfiles_dir}" ] || (echo "no dotfiles dir" && exit 1)
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
|