mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-22 19:49:02 +01:00
Display shield for generated binary files
Test Plan: Displayed diff with generated images. Should hide [[ https://secure.phabricator.com/D3579?vs=on&id=7076&whitespace=show-all#bfb5f5e5 | webroot/rsrc/image/autosprite.png ]] after deploy. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D3585
This commit is contained in:
parent
3211238a95
commit
377a29644f
1 changed files with 33 additions and 26 deletions
|
@ -575,30 +575,7 @@ final class DifferentialChangesetParser {
|
||||||
}
|
}
|
||||||
$new_corpus_block = implode("\n", $new_corpus);
|
$new_corpus_block = implode("\n", $new_corpus);
|
||||||
|
|
||||||
$generated_guess = (strpos($new_corpus_block, '@'.'generated') !== false);
|
$this->markGenerated($new_corpus_block);
|
||||||
|
|
||||||
if (!$generated_guess) {
|
|
||||||
$config_key = 'differential.generated-paths';
|
|
||||||
$generated_path_regexps = PhabricatorEnv::getEnvConfig($config_key);
|
|
||||||
foreach ($generated_path_regexps as $regexp) {
|
|
||||||
if (preg_match($regexp, $this->changeset->getFilename())) {
|
|
||||||
$generated_guess = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$event = new PhabricatorEvent(
|
|
||||||
PhabricatorEventType::TYPE_DIFFERENTIAL_WILLMARKGENERATED,
|
|
||||||
array(
|
|
||||||
'corpus' => $new_corpus_block,
|
|
||||||
'is_generated' => $generated_guess
|
|
||||||
)
|
|
||||||
);
|
|
||||||
PhutilEventEngine::dispatchEvent($event);
|
|
||||||
|
|
||||||
$generated = $event->getValue('is_generated');
|
|
||||||
$this->specialAttributes[self::ATTR_GENERATED] = $generated;
|
|
||||||
|
|
||||||
if ($this->isTopLevel && !$this->comments &&
|
if ($this->isTopLevel && !$this->comments &&
|
||||||
($this->isGenerated() || $this->isUnchanged() || $this->isDeleted())) {
|
($this->isGenerated() || $this->isUnchanged() || $this->isDeleted())) {
|
||||||
|
@ -770,6 +747,33 @@ final class DifferentialChangesetParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function markGenerated($new_corpus_block = '') {
|
||||||
|
$generated_guess = (strpos($new_corpus_block, '@'.'generated') !== false);
|
||||||
|
|
||||||
|
if (!$generated_guess) {
|
||||||
|
$config_key = 'differential.generated-paths';
|
||||||
|
$generated_path_regexps = PhabricatorEnv::getEnvConfig($config_key);
|
||||||
|
foreach ($generated_path_regexps as $regexp) {
|
||||||
|
if (preg_match($regexp, $this->changeset->getFilename())) {
|
||||||
|
$generated_guess = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$event = new PhabricatorEvent(
|
||||||
|
PhabricatorEventType::TYPE_DIFFERENTIAL_WILLMARKGENERATED,
|
||||||
|
array(
|
||||||
|
'corpus' => $new_corpus_block,
|
||||||
|
'is_generated' => $generated_guess,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
PhutilEventEngine::dispatchEvent($event);
|
||||||
|
|
||||||
|
$generated = $event->getValue('is_generated');
|
||||||
|
$this->specialAttributes[self::ATTR_GENERATED] = $generated;
|
||||||
|
}
|
||||||
|
|
||||||
public function isGenerated() {
|
public function isGenerated() {
|
||||||
return idx($this->specialAttributes, self::ATTR_GENERATED, false);
|
return idx($this->specialAttributes, self::ATTR_GENERATED, false);
|
||||||
}
|
}
|
||||||
|
@ -841,8 +845,11 @@ final class DifferentialChangesetParser {
|
||||||
|
|
||||||
$changeset = $this->changeset;
|
$changeset = $this->changeset;
|
||||||
|
|
||||||
if ($changeset->getFileType() == DifferentialChangeType::FILE_TEXT ||
|
if ($changeset->getFileType() != DifferentialChangeType::FILE_TEXT &&
|
||||||
$changeset->getFileType() == DifferentialChangeType::FILE_SYMLINK) {
|
$changeset->getFileType() != DifferentialChangeType::FILE_SYMLINK) {
|
||||||
|
$this->markGenerated();
|
||||||
|
|
||||||
|
} else {
|
||||||
if ($skip_cache || !$this->loadCache()) {
|
if ($skip_cache || !$this->loadCache()) {
|
||||||
|
|
||||||
$ignore_all = (($whitespace_mode == self::WHITESPACE_IGNORE_ALL) ||
|
$ignore_all = (($whitespace_mode == self::WHITESPACE_IGNORE_ALL) ||
|
||||||
|
|
Loading…
Add table
Reference in a new issue