mirror of
https://github.com/silverstripe/doc.silverstripe.org
synced 2024-10-22 17:05:50 +02:00
6604109f31
- GitMarkdownUpdater - SVNMarkdonUpdater Add logging for errors to SS_Log Secure escaping of shell arguments and error detection
34 lines
711 B
PHP
34 lines
711 B
PHP
<?php
|
|
|
|
class SVNMarkdownUpdater implements MarkdownUpdater
|
|
{
|
|
public function update($repo, $path, $branch)
|
|
{
|
|
$errors = array();
|
|
$svnPath = "https://github.com/{$repo}.git/branches/{$branch}/docs";
|
|
$svnDest = "{$path}/docs";
|
|
$this->runCommand(sprintf(
|
|
"svn export %s %s",
|
|
escapeshellarg($svnPath),
|
|
escapeshellarg($svnDest)
|
|
), $errors);
|
|
return $errors;
|
|
}
|
|
|
|
/**
|
|
* Run this command
|
|
*
|
|
* @param string $cmd
|
|
* @param array $errors
|
|
* @return bool Flag if the command was successful
|
|
*/
|
|
protected function runCommand($cmd, &$errors = array()) {
|
|
exec($cmd, $output, $result);
|
|
if($result) {
|
|
$errors[] = "Error running command {$cmd}";
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
}
|