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

This commit is contained in:
Nilgün Belma Bugüner
2021-09-02 02:55:57 +03:00
parent c92fd4b435
commit daf0c803c2
2 changed files with 15 additions and 4 deletions

View File

@ -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 $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 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 c.name = a.name AND b.id = a.id AND b.id = c.id
AND (a.syncStatus = 'TranslatedOld' AND (a.syncStatus = 'TranslatedOld'
OR a.syncStatus = 'TranslatedWip')"; OR a.syncStatus = 'TranslatedWip')";
@ -216,7 +216,7 @@ function get_translators($idx, $lang)
function get_stats($idx, $lang, $status) { function get_stats($idx, $lang, $status) {
$sql = "SELECT COUNT(a.name) AS total, SUM(b.size) AS size $sql = "SELECT COUNT(a.name) AS total, SUM(b.size) AS size
FROM translated a, enfiles b 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') { if ($status == 'wip') {
$sql .= "a.syncStatus = 'TranslatedWip'"; $sql .= "a.syncStatus = 'TranslatedWip'";
} elseif ($status == 'notrans') { } elseif ($status == 'notrans') {

View File

@ -95,6 +95,7 @@ CREATE TABLE enfiles (
name TEXT, name TEXT,
revision TEXT, revision TEXT,
size INT, size INT,
skip INT,
UNIQUE(id, name) UNIQUE(id, name)
); );
@ -432,11 +433,13 @@ function captureGitValues( & $output )
$hash = null; $hash = null;
$date = null; $date = null;
$utct = new DateTimeZone( "UTC" ); $utct = new DateTimeZone( "UTC" );
$skipThisCommit = 0;
while ( ( $line = fgets( $fp ) ) !== false ) while ( ( $line = fgets( $fp ) ) !== false )
{ {
if ( substr( $line , 0 , 7 ) == "commit " ) if ( substr( $line , 0 , 7 ) == "commit " )
{ {
$hash = trim( substr( $line , 7 ) ); $hash = trim( substr( $line , 7 ) );
$skipThisCommit = 0;
continue; continue;
} }
if ( strpos( $line , 'Date:' ) === 0 ) if ( strpos( $line , 'Date:' ) === 0 )
@ -447,13 +450,20 @@ function captureGitValues( & $output )
if ( trim( $line ) == "" ) if ( trim( $line ) == "" )
continue; continue;
if ( substr( $line , 0 , 4 ) == ' ' ) if ( substr( $line , 0 , 4 ) == ' ' )
continue; {
if ( stristr( $line, '[skip-revcheck]' ) !== false )
{
$skipThisCommit = 1;
}
continue;
}
if ( strpos( $line , ': ' ) > 0 ) if ( strpos( $line , ': ' ) > 0 )
continue; continue;
$filename = trim( $line ); $filename = trim( $line );
if ( isset( $output[$filename] ) ) if ( isset( $output[$filename] ) )
continue; continue;
$output[$filename]['hash'] = $hash; $output[$filename]['hash'] = $hash;
$output[$filename]['skip'] = $skipThisCommit;
} }
pclose( $fp ); pclose( $fp );
chdir( $cwd ); chdir( $cwd );
@ -484,11 +494,12 @@ foreach( $enFiles as $key => $en )
if ( isset( $gitData[ $filename ] ) ) if ( isset( $gitData[ $filename ] ) )
{ {
$en->hash = $gitData[ $filename ]['hash']; $en->hash = $gitData[ $filename ]['hash'];
$en->skip = $gitData[ $filename ]['skip'];
} }
else else
print "Warn: No hash for en/$filename\n"; 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 ) foreach( $LANGS as $lang )
{ {