forked from mathiasbynens/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 49
/
.dotfilecheck
41 lines (33 loc) · 927 Bytes
/
.dotfilecheck
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
function info {
echo -e "${COLOR_YELLOW}${*}${COLOR_NO_COLOUR}"
}
function error {
echo -e "${COLOR_RED}${*}${COLOR_NO_COLOUR}"
}
MOD=$(date +%Y%m%d -r "$HOME/.dotfilecheck")
CUR=$(date +%Y%m%d)
if [[ ${MOD} != "${CUR}" ]]; then
touch "$HOME/.dotfilecheck"
if [[ -z $DOTFILESSRCDIR ]]; then
error "DOTFILESSRCDIR not set. It must point to the git based source directory of dotfiles"
else
(
cd "$DOTFILESSRCDIR"
git remote update > /dev/null 2>&1
UPSTREAM=${1:-'@{u}'}
LOCAL=$(git rev-parse @{0})
REMOTE=$(git rev-parse "$UPSTREAM")
BASE=$(git merge-base @{0} "$UPSTREAM")
if [ $LOCAL = $REMOTE ]; then
:
elif [ $LOCAL = $BASE ]; then
info "Dotfiles may need a pull?"
elif [ $REMOTE = $BASE ]; then
info "Dotfiles may need a push?"
else
info "Dotfiles may need pull & push?"
fi
)
fi
fi