diff --git a/scripts/translation/lib/GitLogParser.php b/scripts/translation/lib/GitLogParser.php index 0ad45b8ac..c721a75f4 100644 --- a/scripts/translation/lib/GitLogParser.php +++ b/scripts/translation/lib/GitLogParser.php @@ -21,75 +21,6 @@ class GitLogParser { - static function parseInto( string $lang , RevcheckFileList & $list ) - { - $cwd = getcwd(); - chdir( $lang ); - $fp = popen( "git log --name-only" , "r" ); - chdir( $cwd ); - - $hash = ""; - $date = ""; - $skip = false; - $mcnt = 0; - - while ( ( $line = fgets( $fp ) ) !== false ) - { - // new commit block - if ( substr( $line , 0 , 7 ) == "commit " ) - { - $hash = trim( substr( $line , 7 ) ); - $date = ""; - $skip = false; - $mcnt = 0; - continue; - } - // datetime of commit - if ( strpos( $line , 'Date:' ) === 0 ) - { - $line = trim( substr( $line , 5 ) ); - $date = strtotime( $line ); - continue; - } - // empty lines - if ( trim( $line ) == "" ) - continue; - // commit message - if ( str_starts_with( $line , ' ' ) ) - { - if ( LOOSE_SKIP_REVCHECK ) // See below, and https://github.com/php/doc-base/pull/132 - { - // commits with [skip-revcheck] anywhere commit message flags skip - if ( str_contains( $line, '[skip-revcheck]' ) ) - $skip = true; - } - else - { - $mcnt++; - // [skip-revcheck] at start of first line of commit message flags a skip - if ( $mcnt == 1 && str_starts_with( trim( $line ) , '[skip-revcheck]' ) ) - $skip = true; - } - continue; - } - // other headers - if ( strpos( $line , ': ' ) > 0 ) - continue; - - // otherwise, a filename - $filename = trim( $line ); - $info = $list->get( $filename ); - - // untracked file (deleted, renamed) - if ( $info == null ) - continue; - - $info->addGitLogData( $hash , $date , $skip ); - } - - pclose( $fp ); - } - static function parseDir( string $gdir , RevcheckFileList $list ) { $gdir = escapeshellarg( $gdir ); @@ -142,19 +73,10 @@ static function parseDir( string $gdir , RevcheckFileList $list ) while ( $proc->live && str_starts_with( $proc->line , ' ' ) ) { - if ( LOOSE_SKIP_REVCHECK ) // https://github.com/php/doc-base/pull/132 - { - // Messages that contains [skip-revcheck] flags entire commit as ignored. - if ( str_contains( $proc->line , '[skip-revcheck]' ) ) - $skip = true; - } - else - { - // Messages that start with [skip-revcheck] flags entire commit as ignored. - $lcnt++; - if ( $lcnt == 1 && str_starts_with( trim( $line ) , '[skip-revcheck]' ) ) - $skip = true; - } + // Messages that start with [skip-revcheck] flags entire commit as ignored. + $lcnt++; + if ( $lcnt == 1 && str_starts_with( trim( $proc->line ) , '[skip-revcheck]' ) ) + $skip = true; $proc->next(); } diff --git a/scripts/translation/lib/RevcheckRun.php b/scripts/translation/lib/RevcheckRun.php index 59e412be4..5159281e2 100644 --- a/scripts/translation/lib/RevcheckRun.php +++ b/scripts/translation/lib/RevcheckRun.php @@ -208,7 +208,11 @@ private function parseTranslationXml() : void $this->revData->lang = $this->targetDir; $this->revData->date = date("r"); - $dom = XmlUtil::loadFile( $this->targetDir . '/translation.xml' ); + $transfile = $this->targetDir . '/translation.xml'; + if ( ! file_exists( $transfile ) ) + throw new \Exception("Missing translation.xml file." ); + + $dom = XmlUtil::loadFile( $transfile ); $tag = $dom->getElementsByTagName( 'intro' )[0] ?? null; if ( $tag == null ) diff --git a/scripts/translation/lib/all.php b/scripts/translation/lib/all.php index 843c046bb..18c44b7d4 100644 --- a/scripts/translation/lib/all.php +++ b/scripts/translation/lib/all.php @@ -21,7 +21,6 @@ ini_set( 'display_startup_errors' , 1 ); error_reporting( E_ALL ); -require_once __DIR__ . '/backport.php'; require_once __DIR__ . '/CacheFile.php'; require_once __DIR__ . '/CacheUtil.php'; require_once __DIR__ . '/GitLogParser.php'; diff --git a/scripts/translation/lib/backport.php b/scripts/translation/lib/backport.php deleted file mode 100644 index 169c781f4..000000000 --- a/scripts/translation/lib/backport.php +++ /dev/null @@ -1,149 +0,0 @@ -window is the base-2 log of the compression loopback window size. -Higher values (up to 15 -- 32768 bytes) yield better compression at a cost of memory, -while lower values (down to 9 -- 512 bytes) yield worse compression in a smaller memory footprint. -- Default window size is currently 15. -+ Default window size is currently 15. - -memory is a scale indicating how much work memory should be allocated. -Valid values range from 1 (minimal allocation) to 9 (maximum allocation). This memory allocation -diff --git a/install/fpm/configuration.xml b/install/fpm/configuration.xml -index 9baaf43d6f..a34700ef97 100644 ---- a/install/fpm/configuration.xml -+++ b/install/fpm/configuration.xml -@@ -805,109 +805,109 @@ - - - -- %C -+ %C - -%CPU - - -``` - -This commit must be tracked in translations? In other words, this commit -should mark the various files changed as outdated in translations? - -The current implementation on doc-base/revcheck.php would *ignore* this -commit, *not* marking these files as outdated on translations. - -This is because the code searches for '[skip-revcheck]' in any position [1], -and in any lile [2] of commit messages. - -[1] https://github.com/php/doc-base/blob/84532c32eb7b6d694df6cbee3622cec624709654/scripts/revcheck.php#L304 -[2] https://github.com/php/doc-base/blob/84532c32eb7b6d694df6cbee3622cec624709654/scripts/revcheck.php#L302 - -The problem, here, is that this commit on doc-en was squashed, and by so, all -individual commit messages are concatenated in one commit message. - -``` -Remove constant tag from literal values (#3251) -* Remove constant tag from literal values -* [skip-revcheck] Fix whitespace -``` - -The solution proposed is to check for '[skip-revcheck]' mark only at the -starting of the first line on commit messages, so future squashed commits -do not cause file modifications being untracked on translations. - -After code deduplication, open an issue to consider having an -*strick* [skip-revcheck] mode, avoids the issue above, -by removing any mentions of LOOSE_SKIP_REVCHECK constante. */ - -assert( LOOSE_SKIP_REVCHECK || ! LOOSE_SKIP_REVCHECK ); - -/* # FIXED_SKIP_REVCHECK - -Consider the output of: git log --oneline -- reference/ds/ds.deque.xml -``` -4d17 [skip-revcheck] Convert class markup to be compatible with DocBook 5.2 -6cec [skip-revcheck] Normalize &Constants; and &Methods; usage (#2703) -b2a2 These should include the namesapce -120c Document ArrayAccess in PHP-DS -``` - -The last two commits, each one, will mark all their included files as old -in translations, as the commit message does not contain '[skip-revcheck]'. - -The commit 6cec, marked [skip-revcheck], will not mark any file as outdated. - -The commit 4d17, marked [skip-revcheck], will mark all its files as outdated, -needing to be updated to 6cec. - -See the difference in behaviour between two individual commits marked -'[skip-revcheck]'? -That 6cec commit is also marked '[skip-revcheck]' is -incidental. This discrepancy occurs in any sequence of commits -marked '[skip-revcheck]'. - -When the revcheck code, as now, detects that the topmost commit hash contains an -'[skip-revcheck]', it ignores this topmost commit hash, and then selects the fixed -'-2' commit hash as a base of comparison, when the file is calculated as old. - -See: -- Oldness test: https://github.com/php/doc-base/blob/84532c32eb7b6d694df6cbee3622cec624709654/scripts/revcheck.php#L362 -- Topmost skip: https://github.com/php/doc-base/blob/84532c32eb7b6d694df6cbee3622cec624709654/scripts/revcheck.php#L380 -- Hash -2:      https://github.com/php/doc-base/blob/84532c32eb7b6d694df6cbee3622cec624709654/scripts/revcheck.php#L384 - -The output of -2 test, as now, is: -``` -4d17b7b4947e7819ff5036715dd706be87ae4def -6ceccac7860f382f16ac1407baf54f656e85ca0b -``` - -The code linked above splits the results on the new line, and compares the revtag -hash against the second line, 6cec in this case. But 6cec is itself marked as an -'[skip-revcheck]'. So an [skip-revcheck] is bumping all its file hashes into -another [skip-revcheck] commit hash... - -The proposed solution is to removing the use of the fixed -2 topmost hash when -the topmost hash is marked [skip-revcheck] into ignoring any topmost commit -hash marked [skip-revcheck], and thus selecting as an alternative comparison -hash the first topmost hash not marked as [skip-revcheck]. - -In this case, b2a2. - -So any future sequence of [skip-revcheck] commits does not cause the bumping -of hashes in all translations in the presence of a sequence of [skip-revcheck] -commits. - -After code deduplication, open an issue to consider having an -multi skipping [skip-revcheck] mode, avoids the issue above, -by removing any mentions of FIXED_SKIP_REVCHECK constante. */ - -assert( FIXED_SKIP_REVCHECK || ! FIXED_SKIP_REVCHECK ); \ No newline at end of file