diff options
| author | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-12-24 13:54:03 +0900 |
|---|---|---|
| committer | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-12-24 13:54:03 +0900 |
| commit | 28e8bdf7f8286bd431b7f3b709e79f3827b31469 (patch) | |
| tree | 85b44eff6da4d8443198fb6e04dfb6ee55244588 /debian/.local/bin/syncdot | |
| parent | 8470ff001befcfd0f626dea69a9e76d43aee0511 (diff) | |
updates
Diffstat (limited to 'debian/.local/bin/syncdot')
| -rwxr-xr-x | debian/.local/bin/syncdot | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/debian/.local/bin/syncdot b/debian/.local/bin/syncdot new file mode 100755 index 0000000..5e560e9 --- /dev/null +++ b/debian/.local/bin/syncdot @@ -0,0 +1,46 @@ +#!/bin/sh + +# Define ANSI color codes for better readability in script output +GREEN='\033[1;32m' +BLUE='\033[1;34m' +RED='\033[1;31m' +NC='\033[0m' # No Color + +# Ensure the script exits on any error +set -e + +# Navigate to the dotfiles directory +cd "${XDG_DOTFILES_DIR:-${HOME}/.dotfiles}" || exit + +echo "${BLUE}Stashing existing changes...${NC}" +stash_result=$(git stash push -m "sync-dotfiles: Before syncing dotfiles" 2>&1) +needs_pop=0 +if ! echo "$stash_result" | grep -q "No local changes to save"; then + needs_pop=1 +fi + +echo "${BLUE}Pulling updates from dotfiles repo...${NC}" +git pull origin master + +if [ "$needs_pop" -eq 1 ]; then + echo "${BLUE}Popping stashed changes...${NC}" + git stash pop +fi + +# Check for merge conflicts after attempting to pop the stash +unmerged_files=$(git diff --name-only --diff-filter=U) +if [ -n "$unmerged_files" ]; then + echo "${RED}The following files have merge conflicts after popping the stash:${NC}" + printf "%s\n" "$unmerged_files" + exit 1 +else + echo "${GREEN}No merge conflicts detected. Proceeding with dotfiles linkage...${NC}" + # Ensure GNU Stow is installed + if ! command -v stow >/dev/null 2>&1; then + echo "${RED}GNU Stow not found. Please install GNU Stow to continue.${NC}" + exit 1 + fi + # Run stow to ensure all new dotfiles are linked, targeting directories named after the OS + stow -v --no-folding -S "$(whereami)" # Verbose output + echo "${GREEN}Dotfiles successfully linked.${NC}" +fi |
