|
|
|
@ -9,7 +9,7 @@ namespace autodoc\Helpers;
|
|
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
|
|
|
use Symfony\Component\Console\Input\StringInput; |
|
|
|
|
use Symfony\Component\Console\Input\ArgvInput; |
|
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
|
|
|
use Symfony\Component\Console\Output\Output; |
|
|
|
|
use autodoc\Application as Autodoc; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -47,7 +47,7 @@ class Generator
|
|
|
|
|
* @param InputInterface $input |
|
|
|
|
* @param OutputInterface $output |
|
|
|
|
**/ |
|
|
|
|
public function __construct(InputInterface $input, OutputInterface $output, $autoloader = null) |
|
|
|
|
public function __construct(InputInterface $input, Output $output, $autoloader = null) |
|
|
|
|
{ |
|
|
|
|
$this->input = $input; |
|
|
|
|
$this->output = $output; |
|
|
|
@ -56,6 +56,10 @@ class Generator
|
|
|
|
|
$this->setApplicationDirectories(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function isVerbose() { |
|
|
|
|
return $this->output->isVerbose(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Obtient le chemin d'un executable sur le serveur. |
|
|
|
|
* |
|
|
|
@ -691,41 +695,92 @@ class Generator
|
|
|
|
|
$res = $this->makeCheckoutCommand('--read'); |
|
|
|
|
if (!$res or false === stripos(implode("", $res), $source)) { |
|
|
|
|
// erreur, donc pas un dossier ou pas le bon |
|
|
|
|
$this->output->write("<comment> - Source absente ou mauvaise, on le recrée</comment>"); |
|
|
|
|
$this->deleteDirectoryContent($this->dirs['input']); |
|
|
|
|
$this->output->writeln("<comment> - Source absente ou mauvaise, on le recrée</comment>"); |
|
|
|
|
$this->deleteDirectoryContent($this->dirs['input'], true); |
|
|
|
|
} |
|
|
|
|
$res = $this->makeCheckoutCommand("$type -b$branche $source"); |
|
|
|
|
$res = $this->makeCheckoutCommand("$type -b$branche $source", false); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// On récupère le numéro de dernière révision, ça peut servir |
|
|
|
|
if ($revision = $this->recuperer_revision_git()) { |
|
|
|
|
$this->git['revision'] = $revision; |
|
|
|
|
if ($infos = $this->recuperer_infos_git()) { |
|
|
|
|
$this->git['revision'] = $infos['revision']; |
|
|
|
|
$this->git['branche'] = $infos['branche']; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Retrouver le numéro de la dernière révision du dossier de travail |
|
|
|
|
* |
|
|
|
|
* @return string Numéro de révision (si connu) |
|
|
|
|
**/ |
|
|
|
|
function recuperer_revision_git() { |
|
|
|
|
$revision = ''; |
|
|
|
|
function recuperer_infos_git() { |
|
|
|
|
$infos = []; |
|
|
|
|
|
|
|
|
|
// Ici, on a les bons fichiers SVN à jour |
|
|
|
|
// on récupère le numéro de dernière révision |
|
|
|
|
if ($res = $this->makeCheckoutCommand('--read')) { |
|
|
|
|
$this->output->writeln($res); |
|
|
|
|
$res = trim($res[0]); |
|
|
|
|
$res = explode(' ', $res); |
|
|
|
|
$revision = substr($res[3], 2); // -r{revision} |
|
|
|
|
$infos['revision'] = substr($res[2], 2); // -r{revision} |
|
|
|
|
$infos['branche'] = substr($res[3], 2); // -b{branche} |
|
|
|
|
$infos['url'] = $res[4]; |
|
|
|
|
} |
|
|
|
|
return $infos; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $revision; |
|
|
|
|
/** |
|
|
|
|
* Retrouver le numéro de la dernière révision du dossier de travail |
|
|
|
|
* |
|
|
|
|
* @return string Numéro de révision (si connu) |
|
|
|
|
**/ |
|
|
|
|
function recuperer_revision_git() { |
|
|
|
|
$infos = $this->recuperer_infos_git(); |
|
|
|
|
return $infos ? $infos['revision'] : ''; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Exécuter la commande checkout indiquée |
|
|
|
|
* |
|
|
|
|
* @param string $cmd Commande Checkout |
|
|
|
|
* @param bool $no_error true : Envoie les erreurs dans /dev/null |
|
|
|
|
* @return mixed|bool false en cas d'erreur |
|
|
|
|
**/ |
|
|
|
|
private function makeCheckoutCommand($cmd, $no_error = true, $dir = null) { |
|
|
|
|
if (is_null($dir)) { |
|
|
|
|
$dir = $this->dirs['input']; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!$checkout = $this->obtenir_commande_serveur('checkout.php')) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
$no_error = $no_error ? '2> /dev/null' : ''; |
|
|
|
|
# checkout doit se lancer depuis le répertoire parent |
|
|
|
|
$dest = basename($dir); |
|
|
|
|
$root = dirname($dir); |
|
|
|
|
|
|
|
|
|
$cmd = "cd $root && $checkout $cmd $dest $no_error"; |
|
|
|
|
if ($this->isVerbose()) { |
|
|
|
|
$this->output->writeln($cmd); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
exec($cmd, $res, $error); |
|
|
|
|
if ($this->isVerbose()) { |
|
|
|
|
$this->output->writeln($res); |
|
|
|
|
} |
|
|
|
|
if ($error) { |
|
|
|
|
if ($this->isVerbose()) { |
|
|
|
|
$this->output->writeln($error); |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
return $res; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Télécharge ou met à jour la source SVN indiquée |
|
|
|
|
* |
|
|
|
@ -802,31 +857,6 @@ class Generator
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Exécuter la commande checkout indiquée |
|
|
|
|
* |
|
|
|
|
* @param string $cmd Commande Checkout |
|
|
|
|
* @param bool $no_error true : Envoie les erreurs dans /dev/null |
|
|
|
|
* @return mixed|bool false en cas d'erreur |
|
|
|
|
**/ |
|
|
|
|
private function makeCheckoutCommand($cmd, $no_error = true, $dir = null) { |
|
|
|
|
if (is_null($dir)) { |
|
|
|
|
$dir = $this->dirs['input']; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!$checkout = $this->obtenir_commande_serveur('checkout.php')) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
$no_error = $no_error ? '2> /dev/null' : ''; |
|
|
|
|
# checkout doit se lancer depuis le répertoire parent |
|
|
|
|
$dest = basename($dir); |
|
|
|
|
$root = dirname($dir); |
|
|
|
|
|
|
|
|
|
exec("cd $root && $checkout $cmd $dest $no_error", $res, $error); |
|
|
|
|
if ($error) return false; |
|
|
|
|
return $res; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Exécuter la commande svn indiquée |
|
|
|
@ -1056,7 +1086,12 @@ class Generator
|
|
|
|
|
$presentation = "Cette documentation est issue du code source PHP de SPIP $version. "; |
|
|
|
|
} else { |
|
|
|
|
$rev = ""; |
|
|
|
|
if (isset($this->svn['revision']) and $revision = $this->svn['revision']) { |
|
|
|
|
if (isset($this->git['branche']) and $branche = $this->git['branche'] and $branche !== 'master') { |
|
|
|
|
$rev .= " [$branche]"; |
|
|
|
|
} |
|
|
|
|
if (isset($this->git['revision']) and $revision = $this->git['revision']) { |
|
|
|
|
$rev .= " (révision $revision)"; |
|
|
|
|
} elseif (isset($this->svn['revision']) and $revision = $this->svn['revision']) { |
|
|
|
|
$rev .= " (révision $revision)"; |
|
|
|
|
} |
|
|
|
|
$presentation = "Cette documentation est issue du code source PHP du plugin « ".$nom." », version $version$rev. "; |
|
|
|
|