Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exit if a git repository exists on the new backup path #171

Merged
merged 6 commits into from
Nov 9, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions shallow_backup/git_wrapper.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import sys
import git
from shutil import move
from printing import *
Expand Down Expand Up @@ -92,6 +93,11 @@ def move_git_repo(source_path, new_path):
"""
Moves git folder and .gitignore to the new backup directory.
"""
if os.path.exists(os.path.join(new_path, '.git')) or os.path.exists(os.path.join(new_path, '.gitignore')):
alichtman marked this conversation as resolved.
Show resolved Hide resolved
print_red_bold("Git repository already exists new path ({})".format(new_path))
alichtman marked this conversation as resolved.
Show resolved Hide resolved
print_red_bold("Please choose a different directory")
alichtman marked this conversation as resolved.
Show resolved Hide resolved
sys.exit()

git_dir = os.path.join(source_path, '.git')
git_ignore_file = os.path.join(source_path, '.gitignore')

Expand Down
4 changes: 2 additions & 2 deletions shallow_backup/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ def prompt_for_path_update(config):
print_green_bold("Enter relative or absolute path:")
abs_path = expand_to_abs_path(input())
print(Fore.BLUE + "\nUpdating shallow-backup path to {}".format(abs_path) + Style.RESET_ALL)
config["backup_path"] = abs_path
write_config(config)
mkdir_warn_overwrite(abs_path)
move_git_repo(current_path, abs_path)
config["backup_path"] = abs_path
alichtman marked this conversation as resolved.
Show resolved Hide resolved
write_config(config)


def prompt_for_git_url(repo):
Expand Down