1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 06:20:56 +01:00

Fix the feed line items for autodetect paste languages

Summary:
Fixes T11555. Previously changing the extension of a paste wouldn't change the syntax highlight language. Now it does.
Also, feed items involving autodetect weren't rendering in a readable way.

Test Plan: Created a paste named `paste.php` and let it autodetect language. Then edited the paste to be named paste.rainbow. It should now be highlighted in raiinnboow

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley, yelirekim

Maniphest Tasks: T11555

Differential Revision: https://secure.phabricator.com/D16474
This commit is contained in:
Josh Cox 2016-08-29 22:00:27 -04:00
parent 5504f37eb2
commit f5537fdff6
2 changed files with 14 additions and 4 deletions

View file

@ -173,6 +173,7 @@ final class PhabricatorPasteQuery
'P'.$paste->getID(), 'P'.$paste->getID(),
$paste->getFilePHID(), $paste->getFilePHID(),
$paste->getLanguage(), $paste->getLanguage(),
PhabricatorHash::digestForIndex($paste->getTitle()),
)); ));
} }
@ -184,6 +185,7 @@ final class PhabricatorPasteQuery
$paste->getFilePHID(), $paste->getFilePHID(),
$paste->getLanguage(), $paste->getLanguage(),
'snippet', 'snippet',
PhabricatorHash::digestForIndex($paste->getTitle()),
)); ));
} }

View file

@ -13,12 +13,20 @@ final class PhabricatorPasteLanguageTransaction
$object->setLanguage($value); $object->setLanguage($value);
} }
private function renderLanguageValue($value) {
if (!strlen($value)) {
return $this->renderValue(pht('autodetect'));
} else {
return $this->renderValue($value);
}
}
public function getTitle() { public function getTitle() {
return pht( return pht(
"%s updated the paste's language from %s to %s.", "%s updated the paste's language from %s to %s.",
$this->renderAuthor(), $this->renderAuthor(),
$this->renderOldValue(), $this->renderLanguageValue($this->getOldValue()),
$this->renderNewValue()); $this->renderLanguageValue($this->getNewValue()));
} }
public function getTitleForFeed() { public function getTitleForFeed() {
@ -26,8 +34,8 @@ final class PhabricatorPasteLanguageTransaction
'%s updated the language for %s from %s to %s.', '%s updated the language for %s from %s to %s.',
$this->renderAuthor(), $this->renderAuthor(),
$this->renderObject(), $this->renderObject(),
$this->renderOldValue(), $this->renderLanguageValue($this->getOldValue()),
$this->renderNewValue()); $this->renderLanguageValue($this->getNewValue()));
} }
} }