forked from FreekingDean/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
auto_updater
14 lines (14 loc) · 757 Bytes
/
auto_updater
1
2
3
4
5
6
7
8
9
10
11
12
13
14
check_for_updates() {
GIT_STATUS=$(git --git-dir=$HOME/.dotfiles/.git remote update && git --git-dir=$HOME/.dotfiles/.git status)
if [[ "$GIT_STATUS" == *"Changes not staged for commit"* || "$GIT_STATUS" == *"Changes to be committed"* ]]; then
echo "You have dotfile changes that need to be pushed."
echo "Pushing..."
git --git-dir=$HOME/.dotfiles/.git add -u
git --git-dir=$HOME/.dotfiles/.git commit -m "dotfile update $(date +'%m/%d/%Y %H:%M:%S') from $(cat /etc/hostname) $(uname)"
git --git-dir=$HOME/.dotfiles/.git pull
git --git-dir=$HOME/.dotfiles/.git push
elif [[ "$GIT_STATUS" == *"Your branch is behind 'origin/master'"* ]]; then
echo "Updating dotfiles..."
git --git-dir=$HOME/.dotfiles/.git pull
fi
}