doc.silverstripe.org/app/code/updaters/SVNMarkdownUpdater.php
Damian Mooyman 6604109f31
API Split updater into a service and provide two default implementations:
- GitMarkdownUpdater
 - SVNMarkdonUpdater
Add logging for errors to SS_Log
Secure escaping of shell arguments and error detection
2016-06-24 17:48:27 +12:00

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;
}
}