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

Travis test fixes? #107

Merged
merged 1 commit into from
Oct 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
28 changes: 16 additions & 12 deletions shallow_backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,18 @@ def get_default_config():
}


def create_config_file_if_needed():
"""
Creates config file if it doesn't exist already.
"""
backup_config_path = get_config_path()
if not os.path.exists(backup_config_path):
print(Fore.BLUE + Style.BRIGHT + "Creating config file at {}".format(backup_config_path))
backup_config = get_default_config()
write_config(backup_config)



#######
# CLI
#######
Expand Down Expand Up @@ -661,7 +673,6 @@ def prompt_for_path_update(config):
move_git_folder_to_path(current_path, abs_path)



# custom help options
@click.command(context_settings=dict(help_option_names=['-h', '-help', '--help']))
@click.option('-complete', is_flag=True, default=False, help="Back up everything.")
Expand Down Expand Up @@ -696,16 +707,11 @@ def cli(complete, dotfiles, configs, packages, fonts, old_path, new_path, remote

splash_screen()

# If config file doesn't exist, create it.
if not os.path.exists(backup_config_path):
print(Fore.BLUE + Style.BRIGHT + "Creating config file at {}".format(backup_config_path))
backup_config = get_default_config()
write_config(backup_config)

#####
# Update backup path from CLI args, prompt user, or skip updating
#####

create_config_file_if_needed()
backup_config = get_config()

# User entered a new path, so update the config
Expand All @@ -717,13 +723,11 @@ def cli(complete, dotfiles, configs, packages, fonts, old_path, new_path, remote
backup_config["backup_path"] = abs_path
write_config(backup_config)

# User didn't enter the same_path flag but entered a backup option, so no path update prompt
elif old_path or complete or dotfiles or packages or fonts:
pass
# User didn't enter a new path, didn't use the same_path flag or any backup options, so prompt
else:
# User didn't enter any CLI args so prompt for path update before showing menu
elif not (old_path or complete or dotfiles or packages or fonts):
prompt_for_path_update(backup_config)


###
# Create backup directory and set up git stuff
###
Expand Down
3 changes: 2 additions & 1 deletion tests/test_git_folder_moving.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import shutil
from shallow_backup import move_git_folder_to_path, git_init_if_needed, create_gitignore_if_needed
from shallow_backup import move_git_folder_to_path, git_init_if_needed, create_config_file_if_needed, create_gitignore_if_needed

OLD_BACKUP_DIR = 'shallow-backup-test-git-old-backup-dir'
NEW_BACKUP_DIR = 'shallow-backup-test-git-new-backup-backup-dir'
Expand All @@ -13,6 +13,7 @@ class TestGitFolderCopying:
"""

def setup_method(self):
create_config_file_if_needed()
for directory in DIRS:
try:
os.mkdir(directory)
Expand Down