trilbymedia / grav-plugin-git-sync

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

Git-Sync pushes to the root of my Github folder #25

Closed tilb closed 6 years ago

tilb commented 7 years ago

I connected Git-Sync to my repo and it succesfully pushes to it. The only thing though is that it pushes a /pages folder to my root.

schermafbeelding 2017-02-22 om 11 45 45

I tried fixing it by changing a setting in the user/plugins/git-sync/blueprints.yaml file. I changed default: ['pages'] to default: ['user/pages']. This did not solve the issue. Then I tried changing the payload url of my webhook to http://178.62.255.166/user/_git-sync. This also did not solve it. @olevik suggested I'd create an issue here. Is it a Git-Sync issue or am I doing something wrong?

OleVik commented 7 years ago

We should note that you are using MAMP on OSX, working from http://localhost/. It seems to me that the issue is that Git Sync pushes the entirety of the Grav installation to the repo, not just /pages as it should.

jacobmllr95 commented 7 years ago

I've got the exact same problem as @tilb and I'am not using MAMP.

tilb commented 7 years ago

@OleVik I think there is a misunderstanding. I want the whole grav installation in my Github repo, so I can version control the whole website (and my theme development). Also I initiated the Git-Sync plugin from production, so I wonder how localhost can cause a problem.

OleVik commented 7 years ago

Ahh, this then relates to #21, as the plugin currently only syncs the user/pages-folder, not the entirety of Grav. To do that, you'd need to not use the plugin, but set up the sync yourself.

jacobmllr95 commented 7 years ago

@OleVik By looking at the code I found out that my problem is related to that. I've expected this plugin to follow the directory structure of the Grav repo but it starts at the user directory.

Are there any plans to make this configurable in the future? That would be awesome 🎉

OleVik commented 7 years ago

As @w00fz remarked in issue 21, Grav can only trigger the git synchronization on changes in pages, not in themes/plugins. "Config/Data/Accounts could be detected", but they contain sensitive personal and system data, so pushing them is inherently risky on several levels - causing e-mail addresses to easily be left public, as well as creating conflicts in configurations.

As noted, the plugin deliberately only syncs the user/pages-folder - though it has the potential for syncing more content from the user-folder - because of the lack of a hook for changes in themes/plugins other than version bumps. It would be far safer to set up this git-syncing yourself, where you are certain that the target repository and server are both secured, and just as importantly you have control of merge conflicts and erroneous configurations.

Though the plugin could be extended to take all this into consideration, there would be a virtually endless list of Yes/No questions asked before pushing to the repository, to avoid conflicts. If you need a complete sync of a site, git already allows that intuitively, with better systems for preventing conflicts - just set your entire Grav-folder up to sync to a private repository, and from there add the webhook to push to the server. You will have to push each change yourself, but indeed you want to do so, because any significant change should be checked for errors and conflicts by the author - you - rather than by Grav.

That said, I would personally go the "partial route" and set up two repositories: One for Grav excluding user/pages, and one for Git Sync to push on updates in user/pages. That way I have central control of everything except for that which is deemed fairly fail-safe: Content in pages.

jacobmllr95 commented 7 years ago

@OleVik I understand your concerns. The idea with the two separated repos sounds like a good solution for me :)

glasswork commented 7 years ago

I am fine with the plugin only pushing the user/pages folder (that is all anyone should be touching on the server - development should be local). But it would be nice if it would put the user/pages folder where the user/pages folder falls in the site structure rather than at root. Any chance of that? Thanks.

edit: I am using the plugin on an Ubuntu/Apache flavored server via AWS.

ngstigator commented 7 years ago

In my repo that has existing pages, enabling the plugin and creating a new page saves them in a folder called "pages" at the root of the site (instead of within the "user" folder). Git operations in the command line has such unintended results as nested "user" folders. It seems that a way to set the root might help.

lianhuilui commented 7 years ago

I am also having the problem. Looking at other issues, it seems other users are getting user/pages synced, which is not the case with me (and other users on this thread?) I am getting a new folder in root and user/pages is modified but not synced. How do I solve this?

Coderwelsch commented 7 years ago

Same problems here, when I will change some content on an test sub domain GitSync will push these changes to root directory of my repo. I wondered that I couldn't see the changes localy after a git pull, because the files are synced to the root dir :/

screen shot 2017-08-20 at 17 41 58