Closed lambopedia closed 5 years ago
Have you tried running a manual synchronization from your CLI? It seems like it's able to reach your server but it's failing.
When manually sending (redeliewer) all the same. Maybe I can see some logs, through which I can understand the source of the problem?
I progressed in figuring out the problem.
An error occurs in the module /user/plugins/git-sync/classes/GitSync.php
in line 353
.
if ($this->getConfig('logging', false)) {
$log_command = Helper::preventReadablePassword($command, $this->password);
$this->grav['log']->notice('gitsync[command]: ' . $log_command);
exec($command, $output, $returnValue);
$log_output = Helper::preventReadablePassword(implode("\n", $output), $this->password);
$this->grav['log']->notice('gitsync[output]: ' . $log_output);
} else {
exec($command, $output, $returnValue); // <---- HERE
}
Error message: "On the master branch there is nothing to commit, there are no changes in the working directory"
In general, it is strange, the idea behind the change is to get to the site. What can a mistake mean?
Webhook log:
[2018-12-21 21:06:58] grav.NOTICE: gitsync[command]: LC_ALL=en_US.UTF-8 git -C '/home/lambopedia.ru/docs/user/' status pages 2>&1 [] []
[2018-12-21 21:06:58] grav.NOTICE: gitsync[output]: nothin to commit, working tree clean [] []
[2018-12-21 21:06:59] grav.NOTICE: gitsync[command]: LC_ALL=en_US.UTF-8 git -C '/home/lambopedia.ru/docs/user/' add . 2>&1 [] []
[2018-12-21 21:06:59] grav.NOTICE: gitsync[output]: [] []
[2018-12-21 21:06:59] grav.NOTICE: gitsync[command]: LC_ALL=en_US.UTF-8 git -C '/home/lambopedia.ru/docs/user/' commit --author="lambopedia <lambopedia@ya.ru>" -m '(Grav GitSync) Automatic Commit from lambopedia' 2>&1 [] []
[2018-12-21 21:06:59] grav.NOTICE: gitsync[output]: nothin to commit, working tree clean [] []
How to make git pull command?
The error works here:
public function synchronize()
{
if (!Helper::isGitInstalled() || !Helper::isGitInitialized()) {
return true;
}
$this->grav->fireEvent('onGitSyncBeforeSynchronize');
if ($this->git->hasChangesToCommit()) {
$this->git->commit(); // <------ HERE
}
// synchronize with remote
$this->git->sync();
$this->grav->fireEvent('onGitSyncAfterSynchronize');
return true;
}
Apparently "hasChangesToCommit" for some reason gives the wrong result..
$message = 'nothing to commit';
$output = $this->execute('status ' . implode(' ', $paths));
return (substr($output[count($output)-1], 0, strlen($message)) !== $message); // <--- PROBLEM IS HERE
In the logs, in fact, this:
[2018-12-21 21:05:50] grav.NOTICE: gitsync[command]: LC_ALL=en_US.UTF-8 git -C '/home/lambopedia.ru/docs/user/' commit --author="lambopedia <lambopedia@ya.ru>" -m '(Grav GitSync) Automatic Commit from lambopedia' 2>&1 [] []
[2018-12-21 21:05:50] grav.NOTICE: gitsync[output]: На ветке master нечего коммитить, нет изменений в рабочем каталоге [] []
I did not know that there is a comparison of the line and translated the message into English.
Hmm.. why is this command may not work?
LC_ALL=en_US.UTF-8
Like this all work:
public function execute($command, $quiet = false)
{
try {
. . .
if (DIRECTORY_SEPARATOR == '/') {
// ++ lambopedia 2018.12.23
//$command = 'LC_ALL=en_US.UTF-8 ' . $command;
$command = 'LC_ALL=C ' . $command;
// -- lambopedia 2018.12.23
}
. . .
} catch (\RuntimeException $e) {
. . .
}
}
Thanks @lambopedia this is now merged and released. Good catch!
Hello! A couple of days I can not deal with the problem. I set up the plugin exactly as in the video. At changes in a repository (push) the webhook returns an error, a code 500.
I tried to use HTTPS and not use. I tried both "github" and "bitbucked" - the result is one. Now I do not understand in which direction to diagnose the problem.
Please offer something.