Skip to content

Commit

Permalink
Merge pull request #107 from alichtman/travis-ci
Browse files Browse the repository at this point in the history
Travis test fixes?
  • Loading branch information
alichtman authored Oct 19, 2018
2 parents 9bb91b7 + 2feacfd commit f7e0b55
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
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

0 comments on commit f7e0b55

Please sign in to comment.