Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f9921a1
DTO for revcheck data.
Oct 25, 2024
d72bb52
Preparation for revcheck data exporting.
Oct 26, 2024
72453ce
Backport loose and fixed [skip-revcheck] modes
Oct 26, 2024
600714c
Additional revcheck data.
Nov 1, 2024
221e0dc
Revcheck deduplication: clean up, header.
Nov 1, 2024
83fb651
Revcheck deduplication: translators, file summary.
Nov 1, 2024
3b62b38
Revcheck deduplication: old/wip files.
Nov 5, 2024
156b0b5
Move backport code and docs to a separate file.
Nov 5, 2024
4405435
Revcheck deduplication: backport couting behaviour.
Nov 5, 2024
31cf0db
Revcheck deduplication: more backport couting woes.
Nov 5, 2024
324f48c
Revcheck deduplication: notinen, revtag, unstranslated.
Nov 5, 2024
60b5f1e
Revcheck deduplication: ignore, regex, xml.
Nov 6, 2024
a0ddca6
Revcheck deduplication: adds/dels, clean up.
Nov 6, 2024
55bae33
Revcheck deduplicatoin: genrevdb.php.
Nov 7, 2024
1ab908c
Revcheck deduplicatoin: genrevdb.php.
Nov 7, 2024
a08561f
More backport and small fixes.
Nov 7, 2024
d254ced
Review changes/fixes.
Nov 7, 2024
117a61d
Better log messages.
Nov 7, 2024
3eb4ef5
Remove unrelated filter.
Nov 8, 2024
bf4f663
Merge branch 'php:master' into master
alfsb Nov 11, 2024
e1f8400
Changes revcheck to consider one or many hashes, instead of two.
Nov 11, 2024
0460e4b
Changes revcheck to consider one or many hashes, instead of two.
Nov 11, 2024
0d5b26a
Changes revcheck to consider one or many hashes, instead of two.
Nov 11, 2024
a58d5a2
Merge branch 'php:master' into FIXED_SKIP_REVCHECK
alfsb Nov 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Preparation for revcheck data exporting.
  • Loading branch information
André L F S Bacci committed Oct 31, 2024
commit d72bb5273577d7ef563fa6caf2d5b25d2bd041e0
47 changes: 33 additions & 14 deletions scripts/translation/lib/RevcheckData.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,42 @@

enum RevcheckStatus : string
{
case TranslatedOk = 'TranslatedOk';
case TranslatedOld = 'TranslatedOld';
case TranslatedWip = 'TranslatedWip';
case Untranslated = 'Untranslated';
case RevTagProblem = 'RevTagProblem';
case NotInEnTree = 'NotInEnTree';
case TranslatedOk = 'TranslatedOk';
case TranslatedOld = 'TranslatedOld';
case TranslatedWip = 'TranslatedWip';
case Untranslated = 'Untranslated';
case RevTagProblem = 'RevTagProblem';
case NotInEnTree = 'NotInEnTree';
}

class RevcheckData
{
public $translators = array(); // RevcheckDataTranslator
public $translators = array(); // nick, RevcheckDataTranslator
public $fileSummary = array(); // RevcheckStatus, int
public $fileDetail = array(); // RevcheckDataFile
public $fileDetail = array(); // filename, RevcheckDataFile

public function __construct()
{
foreach ( RevcheckStatus::cases() as $status )
$this->$fileSummary[ $tatus ] = 0;
$this->fileSummary[ $status->value ] = 0;
}

public function addFile( string $key , RevcheckDataFile $file )
{
$this->fileSummary[ $file->status->value ]++;
$this->fileDetail[ $key ] = $file;
}

public function getTranslator( string $nick )
{
$translator = $this->translators[ $nick ] ?? null;
if ( $translator == null )
{
$translator = new RevcheckDataTranslator();
$translator->nick = $nick;
$this->translators[ $nick ] = $translator;
}
return $translator;
}
}

Expand All @@ -48,10 +66,11 @@ class RevcheckDataTranslator
public string $name;
public string $email;
public string $nick;
public string $vcs;

public int $filesUpdate;
public int $filesOld;
public int $filesWip;
public int $filesUpdate = 0;
public int $filesOld = 0;
public int $filesWip = 0;
}

class RevcheckDataFile
Expand All @@ -63,6 +82,6 @@ class RevcheckDataFile

public RevcheckStatus $status;

public string $lastHash; // The most recent commit hash, skipped or not
public string $diffHash; // The most recent, non [skip-revcheck] commit hash
public string $hashLast; // The most recent commit hash, skipped or not
public string $hashDiff; // The most recent, non [skip-revcheck] commit hash
}
100 changes: 82 additions & 18 deletions scripts/translation/lib/RevcheckRun.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ class RevcheckRun
public RevcheckFileList $sourceFiles;
public RevcheckFileList $targetFiles;

// Separated lists
public array $filesOk = [];
public array $filesOld = [];
public array $filesRevtagProblem = [];
public array $filesUntranslated = [];
public array $filesNotInEn = [];
public array $filesWip = [];

public array $qaList = [];
public RevcheckData $revData;

