Skip to content

Commit

Permalink
Merge e417fe2 into fc0bcb2
Browse files Browse the repository at this point in the history
  • Loading branch information
alichtman committed Mar 25, 2020
2 parents fc0bcb2 + e417fe2 commit 764f4b2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
7 changes: 5 additions & 2 deletions README.md
Expand Up @@ -18,7 +18,7 @@ Contents
* [What can I back up?](#what-can-i-back-up)
* [Backup Customization](#backup-customization)
* [Output Structure](#output-structure)
* [Reinstallation](#reinstallation)
* [Reinstalling Dotfiles](#reinstalling-dotfiles)
* [Inspiration](#inspiration)
* [Want to contribute?](#want-to-contribute)

Expand Down Expand Up @@ -204,10 +204,13 @@ backup_dir/
└── sublime3_list.txt
```
### Reinstallation
### Reinstalling Dotfiles
To reinstall your dotfiles, clone your dotfiles repo and make sure your shallow-backup config path can be found at either `~/.config/shallow-backup.conf` or `$XDG_CONFIG_HOME/.shallow_backup.conf`. Set the `backup-path` key in the config to the path of your cloned dotfiles. Then run `$ shallow-backup -reinstall_dots`.
When reinstalling your dotfiles, the top level `.git/`, `.gitignore`, `img/` and `README.md` files / directories are ignored.
### Inspiration
---
Expand Down
4 changes: 2 additions & 2 deletions shallow_backup/utils.py
Expand Up @@ -139,8 +139,8 @@ def get_abs_path_subfiles(directory):
root_git_dir = os.path.join(directory, ".git")
root_gitignore = os.path.join(directory, ".gitignore")
img = os.path.join(directory, "img")
readme = os.path.join(directory, "readme.md")
if not any(root_git_dir, root_gitignore, img, readme) in joined:
readme = os.path.join(directory, "README.md")
if not any(x in joined for x in [root_git_dir, root_gitignore, img, readme]):
file_paths.append(joined)
else:
print_path_red("Excluded:", joined)
Expand Down
8 changes: 8 additions & 0 deletions tests/test_reinstall_dotfiles.py
Expand Up @@ -60,6 +60,11 @@ def create_git_dir(parent):
git_dir_should_not_reinstall = create_git_dir(DOTFILES_PATH)
git_dir_should_reinstall = create_git_dir(testfolder2)

# Dotfiles / folders to not reinstall
img_dir_should_not_reinstall = create_dir(DOTFILES_PATH, "img")
create_file(img_dir_should_not_reinstall, "test.png")
create_file(DOTFILES_PATH, "README.md")

# SAMPLE DOTFILES TO REINSTALL
create_file(testfolder2, ".testsubfolder_rc1")
create_file(testfolder2, ".gitignore")
Expand All @@ -86,6 +91,9 @@ def test_reinstall_dotfiles(self):
# Don't reinstall root-level git files
assert not os.path.isdir(os.path.join(FAKE_HOME_DIR, ".git"))
assert not os.path.isfile(os.path.join(FAKE_HOME_DIR, ".gitignore"))
# Don't reinstall img or README.md
assert not os.path.isdir(os.path.join(FAKE_HOME_DIR, "img"))
assert not os.path.isfile(os.path.join(FAKE_HOME_DIR, "README.md"))
# Do reinstall all other git files
assert os.path.isdir(os.path.join(testfolder2, ".git"))
assert os.path.isfile(os.path.join(testfolder2, ".gitignore"))

0 comments on commit 764f4b2

Please sign in to comment.