Use git reset --hard instead of git pull to refresh local files
Better error reporting
This commit is contained in:
parent
055888bf71
commit
2c8cba75be
|
@ -28,20 +28,20 @@ class GitMarkdownUpdater implements MarkdownUpdater
|
||||||
*/
|
*/
|
||||||
protected function doFetch($path, $branch) {
|
protected function doFetch($path, $branch) {
|
||||||
$errors = array();
|
$errors = array();
|
||||||
$checkoutCommand = sprintf(
|
$fetchCommand = sprintf(
|
||||||
'cd %s && git checkout %s',
|
'cd %s && git fetch origin %s',
|
||||||
escapeshellarg($path),
|
escapeshellarg($path),
|
||||||
escapeshellarg($branch)
|
escapeshellarg($branch)
|
||||||
);
|
);
|
||||||
$pullCommand = sprintf(
|
$resetCommand = sprintf(
|
||||||
'cd %s && git pull origin %s',
|
'cd %s && git reset --hard origin/%s',
|
||||||
escapeshellarg($path),
|
escapeshellarg($path),
|
||||||
escapeshellarg($branch)
|
escapeshellarg($branch)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Run
|
// Run
|
||||||
if($this->runCommand($checkoutCommand, $errors)) {
|
if($this->runCommand($fetchCommand, $errors)) {
|
||||||
$this->runCommand($pullCommand, $errors);
|
$this->runCommand($resetCommand, $errors);
|
||||||
}
|
}
|
||||||
return $errors;
|
return $errors;
|
||||||
}
|
}
|
||||||
|
@ -73,9 +73,12 @@ class GitMarkdownUpdater implements MarkdownUpdater
|
||||||
* @return bool Flag if the command was successful
|
* @return bool Flag if the command was successful
|
||||||
*/
|
*/
|
||||||
protected function runCommand($cmd, &$errors = array()) {
|
protected function runCommand($cmd, &$errors = array()) {
|
||||||
exec($cmd, $output, $result);
|
exec("{$cmd} 2>&1 >/dev/null", $output, $result);
|
||||||
if($result) {
|
if($result) {
|
||||||
$errors[] = "Error running command {$cmd}";
|
$errors[] = "Error running command {$cmd}:";
|
||||||
|
foreach($output as $error) {
|
||||||
|
$errors[] = ' * ' . $error;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue