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

extra trailing slash for web hook URL in wizard #15

Closed mikegcox closed 7 years ago

mikegcox commented 7 years ago

When using the wizard, the URL specified for the WebHook has an extra trailing slash that should not show.

http://mydomainname.ca//_git-sync

It should show as http://mydomainname.ca/_git-sync

w00fz commented 7 years ago

Hi Mike,

thanks for opening the issue in here. For reference, this is the conversation we had on Disqus:

Mike: I am having a hard time getting this to work. In order to get the Wizard to come up, I first had to add /usr/local/cpanel/3rdparty/bin/git to the Git Binary Path. Once I did that, the wizard came up. I put in the credentials for GitHub and in the next step I add my repository and pressed the Test Connection button and got this: sh: git: command not found. But GIT is working on the server from command line using the path above. If I proceed to the end of the wizard and save my configuration and press Synchronize I get a GitSynch has successfully synchronized with the repository message. When I go to my repo on GitHub, there is nothing there and no history with my web hook.

w00fz: Can you try going in one of your Pages and make a change there? Saving should push it

Mike: I did try that and it does not do anything. Also the .git folder does not get created. One oddity that I am looking into is this: Step 3 of the wizard, I am given the URL to put in as the web hook and it is "http://www.mydomainame.ca//_gi...". I took out the extra slash "/" at the end of the domain when making my webhook. If I put that URL into a browser I do get a success message on the page that loads. If I put in the extra slash I do not. Maybe the plugin is trying to use //?

w00fz: Yes that extra / is not supposed to be there, only 1 and the rest is good. That is an issue I noticed that I still need to look at. Would you mind opening an issue on GitHub so we can better follow up on this? I'm not quite sure why you are getting this issue but it sounds like the binary is just not reachable at all. Did not specifying the git binary location at all just not worked for you?

Mike: But I get the impression that the binary is reachable because when I don't have the path specified, the wizard pops up telling me I don't have git. When I put in the path to the binary, the wizard is accessible. How could I know for sure?

Right, if we the default setting you got the modal and after pointing to the binary you didn't, that means it is reachable because to verify it the check actually does a git --version. There must be something else going on but it's kind of hard for me to understand what it is without being able to look at it directly.

Try enabling the Log Git Commands option and run a Synchronization, you should now get logs under logs/grav.log and hopefully some more details about the error that happens (if any).

Please make sure to remove any sensitive data if you are going to post the log in here.

mikegcox commented 7 years ago

Here is my error log: mikxxxxxx is my github username.

{password}@github.com/mikxxxxxx/vintagemoto.git" 2>&1 [] [] [2017-02-01 18:41:51] grav.NOTICE: gitsync[output]: sh: git: command not found [] [] [2017-02-01 20:15:02] grav.NOTICE: gitsync[command]: LC_ALL=en_US.UTF-8 git -C '/home/ffcmsbiz/public_html/vintagemoto.ca/user/' ls-remote "https://mikxxxxxx:

w00fz commented 7 years ago

Sounds like it's not using the specified binary, this might be a bug. Can you double check in user/plugins/git-sync.yaml that the bin location is effectively the custom one you specified?

mikegcox commented 7 years ago

Yup, it is correct. I can paste it in here if you like

w00fz commented 7 years ago

No that's fine. I'll look into this, might be an issue. What you can try to do is to edit the file classes/Helper.php and at line 46 (https://github.com/trilbymedia/grav-plugin-git-sync/blob/develop/classes/Helper.php#L46) change the return statement to your hardcoded path, such as return /usr/local/cpanel/3rdparty/bin/git;

Then try again some action and keep an eye on the logs, see if that fixes it.

mikegcox commented 7 years ago

It seems to work now with that modification. It it taking some time to synch though, kind of a big site. It did make the .git folder and and it passed the test in the wizard.

mikegcox commented 7 years ago

I am getting git synch errors now, might be a slow server issue but I will try again tomorrow. I think we made good progress though today.

mikegcox commented 7 years ago

I am getting a timeout from my slow server. My initial commit is quite big. I was able to do a commit from my local computer (mac) which worked just fine, I am now working with wirenine to increase my timeout but the plugin works just fine after putting in the return manually at line 46 of the helper.

w00fz commented 7 years ago

Thank for troubleshooting this, helped a lot. I'll fix the issue of the binary not getting used when set in admin, that seems to be a bug.

Cheers.

mikegcox commented 7 years ago

I was trying again to get my site to synch, but it would not, I keep getting a timeout error which I blamed my host for - that and my site is kind of big. So I removed all the pages from the site and tried a synch but I get the same timeout error. I checked the grav log and I get similar errors as above.

[2017-02-04 14:58:17] grav.NOTICE: gitsync[output]: https://github.com/mixxxxxx/vintxxxxxx.git [] []
[2017-02-04 14:58:19] grav.NOTICE: gitsync[command]: LC_ALL=en_US.UTF-8 /usr/local/cpanel/3rdparty/bin/git -C '/home/ffcmsbiz/public_html/vintxxxxxx.ca/user/' remote set-url origin "https://mixxxxxx:{password}@github.com/mixxxxxxx/vintxxxxxxx.git" 2>&1 [] []

I know the plugin works fine if the git binary where you expect it to be, I am tempted to switch to a different host to get more resources, but for now let me know what I can do to help get this fixed.

mikegcox commented 7 years ago

One more observation... Synch is working from GitHub to the live site but not from the Live site to GitHub. If I make a change to a page on my local computer and save it, the change is synched to the live site.

w00fz commented 7 years ago

Hey Mike, both the binary setting not working and the extra trailing slash are now fixed.

Thank you!