1
0
Fork 0

improve dotsync script

improve dotsync script
This commit is contained in:
Luca Bilke 2023-03-28 14:31:21 +02:00
parent 4a747b249e
commit 78778ff973
No known key found for this signature in database
GPG Key ID: 7B77C51E8C779E75
1 changed files with 9 additions and 9 deletions

View File

@ -5,32 +5,32 @@ BLUE='\033[1;34m'
RED='\033[1;30m'
NC='\033[0m'
cd $HOME/.dotfiles
cd "$HOME/.dotfiles" || exit
echo -e "${BLUE}Stashing existing changes...${NC}"
echo "${BLUE}Stashing existing changes...${NC}"
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
echo -e "${BLUE}Pulling updates from dotfiles repo...${NC}"
echo "${BLUE}Pulling updates from dotfiles repo...${NC}"
echo
git pull origin main
echo
if [[ $needs_pop -eq 1 ]]; then
echo -e "${BLUE}Popping stashed changes...${NC}"
if [ $needs_pop -eq 1 ]; then
echo "${BLUE}Popping stashed changes...${NC}"
echo
git stash pop
fi
unmerged_files=$(git diff --name-only --diff-filter=U)
if [[ ! -z $unmerged_files ]]; then
echo -e "${RED}The following files have merge conflicts after popping the stash:${NC}"
if [ -n "$unmerged_files" ]; then
echo "${RED}The following files have merge conflicts after popping the stash:${NC}"
echo
printf %"s\n" $unmerged_files
printf %"s\n" "$unmerged_files"
else
stow -t $HOME .
stow -t "$HOME" .
fi