function __construct( string $sourceDir , string $targetDir , bool $writeResults = true )
{
Expand All @@ -54,14 +55,20 @@ function __construct( string $sourceDir , string $targetDir , bool $writeResults
// match and mix
$this->calculateStatus();

// fs output
if ( $writeResults )
{
QaFileInfo::cacheSave( $this->qaList );
$this->saveRevcheckData();
}
}

private function calculateStatus()
{
$this->revData = new RevcheckData;

// All status are marked in source files,
// except notinen, that are marked on target.
// except NotInEnTree, that are marked on target.

foreach( $this->sourceFiles->iterator() as $source )
{
Expand All @@ -73,6 +80,7 @@ private function calculateStatus()
{
$source->status = RevcheckStatus::Untranslated;
$this->filesUntranslated[] = $source;
$this->addData( $source , null );
continue;
}

Expand All @@ -82,49 +90,51 @@ private function calculateStatus()
{
$source->status = RevcheckStatus::RevTagProblem;
$this->filesRevtagProblem[] = $source;
$this->addData( $source , null );
continue;
}

// Translation compares ok from multiple hashs. The head hash or the last non-skiped hash.
// Previous code compares uptodate on multiple hashs. The last hash or the last non-skipped hash.
// See https://github.com/php/doc-base/blob/090ff07aa03c3e4ad7320a4ace9ffb6d5ede722f/scripts/revcheck.php#L374
// and https://github.com/php/doc-base/blob/090ff07aa03c3e4ad7320a4ace9ffb6d5ede722f/scripts/revcheck.php#L392 .

$sourceHash = $source->head;
$sourceHsh1 = $source->head;
$sourceHsh2 = $source->diff;
$targetHash = $target->revtag->revision;

if ( $targetHash == $source->diff )
$sourceHash = $source->diff;

$daysOld = ( strtotime( "now" ) - $source->date ) / 86400;
$daysOld = (int)$daysOld;

$qaInfo = new QaFileInfo( $sourceHash , $targetHash , $this->sourceDir , $this->targetDir , $source->file , $daysOld );
$qaInfo = new QaFileInfo( $sourceHsh1 , $targetHash , $this->sourceDir , $this->targetDir , $source->file , $daysOld );
$this->qaList[ $source->file ] = $qaInfo;

// TranslatedOk

if ( $target->revtag->status == "ready" && $sourceHash == $targetHash )
if ( $target->revtag->status == "ready" && ( $sourceHsh1 == $targetHash || $sourceHsh2 == $targetHash ) )
{
$source->status = RevcheckStatus::TranslatedOk;
$this->filesOk[] = $source;
$this->addData( $source , $target->revtag );
continue;
}

GitDiffParser::parseNumstatInto( $this->sourceDir , $source );

// TranslatedOld
// TranslatedWip

if ( $target->revtag->status != "ready" )
GitDiffParser::parseNumstatInto( $this->sourceDir , $source );

if ( $target->revtag->status == "ready" )
{
$source->status = RevcheckStatus::TranslatedOld;
$this->filesOld[] = $source;
$this->addData( $source , $target->revtag );
}
else
{
$source->status = RevcheckStatus::TranslatedWip;
$this->filesWip[] = $source;
continue;
$this->addData( $source , $target->revtag );
}

// TranslatedOld

$source->status = RevcheckStatus::TranslatedOld;
$this->filesOld[] = $source;
}

// NotInEnTree
Expand All @@ -136,7 +146,61 @@ private function calculateStatus()
{
$target->status = RevcheckStatus::NotInEnTree;
$this->filesNotInEn[] = $target;
$this->addData( $target );
}
}
}

private function addData( RevcheckFileInfo $info , RevtagInfo|null $revtag = null ) : void
{
$file = new RevcheckDataFile;

$file->path = dirname( $info->file );
$file->name = basename( $info->file );
$file->size = $info->size;
$file->days = floor( ( time() - $info->date ) / 86400 );
$file->status = $info->status;
$file->hashLast = $info->head;
$file->hashDiff = $info->diff;

$this->revData->addFile( $info->file , $file );

if ( $revtag != null )
{
$translator = $this->revData->getTranslator( $revtag->maintainer );

switch( $info->status )
{
case RevcheckStatus::TranslatedOk:
$translator->filesUpdate++;
break;
case RevcheckStatus::TranslatedOld:
$translator->filesOld++;
break;
default:
$translator->filesWip++;
break;
}
}
}

private function parseTranslationXml() : void
{
$xml = XmlUtil::loadFile( $this->targetDir . '/translation.xml' );
$persons = $xml->getElementsByTagName( 'person' );

foreach( $persons as $person )
{
$nick = $person->getAttribute( 'nick' );
$translator = $this->revData->getTranslator( $nick );
$translator->name = $person->getAttribute( 'name' );
$translator->email = $person->getAttribute( 'email' );
$translator->vcs = $person->getAttribute( 'vcs' ) ?? "";
}
}

private function saveRevcheckData()
{
$this->parseTranslationXml();
}
}
2 changes: 1 addition & 1 deletion scripts/translation/lib/all.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
require_once __DIR__ . '/OutputIgnoreArgv.php';
require_once __DIR__ . '/OutputIgnoreBuffer.php';
require_once __DIR__ . '/QaFileInfo.php';
require_once __DIR__ . '/RevcheckData.php';
require_once __DIR__ . '/RevcheckFileInfo.php';
require_once __DIR__ . '/RevcheckFileList.php';
require_once __DIR__ . '/RevcheckIgnore.php';
require_once __DIR__ . '/RevcheckRun.php';
require_once __DIR__ . '/RevcheckData.php';
require_once __DIR__ . '/RevtagParser.php';
require_once __DIR__ . '/XmlUtil.php';