Skip to content
Extraits de code Groupes Projets
Valider 1b2f6dae rédigé par sgiehl's avatar sgiehl
Parcourir les fichiers

add more information to translation update pull requests

parent 466dd37c
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -97,6 +97,8 @@ class CreatePull extends ConsoleCommand
$inputObject->setInteractive($input->isInteractive());
$command->run($inputObject, $output);
shell_exec('git add lang/. > /dev/null 2>&1');
$changes = shell_exec('git status --porcelain -uno');
if (empty($changes)) {
......@@ -106,16 +108,68 @@ class CreatePull extends ConsoleCommand
return;
}
shell_exec('git add lang/. > /dev/null 2>&1');
$fileCount = 0;
$message = '';
API::unsetInstance(); // reset languagemanager api (to force refresh of data)
preg_match_all('/M lang\/([a-z]{2,3})\.json/', $changes, $modifiedFiles);
preg_match_all('/A lang\/([a-z]{2,3})\.json/', $changes, $addedFiles);
$modifiedList = '';
if (!empty($modifiedFiles[1])) {
foreach ($modifiedFiles[1] AS $modifiedFile) {
$fileCount++;
$languageInfo = $this->getLanguageInfoByIsoCode($modifiedFile);
$message .= sprintf("- Updated %s (%s translated)\n", $languageInfo['english_name'], $languageInfo['percentage_complete']);
}
$modifiedList = implode(', ', $modifiedFiles[1]);
}
$addedList = '';
if (!empty($addedFiles[1])) {
foreach ($addedFiles[1] AS $addedFile) {
$fileCount++;
$languageInfo = $this->getLanguageInfoByIsoCode($addedFile);
$message .= sprintf("- Added %s (%s translated)\n", $languageInfo['english_name'], $languageInfo['percentage_complete']);
}
$addedList = implode(', ', $addedFiles[1]);
}
$stats = shell_exec('git diff --numstat HEAD lang');
preg_match_all('/([0-9]+)\t([0-9]+)\tlang\/([a-z]{2,3})\.json/', $stats, $lineChanges);
$addedLinesSum = 0;
if (!empty($lineChanges[1])) {
$addedLinesSum = array_sum($lineChanges[1]);
}
$title = sprintf(
'Updated %s strings in %u languages (%s)',
$addedLinesSum,
$fileCount,
implode(', ', array($modifiedList, $addedList))
);
shell_exec('git commit -m "language update ${pluginName} refs #3430"');
shell_exec('git push');
shell_exec('git checkout master > /dev/null 2>&1');
$this->createPullRequest($input, $output);
$this->createPullRequest($output, $title, $message);
}
private function getLanguageInfoByIsoCode($isoCode)
{
$languages = API::getInstance()->getAvailableLanguagesInfo();
foreach ($languages AS $languageInfo) {
if ($languageInfo['code'] == $isoCode) {
return $languageInfo;
}
}
return array();
}
private function createPullRequest(InputInterface $input, OutputInterface $output)
private function createPullRequest(OutputInterface $output, $title, $message)
{
$dialog = $this->getHelperSet()->get('dialog');
......@@ -131,7 +185,7 @@ class CreatePull extends ConsoleCommand
--stderr /dev/null \
-o /dev/null \
-u '.$username.' \
--data "{\"title\":\"automatic translation update\",\"body\":\"autogenerated translation update\",\"head\":\"translationupdates\",\"base\":\"master\"}" \
--data "{\"title\":\"[automatic translation update] '.$title.'\",\"body\":\"'.$message.'\",\"head\":\"translationupdates\",\"base\":\"master\"}" \
-H "Accept: application/json" \
https://api.github.com/repos/piwik/piwik/pulls');
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter