2023-03-28 14:24:58 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
GREEN='\033[1;32m'
|
|
|
|
BLUE='\033[1;34m'
|
|
|
|
RED='\033[1;30m'
|
|
|
|
NC='\033[0m'
|
|
|
|
|
2023-03-28 14:31:21 +02:00
|
|
|
cd "$HOME/.dotfiles" || exit
|
2023-03-28 14:24:58 +02:00
|
|
|
|
2023-03-28 14:31:21 +02:00
|
|
|
echo "${BLUE}Stashing existing changes...${NC}"
|
2023-03-28 14:24:58 +02:00
|
|
|
stash_result=$(git stash push -m "sync-dotfiles: Before syncing dotfiles")
|
|
|
|
needs_pop=1
|
|
|
|
if [ "$stash_result" = "No local changes to save" ]; then
|
|
|
|
needs_pop=0
|
|
|
|
fi
|
|
|
|
|
2023-03-28 14:31:21 +02:00
|
|
|
echo "${BLUE}Pulling updates from dotfiles repo...${NC}"
|
2023-03-28 14:24:58 +02:00
|
|
|
echo
|
|
|
|
git pull origin main
|
|
|
|
echo
|
|
|
|
|
2023-03-28 14:31:21 +02:00
|
|
|
if [ $needs_pop -eq 1 ]; then
|
|
|
|
echo "${BLUE}Popping stashed changes...${NC}"
|
2023-03-28 14:24:58 +02:00
|
|
|
echo
|
|
|
|
git stash pop
|
|
|
|
fi
|
|
|
|
|
|
|
|
unmerged_files=$(git diff --name-only --diff-filter=U)
|
2023-03-28 14:31:21 +02:00
|
|
|
if [ -n "$unmerged_files" ]; then
|
|
|
|
echo "${RED}The following files have merge conflicts after popping the stash:${NC}"
|
2023-03-28 14:24:58 +02:00
|
|
|
echo
|
2023-03-28 14:31:21 +02:00
|
|
|
printf %"s\n" "$unmerged_files"
|
2023-03-28 14:24:58 +02:00
|
|
|
else
|
2023-03-28 14:31:21 +02:00
|
|
|
stow -t "$HOME" .
|
2023-03-28 14:24:58 +02:00
|
|
|
fi
|
|
|
|
|