andsens / homeshick

git dotfiles synchronizer written in bash
MIT License
2.11k stars 145 forks source link

Make `--force` work with `homeshick clone` #49

Closed jrhorn424 closed 3 years ago

jrhorn424 commented 11 years ago

Use case: Automated installs (should be idempotent, right?)

Expected: homeshick clone user/repo --force should not return non-zero exit when files exist. Why?

 Runtime options:
    ...
   -f, [--force]    # Overwrite files that already exist

Actual:

> $HOME/.homesick/repos/homeshick/bin/homeshick clone jrhorn424/dotfiles --batch --force
        clone https://github.com/jrhorn424/dotfiles.git
        error /home/deploy/.homesick/repos/dotfiles already exists

Same probably goes for --skip, in retrospect.

jrhorn424 commented 11 years ago

This probably doesn't work because homeshick uses git clone in the background, and git clone throws errors. I'm not sure how to tackle this, or if it is even worth it.

andsens commented 11 years ago

This would certainly be expected behavior, homeshick should delete the existing repository beforehand. The non-idempotency of the deploy script has annoyed me for a while now. The switches are only used on the link command, but they certainly also make sense in track, clone and generate commands.

jrhorn424 commented 11 years ago

I was thinking about this earlier today. Perhaps it should delete the clone, as you say, or homeshick clone could check for an existing directory. In default mode, it could ask whether your intended to just do homeshick pull, but with homeshick clone --force could just delete and re-clone.

Another alternative would be to have homeshick clone --force or another switch default to the pull behavior, and try cloning when pulling fails, but that isn't semantically as nice as the above suggestion.

g0t4 commented 6 years ago

Aside from dealing with an already existing repository, clone could also work with --force to add symlinks when in --batch mode. I might be missing something but it seems that --batch defaults to NO for symlinks. And --force can't override this to YES

andsens commented 6 years ago

Aside from dealing with an already existing repository, clone could also work with --force to add symlinks when in --batch mode. I might be missing something but it seems that --batch defaults to NO for symlinks. And --force can't override this to YES

That is easy to work around actually, just run homeshick --batch clone [repo] && homeshick link -f [castle]

g0t4 commented 6 years ago

Yeah that works, I was just confused since clone prompts to symlink but doesn’t accept —force. On Sat, Apr 21, 2018 at 10:44 Anders Ingemann notifications@github.com wrote:

Aside from dealing with an already existing repository, clone could also work with --force to add symlinks when in --batch mode. I might be missing something but it seems that --batch defaults to NO for symlinks. And --force can't override this to YES

That is easy to work around actually, just run homeshick --batch clone [repo] && homeshick link -f [castle]

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/andsens/homeshick/issues/49#issuecomment-383302300, or mute the thread https://github.com/notifications/unsubscribe-auth/AAK_3V0THgHq1eb6xfshJTAjFv2s5BlIks5tq0WzgaJpZM4BCC_k .