alichtman / shallow-backup

Git-integrated backup tool for macOS and Linux devs.
MIT License
1.22k stars 248 forks source link

Backing up an absolute path dotfile conditionally is broken #346

Open alichtman opened 4 months ago

alichtman commented 4 months ago

I have /etc/zsh/zshrc conditionally backed up and restored on Linux, but not on macOS.

Running a backup on macOS attempts to delete the files from git:

dotfiles on  main [$] via 💎 v2.5.1 took 34ms
03:36:19 AM ➜ gst
On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   .config/git/config
        modified:   .config/nvim/lazyvim.json
        deleted:    .config/rofi/scripts/rofi-insect
        modified:   .config/shallow-backup.json
        modified:   .config/zsh/.zshenv
        deleted:    :etc/zsh/zshenv
        deleted:    :etc/zsh/zshrc

no changes added to commit (use "git add" and/or "git commit -a")

Maybe check if shallow-backup has staged a change to delete an abs path file that still exists in the shallow-backup config, and if yes, drop the deletion change?

Making the first step of the backup process deleting the contents of the current backup (for a clean staging area, to make files that were untracked from the config actually get deleted) was maybe a suboptimal design choice. Shallow-backup could probably instead not reap the directory, and at the end, walk you through all the untracked files and prompt you for what to do (keep / delete).

https://github.com/alichtman/shallow-backup/blob/main/shallow_backup/backup.py#L27-L41