trilbymedia / grav-plugin-git-sync

Collaboratively Synchronize your Grav `user` folder hosted on GitHub, BitBucket or GitLab
Apache License 2.0
240 stars 58 forks source link

git-sync doesn't work with multisites #173

Closed frunika closed 4 years ago

frunika commented 4 years ago

33 was closed but still an issue

I made a fresh install of grav v1.6.26 for grav.domain.org. Setup a setup.php for subdomains, added a grav-admin skeleton in a /user/sites/sub.domain.org/

Used the sub.domain.org/admin Adminpanel to install git-sync v2.1.0 and used the wizard.

Got the "FETCH_HEAD fatal: refusing to merge unrelated histories" problem and solved it using git pull origin master --allow-unrelated-histories.

The wizard made a .git dir in user/ and not in user/sites/sub.domain.org/ and therefore git-sync syncs the main site grav.domain.org user/pages/ and not user/sites/sub.domain.org/pages

Is there a workaround? I cannot the anything in the referenced PR in #95

frunika commented 4 years ago

Any idea how to fix this?

mahagr commented 4 years ago

@w00fz Do you know the answer?

frunika commented 4 years ago

I got it to work by moving/copying the .git directory and the .gitignore.

cp -r /path/to/grav/user/.git/ /path/to/grav/user/sites/sub.domain.org/
cp /path/to/grav/user/.gitignore /path/to/grav/user/sites/sub.domain.org/.gitignore

Additionally you have to set the local_repository option in /path/to/grav/user/sites/sub.domain.org/config/plugins/git-sync.yaml correctly to where the page is located:

local_repository: '/path/to/grav/user/sites/sub.domain.org/'
frunika commented 4 years ago

The better way is, to edit the git-sync.yaml before entering the wizard and adding local_repository: '/path/to/grav/user/sites/sub.domain.org/'

The wizard will then use the correct path to create the repository.

You could create an empty .git folder in /path/to/grav/user/ to avoid the wizard to start every time.

w00fz commented 4 years ago

I am afraid I don't really have suggestions for multi-sites. I never had the need for using it as i just find it quicker to spin off a new Grav site.

If anyone has suggestions or would like to help making GitSync multi-site compatible, PR are more than welcome!

w00fz commented 4 years ago

Hey @frunika, regarding the unrelated histories, I finally got to the bottom of this issue and it appears a regression was introduced where the method returning the git version would always return true instead of the actual version.

Because the version check is necessary to ensure certain git features get enabled (like allow-unrelated-histories), the regression would prevent that from happening.

I have now fixed this and @paulhibbitts kindly helped testing this confirming it's fine. A new release v2.1.1 is out and you shouldn't be needing manually running the command from terminal anymore, as long as your git version is > 2.9.0 (which is fairly old now).

Give it a try!

frunika commented 4 years ago

Hi @w00fz, thank's for the update. I'll give it a try later. It seems it fixes the git problem, also described in #168 . But it has nothing to do with the multisite support, does it? I think the issue should be reopend.

We may need an update in the GUI (blueprint?) of the plugin, where one could enter a specific folder (or just the subsite).