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

Clicking "save" on the wizard reloads the page but re-opens the wizard #135

Closed Bandit closed 5 years ago

Bandit commented 5 years ago

Clicking "synchronize" and "reset" take a little while and say they were successful, but I cannot see anything actually being synchronized. The little git icon in the menu says "Configure Git Sync" so it clearly still thinks something is unconfigured.

Seems like an issue initalizing the repo? If I SSH in to the base directory of the website and git status it says no repo found.

Azure Linux Web App, PHP 7.2, Git Sync 2.0.0, Grav 1.5.8

w00fz commented 5 years ago

Do you think this could be related to #96 ?

Bandit commented 5 years ago

Unfortunately no but it did help me work out the issue (why aren't these errors surfaced to the Admin UI?), which was as I suspected, an issue with initialising the repo:

Screenshot 2019-03-13 11 13 26

How do I force it to initialise (or do it manually)?

w00fz commented 5 years ago

That is a git error and it means your user folder is not a git repository at all. You can initialize it via git init (https://git-scm.com/docs/git-init) but I think this would just cause more problems for you.

You should have a repository with the user folder as root and the clone it as user folder in your Grav project.

See https://www.youtube.com/watch?v=avcGP0FAzB8

Bandit commented 5 years ago

Right now the entire site is my git repository, with the user folder just one of many folders within it. cding into my user folder locally I can see it does indeed have a different repo in it - should I be adding this repo to my parent repo so that it gets pushed to my Azure instance next time I do a release?

w00fz commented 5 years ago

That unfortunately is not what GitSync expects. GitSync wants the user folder to be its own repository and not the full Grav site. You can still have one repo for Grav (without the user folder) and another repo with just the user folder but truth be told, it is kind of overkilled and unnecessary to have Grav in a repository.

What we recommend the community to do (as well as what we do with all our projects and clients) is:

  1. Install Grav: download the zip and unzip at webroot.
  2. Create your site repository and only put there the user folder in it (exactly like we do for our skeletons, example: https://github.com/getgrav/grav-skeleton-blog-site)
  3. Remove the user folder from your Grav install and clone your site repository.

Nothing of what you have outside of user is important, you definitely don't want to keep a copy of cached files, temporary files or resampled images, it is just overkill. Once a new update of Grav comes in, you just need to do a bin/gpm selfupgrade (or update via admin) and that's it.

GitSync will now point to your site (user) repository and that's how it expects things to be setup. There are various open tickets about adding support in GitSync for a full Grav repository (Grav + User) but this is not implemented right now and it is also a bit against Grav's best practises.

Hope this makes sense, let me know if you have any other question on that regard!

Bandit commented 5 years ago

I can understand that, but how do you propose dealing with the situation where build and release / deployment is handled automatically (in my case using an Azure DevOps Pipeline into an Azure Linux Web App container) - the only simple way to do it is to have the entire Grav site in the repo, unless there is a way to install Grav from the commandline?

w00fz commented 5 years ago

Oh yeah there is definitely ways to install Grav from the command line:

  1. Via Composer
  2. From GitHub
  3. Old fashion way of curl/wget + unzip

Being all flat files you literally just need to grab the zip and unzip it then you can run bin/grav install and you are done. You can then just clone your user folder to replace the one that comes with Grav.

It's definitely most efficient as you will always get the latest Grav Core, rather than having to maintain Grav up to date in your repository. This is also why we do not advise to ever push Grav in your repositories. It also helps us of the core team to better ensure old versions of Grav aren't circulating around that much

bobbwal commented 5 years ago

I'm having this issue on a website where git-sync was previously working. I'm guessing it's a result of updating to the latest grav and git-sync versions. I have the user folder as my repo as described above but I can't save my git-sync details. Everytime I go through the wizard it's all fine, connection works and then I click save and the wizard pops up again back at the start. Any ideas? I'm guessing I'll have to restart it from scratch with a fresh repo.

bobbwal commented 5 years ago

Some how managed to get this working now. Not sure how but I'm guessing it was some kind of caching issue.