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( protected function shouldSendMail(
PhabricatorLiskDAO $object, PhabricatorLiskDAO $object,
array $xactions) { 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); return $this->isCommitMostlyImported($object);
} }
@@ -803,7 +811,7 @@ final class PhabricatorAuditEditor
protected function shouldPublishFeedStory( protected function shouldPublishFeedStory(
PhabricatorLiskDAO $object, PhabricatorLiskDAO $object,
array $xactions) { array $xactions) {
return $this->isCommitMostlyImported($object); return $this->shouldSendMail($object, $xactions);
} }
protected function shouldApplyHeraldRules( protected function shouldApplyHeraldRules(

View File

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

View File

@@ -17,7 +17,9 @@ abstract class PhabricatorRepositoryCommitMessageParserWorker
$data = new PhabricatorRepositoryCommitData(); $data = new PhabricatorRepositoryCommitData();
} }
$data->setCommitID($commit->getID()); $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('authorName', $ref->getAuthorName());
$data->setCommitDetail('authorEmail', $ref->getAuthorEmail()); $data->setCommitDetail('authorEmail', $ref->getAuthorEmail());