alichtman / shallow-backup

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

Reinstallation for absolute paths is broken #345

Closed alichtman closed 1 month ago

alichtman commented 1 month ago

Given a config file like:

{
    "backup_path": "~/shallow-backup",
    "lowest_supported_version": "5.0.0a",
    "dotfiles": {
        ".config/agignore": {},
        ".config/crontab": {},
        ".config/fzf-notes": {},
        ".config/git/config": {},
        ".config/git/gitignore_global": {},
        ".config/irb/irbrc": {},
        ".config/jrnl/jrnl.yaml": {},
        ".config/kitty": {},
        ".config/newsboat/urls": {},
        ".config/newsboat/config": {},
        ".config/nvim": {},
        ".config/nvim-old": {},
        ".config/pycodestyle": {},
        ".config/pylintrc": {},
        ".config/python": {},
        ".config/radare2/radare2rc": {},
        ".config/ranger": {},
        ".config/rofi": {},
        ".config/shallow-backup.json": {},
        ".config/starship.toml": {},
        ".config/tmux": {},
        ".config/tuir/tuir.cfg": {},
        ".config/zathura/zathurarc": {},
        ".config/zsh": {},
        "/etc/zsh/zshenv": {},
        "/etc/zsh/zshrc": {},
        ".config/.ghci": {},
        ".ssh": {},
        ".config/task/taskrc": {}
    },
    "root-gitignore": [
        ".DS_Store",
        "dotfiles/.config/nvim/.netrwhist",
        "dotfiles/.config/nvim/spell/en.utf-8.add",
        "dotfiles/.config/nvim-lazyvim/spell/en.utf-8.add",
        "dotfiles/.config/ranger/plugins/ranger_devicons",
        "dotfiles/.config/zsh/.zcompdump*",
        "dotfiles/.ssh",
        ".pypirc"
    ],
    "dotfiles-gitignore": [
        ".DS_Store",
        ".config/nvim/.netrwhist",
        ".config/nvim/spell/en.utf-8.add*",
        ".config/nvim-lazyvim/spell/en.utf-8.add*",
        ".config/ranger/plugins/*",
        ".config/zsh/.zcompdump*",
        ".config/zsh/.zsh_history",
        ".config/zsh/.zinit",
        ".config/tmux/plugins",
        ".config/tmux/resurrect",
        ".config/zsh/.zcomet",
        ".config/zsh/.zcompcache",
        ".ssh/*",
        ".pypirc"
    ],
    "config_mapping": {
        "/Users/alichtman/Library/Application Support/Sublime Text 2": "sublime2",
        "/Users/alichtman/Library/Application Support/Sublime Text 3": "sublime3",
        "/Users/alichtman/Library/Application Support/Code/User/settings.json": "vscode/settings",
        "/Users/alichtman/Library/Application Support/Code/User/Snippets": "vscode/Snippets",
        "/Users/alichtman/Library/Application Support/Code/User/keybindings.json": "vscode/keybindings",
        "/Users/alichtman/.atom": "atom",
        "/Users/alichtman/Library/Preferences/com.apple.Terminal.plist": "terminal_plist"
    }
}

On macOS, the following files never get reinstalled when you run shallow-backup --reinstall-dots.

/etc/zsh/zshenv, /etc/zsh/zshrc

/etc/zsh does not exist. I think this block fails to account for this case:

https://github.com/alichtman/shallow-backup/blob/main/shallow_backup/reinstall.py#L45-L50

I don't have anything I really care about in those files, so I likely won't spend time on fixing this, but will accept a PR to make this feature work.