diff --git a/include/lib_revcheck.inc.php b/include/lib_revcheck.inc.php index 02f34d8..9a08fa9 100644 --- a/include/lib_revcheck.inc.php +++ b/include/lib_revcheck.inc.php @@ -48,7 +48,7 @@ function get_dirs($idx, $lang) { // return an array with the outdated files; can be optionally filtered by user or dir 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, a.additions, a.deletions, 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' AND c.name = a.name AND b.id = a.id AND b.id = c.id @@ -73,7 +73,9 @@ function get_outdated_files($idx, $lang, $filter = null, $value = null) 'trans_rev' => $r['trans_rev'], 'status' => $r['status'], 'maintainer' => $r['maintainer'], - 'name' => $r['dir']); + 'name' => $r['dir'], + 'additions' => $r['additions'], + 'deletions' => $r['deletions']); } return $tmp; @@ -252,6 +254,7 @@ function showdiff () $arg_f = escapeshellarg($gitfile); $file = `git diff {$arg_h} -- {$arg_f}`; chdir( $cwd ); + if (!$file) return; $raw = htmlspecialchars( $file, ENT_XML1, 'UTF-8' ); $lines = explode ( "\n" , $raw ); echo "
"; diff --git a/scripts/rev.php b/scripts/rev.php index 4a685af..662d7f8 100644 --- a/scripts/rev.php +++ b/scripts/rev.php @@ -77,6 +77,8 @@ maintainer TEXT, status TEXT, syncStatus TEXT, + additions INT, + deletions INT, UNIQUE(lang, id, name) ); @@ -514,10 +516,21 @@ function captureGitValues( & $output ) $SQL_BUFF .= "INSERT INTO Untranslated VALUES ($id, '$lang', '$en->name', $size);\n"; } else { + $additions = $deletions = 0; if ( $en->hash == $trFile->hash ){ $trFile->syncStatus = FileStatusEnum::TranslatedOk; - } elseif ( strlen( $trFile->hash ) == 40 ) { + } elseif ( $trFile->hash != null and strlen( $trFile->hash ) == 40 ) { $trFile->syncStatus = FileStatusEnum::TranslatedOld; + + $cwd = getcwd(); + chdir( $DOCS . 'en' ); + $subject = `git diff --numstat $trFile->hash -- {$filename}`; + chdir( $cwd ); + if ( $subject ) { + preg_match('/(\d+)\s+(\d+)/', $subject, $matches); + if ($matches) + [, $additions, $deletions] = $matches; + } } if ( $trFile->completion != null && $trFile->completion != "ready" ) $trFile->syncStatus = FileStatusEnum::TranslatedWip; @@ -531,7 +544,7 @@ function captureGitValues( & $output ) } $SQL_BUFF .= "INSERT INTO translated VALUES ($id, '$lang', '$en->name', '$trFile->hash', $size, '$trFile->maintainer', - '$trFile->completion', '$trFile->syncStatus');\n"; + '$trFile->completion', '$trFile->syncStatus', $additions, $deletions);\n"; } } } diff --git a/www/revcheck.php b/www/revcheck.php index bf1de88..42774f8 100644 --- a/www/revcheck.php +++ b/www/revcheck.php @@ -327,6 +327,7 @@ + @@ -335,14 +336,14 @@ - + END_OF_MULTILINE; $last_dir = false; $prev_name = $outdated[0]['name']; foreach ($outdated as $r) { if ($r['name'] != $prev_name) { - echo ''; + echo ''; $prev_name = $r['name']; } @@ -357,9 +358,6 @@ $key = $r['file']; //plaintext -color $d1 = "?p=plain&lang={$lang}&hbp={$r['trans_rev']}&f=$key&c=on"; - // GitHub web diff -- May not work with very old commits - //$kh = hash( 'sha256' , $key ); - //"https://github.com/php/doc-en/compare/{$r['trans_rev']}..{$r['en_rev']}#diff-{$kh}"; //plaintext $d2 = "?p=plain&lang={$lang}&hbp={$r['trans_rev']}&f=$key&c=off"; @@ -369,9 +367,12 @@ $nm = "{$r['file']}[diff]"; + $ch = "+{$r['additions']}-{$r['deletions']}"; + // Write out the line for the current file (get file name shorter) - echo ''. - "". + echo '' . + "" . + "" . "" . "" . "" .
Translated fileChanges Revision Maintainer Statusen $lang
{$outdated[0]['name']}
{$outdated[0]['name']}
'.$r['name'].'
'.$r['name'].'
{$nm}
{$nm}{$ch}{$h1}{$h2} {$r['maintainer']}