Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only checks for [skip-revcheck] at start of commit messages #181

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
86 changes: 4 additions & 82 deletions scripts/translation/lib/GitLogParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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();
}

Expand Down
6 changes: 5 additions & 1 deletion scripts/translation/lib/RevcheckRun.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
1 change: 0 additions & 1 deletion scripts/translation/lib/all.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
149 changes: 0 additions & 149 deletions scripts/translation/lib/backport.php

This file was deleted.

Loading