Skip to content

Commit 8f811a3

Browse files
authored
Fix unstable add/del ignores (#238)
1 parent 45f488c commit 8f811a3

File tree

3 files changed

+18
-20
lines changed

3 files changed

+18
-20
lines changed

scripts/translation/libqa/OutputBuffer.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ class OutputBuffer
2626
private array $footer = [];
2727

2828
private OutputIgnore $ignore;
29-
private string $options;
3029

3130
public int $printCount = 0;
3231

@@ -37,7 +36,6 @@ public function __construct( string $header , string $filename , OutputIgnore $i
3736
$this->header = $header . ": " . $filename . "\n\n";
3837
$this->filename = $filename;
3938
$this->ignore = $ignore;
40-
$this->options = implode( " " , $ignore->argv->residual() );
4139
}
4240

4341
public function add( string $text )
@@ -88,15 +86,15 @@ public function print( bool $alternatePrinting = false )
8886
if ( count( $this->matter ) == 0 && count( $this->footer ) == 0 )
8987
return;
9088

89+
$this->printCount++;
90+
9191
$hashFile = hash( "crc32b" , $this->filename );
9292
$hashHead = $this->hash( false );
9393
$hashFull = $this->hash( true );
9494

9595
if ( $this->ignore->shouldIgnore( $this , $hashFile , $hashHead , $hashFull ) )
9696
return;
9797

98-
$this->printCount++;
99-
10098
print $this->header;
10199

102100
if ( $alternatePrinting )
@@ -142,7 +140,8 @@ private function printMatterAlternate() : void
142140

143141
private function hash( bool $withContents ) : string
144142
{
145-
$text = $this->header . $this->options;
143+
$text = $this->header;
144+
$text .= implode( "" , array_filter( $this->ignore->argvRest ) );
146145
if ( $withContents )
147146
$text .= implode( "" , $this->matter );
148147
$text = str_replace( " " , "" , $text );

scripts/translation/libqa/OutputIgnore.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,17 @@
2121
class OutputIgnore
2222
{
2323
private string $filename = ".qaxml.ignores";
24-
private string $argv0 = "";
2524

26-
public bool $appendIgnoreCommands = true;
2725
public ArgvParser $argv;
26+
public string $argvZero = "";
27+
public array $argvRest = [];
28+
public bool $appendIgnoreCommands = true;
2829

2930
public function __construct( ArgvParser $argv )
3031
{
3132
$this->argv = $argv;
32-
$this->argv0 = escapeshellarg( $argv->consume( position: 0 ) );
33+
$this->argvZero = escapeshellarg( $argv->consume( position: 0 ) );
34+
$this->argvRest = $this->argv->residual();
3335

3436
$item = $argv->consume( prefix: "--add-ignore=" );
3537

@@ -94,15 +96,15 @@ public function shouldIgnore( OutputBuffer $output , string $hashFile , string $
9496
$ret = true;
9597
else
9698
if ( $this->appendIgnoreCommands )
97-
$output->addFooter( " php {$this->argv0} --add-ignore=$active\n" );
99+
$output->addFooter( " php {$this->argvZero} --add-ignore=$active\n" );
98100

99101
// --del-ignore command
100102

101103
if ( $this->appendIgnoreCommands )
102104
foreach ( $marks as $mark )
103105
if ( str_starts_with( $mark , $prefix ) )
104106
if ( $mark != $active )
105-
$output->addFooter( " php {$this->argv0} --del-ignore=$mark\n" );
107+
$output->addFooter( " php {$this->argvZero} --del-ignore=$mark\n" );
106108

107109
return $ret;
108110
}

scripts/translation/qaxml-tags.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@
2929
if ( count( $tags ) == 1 && $tags[0] == "" )
3030
$tags = [];
3131

32-
if ( $detail )
33-
$ignore->appendIgnoreCommands = false;
34-
35-
$list = SyncFileList::load();
32+
$list = SyncFileList::load();
3633

3734
foreach ( $list as $file )
3835
{
@@ -44,8 +41,8 @@
4441
{
4542
// "Simple" tag contents check, by inner text
4643

47-
[ $s , $_ , $_ ] = XmlFrag::loadXmlFragmentFile( $source );
48-
[ $t , $_ , $_ ] = XmlFrag::loadXmlFragmentFile( $target );
44+
[ $s ] = XmlFrag::loadXmlFragmentFile( $source );
45+
[ $t ] = XmlFrag::loadXmlFragmentFile( $target );
4946

5047
$s = XmlFrag::listNodes( $s , XML_ELEMENT_NODE );
5148
$t = XmlFrag::listNodes( $t , XML_ELEMENT_NODE );
@@ -86,8 +83,8 @@
8683

8784
// "Complex" tag contents check, by inner XML
8885

89-
[ $s , $_ , $_ ] = XmlFrag::loadXmlFragmentFile( $source );
90-
[ $t , $_ , $_ ] = XmlFrag::loadXmlFragmentFile( $target );
86+
[ $s ] = XmlFrag::loadXmlFragmentFile( $source );
87+
[ $t ] = XmlFrag::loadXmlFragmentFile( $target );
9188

9289
$s = XmlFrag::listNodes( $s , XML_ELEMENT_NODE );
9390
$t = XmlFrag::listNodes( $t , XML_ELEMENT_NODE );
@@ -127,8 +124,8 @@
127124
{
128125
// Check tag count, not contents
129126

130-
[ $s , $_ , $_ ] = XmlFrag::loadXmlFragmentFile( $source );
131-
[ $t , $_ , $_ ] = XmlFrag::loadXmlFragmentFile( $target );
127+
[ $s ] = XmlFrag::loadXmlFragmentFile( $source );
128+
[ $t ] = XmlFrag::loadXmlFragmentFile( $target );
132129

133130
$s = XmlFrag::listNodes( $s , XML_ELEMENT_NODE );
134131
$t = XmlFrag::listNodes( $t , XML_ELEMENT_NODE );

0 commit comments

Comments
 (0)