design-center icon indicating copy to clipboard operation
design-center copied to clipboard

VCS::vcs_mirror doesn't work if directory already exists

Open ahdinosaur opened this issue 13 years ago • 4 comments

Hi, git doesn't clone if directory already exists. That wasn't okay because the repositories I wanted to mirror were sections of configuration in /etc/, not necessarily entire directories.

Here's a fix I made: https://github.com/ahdinosaur/design-center/blob/09d9045a6a4fade45f75163266393d4cec085d8c/sketches/utilities/vcs_mirror/main.cf. Probably not the best (I'm new to cfengine), but it works for me.

Thanks.

ahdinosaur avatar Dec 19 '12 08:12 ahdinosaur

I think the right behavior is not to overwrite an existing directory; the user of VCS::vcs_mirror can do a files promise to remove the directory if it's necessary. This is a little tricky because I can see the case for the other behavior as well. Maybe I should make it an option, "clear_existing_dir" for instance? What do you think?

tzz avatar Dec 19 '12 13:12 tzz

I don't want to clear the existing directory completely, I want to keep all the files in the existing directory and clone a git repository on top of it that has new files and may or may not override some overlapping files. My solution came from this: http://stackoverflow.com/questions/2411031/git-how-do-i-clone-into-a-non-empty-directory.

ahdinosaur avatar Dec 20 '12 02:12 ahdinosaur

I'll include this if it's special behavior, explicitly turned on by the user with a flag. I think the default behavior should be to disallow using an existing non-empty directory.

If you're OK with that, please submit a pull request or rebase your repo with the necessary changes, or let us know to make the changes ourselves.

Thank you!

tzz avatar Dec 23 '12 19:12 tzz

Please test the pull request #208.

tzz avatar Jan 08 '13 18:01 tzz