1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 00:42:41 +01:00

Repositories - don't send emails or publish feed stories about commits from importing repositories

Summary: ...also truncate authorName to 255 so that we don't get database errors. Ref T6350.

Test Plan: see T6350 - mostly doing it live - but I did sanity check and commit something and it worked!

Reviewers: epriestley, chad

Reviewed By: chad

Subscribers: Korvin, epriestley

Maniphest Tasks: T6350

Differential Revision: https://secure.phabricator.com/D10734
This commit is contained in:
Bob Trahan 2014-10-21 10:05:45 -07:00
parent d248bc47cf
commit 3bf770cb30
3 changed files with 17 additions and 4 deletions

View file

@ -522,6 +522,14 @@ final class PhabricatorAuditEditor
protected function shouldSendMail(
PhabricatorLiskDAO $object,
array $xactions) {
// not every code path loads the repository so tread carefully
if ($object->getRepository($assert_attached = false)) {
$repository = $object->getRepository();
if ($repository->isImporting()) {
return false;
}
}
return $this->isCommitMostlyImported($object);
}
@ -803,7 +811,7 @@ final class PhabricatorAuditEditor
protected function shouldPublishFeedStory(
PhabricatorLiskDAO $object,
array $xactions) {
return $this->isCommitMostlyImported($object);
return $this->shouldSendMail($object, $xactions);
}
protected function shouldApplyHeraldRules(

View file

@ -40,8 +40,11 @@ final class PhabricatorRepositoryCommit
return $this;
}
public function getRepository() {
return $this->assertAttached($this->repository);
public function getRepository($assert_attached = true) {
if ($assert_attached) {
return $this->assertAttached($this->repository);
}
return $this->repository;
}
public function isPartiallyImported($mask) {

View file

@ -17,7 +17,9 @@ abstract class PhabricatorRepositoryCommitMessageParserWorker
$data = new PhabricatorRepositoryCommitData();
}
$data->setCommitID($commit->getID());
$data->setAuthorName((string)$author);
$data->setAuthorName(id(new PhutilUTF8StringTruncator())
->setMaximumCodepoints(255)
->truncateString((string)$author));
$data->setCommitDetail('authorName', $ref->getAuthorName());
$data->setCommitDetail('authorEmail', $ref->getAuthorEmail());