[web-doc] master: Implement [skip-revcheck] to exclude a commit from consideration. Closes GH-21

[email protected] (Nilgün Belma Bugüner) Wed, 1 Sep 2021 23:55:34 +0000
Newsgroups php.doc.web
Message-ID <[email protected]>
Author: Nilgün Belma Bugüner (nilgun)
Date: 2021-09-02T02:55:57+03:00

Commit: https://github.com/php/web-doc/commit/daf0c803c2d82b32dadbd38cbe35eca7e549104b
Raw diff: https://github.com/php/web-doc/commit/daf0c803c2d82b32dadbd38cbe35eca7e549104b.diff

Implement [skip-revcheck] to exclude a commit from consideration. Closes GH-21

Changed paths:
  M  include/lib_revcheck.inc.php
  M  scripts/rev.php


Diff:

diff --git a/include/lib_revcheck.inc.php b/include/lib_revcheck.inc.php
index 3e31c2c..7f3854d 100644
--- a/include/lib_revcheck.inc.php
+++ b/include/lib_revcheck.inc.php
@@ -50,7 +50,7 @@ function get_outdated_files($idx, $lang, $filter = null, $value = null)
 {
     $sql = "SELECT a.status, a.name AS file, a.maintainer, c.revision AS en_rev, a.revision AS trans_rev, b.path AS dir
     FROM translated a, dirs b, enfiles c
-    WHERE a.lang = '$lang'
+    WHERE a.lang = '$lang' AND c.skip = 0
       AND c.name = a.name AND b.id = a.id AND b.id = c.id
       AND (a.syncStatus = 'TranslatedOld'
        OR  a.syncStatus = 'TranslatedWip')";
@@ -216,7 +216,7 @@ function get_translators($idx, $lang)
 function get_stats($idx, $lang, $status) {
     $sql = "SELECT COUNT(a.name) AS total, SUM(b.size) AS size
         FROM translated a, enfiles b
-        WHERE a.lang = '$lang' AND a.id = b.id AND a.name = b.name AND ";
+        WHERE a.lang = '$lang' AND a.id = b.id AND a.name = b.name AND b.skip = 0 AND ";
     if ($status == 'wip') {
          $sql .= "a.syncStatus = 'TranslatedWip'";
     } elseif ($status == 'notrans') {
diff --git a/scripts/rev.php b/scripts/rev.php
index bd4963d..94ac118 100644
--- a/scripts/rev.php
+++ b/scripts/rev.php
@@ -95,6 +95,7 @@
   name TEXT,
   revision TEXT,
   size INT,
+  skip INT,
   UNIQUE(id, name)
 );
 
@@ -432,11 +433,13 @@ function captureGitValues( & $output )
     $hash = null;
     $date = null;
     $utct = new DateTimeZone( "UTC" );
+    $skipThisCommit = 0;
     while ( ( $line = fgets( $fp ) ) !== false )
     {
         if ( substr( $line , 0 , 7 ) == "commit " )
         {
             $hash = trim( substr( $line , 7 ) );
+            $skipThisCommit = 0;
             continue;
         }
         if ( strpos( $line , 'Date:' ) === 0 )
@@ -447,13 +450,20 @@ function captureGitValues( & $output )
         if ( trim( $line ) == "" )
             continue;
         if ( substr( $line , 0 , 4 ) == '    ' )
-            continue;
+        {
+            if ( stristr( $line, '[skip-revcheck]' ) !== false )
+            {
+                 $skipThisCommit = 1;
+             }
+           continue;
+        }
         if ( strpos( $line , ': ' ) > 0 )
             continue;
         $filename = trim( $line );
         if ( isset( $output[$filename] ) )
             continue;
         $output[$filename]['hash'] = $hash;
+        $output[$filename]['skip'] = $skipThisCommit;
     }
     pclose( $fp );
     chdir( $cwd );
@@ -484,11 +494,12 @@ function captureGitValues( & $output )
     if ( isset( $gitData[ $filename ] ) )
     {
         $en->hash = $gitData[ $filename ]['hash'];
+        $en->skip = $gitData[ $filename ]['skip'];
     }
     else
         print "Warn: No hash for en/$filename\n";
 
-    $SQL_BUFF .= "INSERT INTO enfiles VALUES ($id, '$en->name', '$en->hash', $size);\n";
+    $SQL_BUFF .= "INSERT INTO enfiles VALUES ($id, '$en->name', '$en->hash', $size, '$en->skip');\n";
 
     foreach( $LANGS as $lang )
     {