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

Enhance git repo move #168

Closed
nunomdc opened this issue Oct 30, 2018 · 5 comments
Closed

Enhance git repo move #168

nunomdc opened this issue Oct 30, 2018 · 5 comments
Labels
bug Something isn't working
Milestone

Comments

@nunomdc
Copy link
Contributor

nunomdc commented Oct 30, 2018

An error is thrown when moving the git repository if one already exists on the output directory.

(shallow-backup) $ ls -a ~/sh-back
.  ..  .git  .gitignore
(shallow-backup) $ ls -a ~/sh-back-2
.  ..  .git  .gitignore
(shallow-backup) $ python shallow_backup/cli.py


              dP                dP dP                        dP                         dP
              88                88 88                        88                         88
     ,d8888'  88d888b. .d8888b. 88 88 .d8888b. dP  dP  dP    88d888b. .d8888b. .d8888b. 88  .dP  dP    dP 88d888b.
     Y8ooooo, 88'  `88 88'  `88 88 88 88'  `88 88  88  88    88'  `88 88'  `88 88'  `"" 88888"   88    88 88'  `88
           88 88    88 88.  .88 88 88 88.  .88 88.88b.88'    88.  .88 88.  .88 88.  ... 88  `8b. 88.  .88 88.  .88
     `88888P' dP    dP `88888P8 dP dP `88888P' 8888P Y8P     88Y8888' `88888P8 `88888P' dP   `YP `88888P' 88Y888P'
                                                                                                          88
                                                                                                          dP	
	v1.4a by Aaron Lichtman (@alichtman)

Current shallow-backup path: /home/nunomdc/sh-back
[?] Would you like to update this?:  Yes
 >  Yes
    No

Enter relative or absolute path:
~/sh-back-2

Updating shallow-backup path to /home/nunomdc/sh-back-2
Traceback (most recent call last):
  File "shallow_backup/cli.py", line 180, in <module>
    cli()
  File "/home/nunomdc/.local/share/virtualenvs/shallow-backup-zRzFi1jy/lib/python3.6/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/nunomdc/.local/share/virtualenvs/shallow-backup-zRzFi1jy/lib/python3.6/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/nunomdc/.local/share/virtualenvs/shallow-backup-zRzFi1jy/lib/python3.6/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/nunomdc/.local/share/virtualenvs/shallow-backup-zRzFi1jy/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "shallow_backup/cli.py", line 79, in cli
    prompt_for_path_update(backup_config)
  File "/home/nunomdc/repos/shallow-backup/shallow_backup/prompts.py", line 25, in prompt_for_path_update
    move_git_repo(current_path, abs_path)
  File "/home/nunomdc/repos/shallow-backup/shallow_backup/git_wrapper.py", line 99, in move_git_repo
    move(git_dir, new_path)
  File "/home/nunomdc/.local/share/virtualenvs/shallow-backup-zRzFi1jy/lib/python3.6/shutil.py", line 542, in move
    raise Error("Destination path '%s' already exists" % real_dst)
shutil.Error: Destination path '/home/nunomdc/sh-back-2/.git' already exists
@alichtman alichtman added the bug Something isn't working label Oct 31, 2018
@alichtman
Copy link
Owner

alichtman commented Oct 31, 2018

To fix this, we should make sure that the path doesn't exist before copying it. If it does exist, print an error message and exit. I believe the method responsible for moving the git repo is in git-wrapper.py, potentially called move_git_repo(), but I'm not sure.

@nunomdc
Copy link
Contributor Author

nunomdc commented Oct 31, 2018

What would be the expected behaviour on error?

  • exit the application
  • prompt for overwrite
  • other option

@alichtman
Copy link
Owner

alichtman commented Oct 31, 2018

If it does exist, print an error message and exit.

I don't want to add an overwrite feature since the .git folder could be critically important. That should have to be removed manually.

@nunomdc
Copy link
Contributor Author

nunomdc commented Oct 31, 2018

If it does exist, print an error message and exit.

Ok. So should we exit early, as soon as the issue is detected?
Have a look at this commit nunomdc@6b27205

@alichtman
Copy link
Owner

Open a PR so I can leave comments on specific lines. That commit is close, but not exactly how I think this feature should work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants