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

GitSync auto-commits to incorrect path #137

Closed bewards closed 5 years ago

bewards commented 5 years ago

Being relatively new to Grav I may not fully understand why it's doing this, but when I add a plugin or a blog page via admin panel on my live site, the sync commits blog page files (from the server) under/pages/01.blog/[blog page] instead of /user/pages/01.blog/[blog page], as well as /plugins/ instead of /user/plugins/.

When I pull these changes down locally, none of the pages i've published live or plugins are available and have to be moved in to the user folder.

Then if I commit and push up some custom css under user/themes/mytheme/css or add a partial under user/themes/mytheme/templates/partials in order to override some markup from the default theme (that works locally) and hit Synchronize, I don't see these files being added to that directory location on the server.

In the public site admin panel I do have the wizard configured for Pages, Themes, and Plugins.

nick-dolan commented 5 years ago

The same question.

w00fz commented 5 years ago

That doesn't look right indeed. Can you guys describe your environment, settings as well as how is your repository structure? Is it just the user folder?

Also you can run bin/plugin git-sync status to get some configurations view. Please be careful with what you paste in here as this is publicly viewable.

Another thing you can check is how your sparsecheckout git config look like, from the root of the project run a cat user/.git/info/sparse-checkout

nick-dolan commented 5 years ago

I don't know whether it's the right method or not but seem I solved it this way:

  1. Install The Grav on the server with the first method of the install guide.
  2. Install and set up Git Sync on the server.
  3. Install Grav on the local machine.
  4. Remove all folders from user folder on the local machine (except accounts)
  5. Pull to user folder what Sync committed to git.

The issue was when I tried to set up Sync with existing the whole repository (as we can get with option 3: Install from GitHub from install guide)

bewards commented 5 years ago

My Grav site is hosted on Linode Ubuntu 18.04 LTS.

Running bin/plugin git-sync status locally gives the following (user/pass actually came up as null): image

Running bin/plugin git-sync status on the server gives the following:

plugin runtime information:
array:17 [
  "branch" => "master"
  "enabled" => true
  "folders" => "['pages', 'themes', 'plugins']"
  "git" => array:5 [
    "author" => "gituser"
    "name" => "GitSync"
    "email" => "git-sync@trilby.media"
    "bin" => "git"
    "message" => "(Grav GitSync) Automatic Commit"
  ]
  "gitVersion" => "2.17.1"
  "isGitInitialized" => true
  "logging" => false
  "password" => "REMOVED"
  "remote" => array:2 [
    "name" => "origin"
    "branch" => "master"
  ]
  "repository" => "https://github.com/bewards/tech-blog-grav.git"
  "repositoryPath" => "/home/grav/www/html/user/"
  "sync" => array:5 [
    "on_save" => true
    "on_delete" => true
    "on_media" => true
    "cron_enable" => false
    "cron_at" => "0 12,23 * * *"
  ]
  "text_var" => "Custom Text added by the **Git Sync** plugin (disable plugin to remove)"
  "username" => "bewards"
  "webhook" => "REMOVED"
  "webhook_enabled" => "0"
  "webhook_secret" => "REMOVED"
]

detect git workspace root:
  /home/grav/www/html/user

...
Working state is not clean.

Running cat user/.git/info/sparse-checkout locally returns "No such file or directory" as there is no .git directory underneath /user. On the server there is a .git directory underneath /user, so running is on the server gives the following:

pages/
pages/*
themes/
themes/*
plugins/
w00fz commented 5 years ago

Looks like your gitsync instance is misconfigured or somewhat broken. You should definitely have a .git folder under user for all the git configurations of your repo and sparse checkout.

Try enabling gitsync logging and try going through the wizard once again. Also try to save the plugin after the wizard is done.

bewards commented 5 years ago

Thanks @w00fz - resolved by walking through the wizard again and updating the web hook to ssl and re-saving with the webhook secret. After saving, I now see the .git directory under /user.

This can be closed.

w00fz commented 5 years ago

Awesome, glad it’s resolved 👍