You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(dotfiles): warn and confirm before git reset --hard when local changes exist
Before resetting the dotfiles repo to origin, check git status --porcelain.
If uncommitted changes are present: warn the user, prompt for confirmation
in interactive (TTY) mode, and skip the reset entirely in non-interactive
mode — preventing silent data loss of local dotfile tweaks.
Add two regression tests: NoTTY skips reset and preserves local changes,
CleanRepo still syncs normally when the tree is clean.
ui.Warn(fmt.Sprintf("Local uncommitted changes detected in %s", dotfilesPath))
96
+
ifsystem.HasTTY() {
97
+
proceed, confirmErr:=ui.Confirm("Proceeding will discard all local changes in your dotfiles. Continue?", false)
98
+
ifconfirmErr!=nil||!proceed {
99
+
fmt.Printf("Skipping dotfiles sync to avoid data loss. Run 'git reset --hard origin/%s' manually to force update.\n", branch)
100
+
returnnil
101
+
}
102
+
} else {
103
+
fmt.Printf("Local changes detected in %s — skipping sync to avoid data loss. Run 'git reset --hard origin/%s' manually to force update.\n", dotfilesPath, branch)
0 commit comments