mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
Survive importing Git commits with no commit message and/or no author
Summary: Ref T13538. See PHI1739. Synthetic Git commits with no author and/or no commit message currently extract `null` and then fail to parse. Ideally, we would carefully distinguish between `null` and empty string. In practice, that requires significant schema changes (these columns are non-nullable and have indexing requirements) and these cases are degenerate. These commits are challenging to build and can not normally be constructed with `git commit`. At least for now, merge the `null` cases into the empty string cases so we can survive import. Test Plan: - Constructed a commit with no author and no commit message using the approach described in T13538; pushed and parsed it. - Before: fatals during identity selection and storing the commit message (both roughly NULL inserts into non-null columns). - After: clean import. This produces a less-than-ideal UI in Diffusion, but it doesn't break anything: {F7492094} Maniphest Tasks: T13538 Differential Revision: https://secure.phabricator.com/D21266
This commit is contained in:
parent
f86d822a37
commit
0c51885cf7
1 changed files with 13 additions and 1 deletions
|
@ -62,7 +62,6 @@ abstract class PhabricatorRepositoryCommitMessageParserWorker
|
||||||
final protected function updateCommitData(DiffusionCommitRef $ref) {
|
final protected function updateCommitData(DiffusionCommitRef $ref) {
|
||||||
$commit = $this->commit;
|
$commit = $this->commit;
|
||||||
$author = $ref->getAuthor();
|
$author = $ref->getAuthor();
|
||||||
$message = $ref->getMessage();
|
|
||||||
$committer = $ref->getCommitter();
|
$committer = $ref->getCommitter();
|
||||||
$hashes = $ref->getHashes();
|
$hashes = $ref->getHashes();
|
||||||
$has_committer = (bool)strlen($committer);
|
$has_committer = (bool)strlen($committer);
|
||||||
|
@ -73,6 +72,14 @@ abstract class PhabricatorRepositoryCommitMessageParserWorker
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
->setSourcePHID($commit->getPHID());
|
->setSourcePHID($commit->getPHID());
|
||||||
|
|
||||||
|
// See T13538. It is possible to synthetically construct a Git commit with
|
||||||
|
// no author and arrive here with NULL for the author value.
|
||||||
|
|
||||||
|
// This is distinct from a commit with an empty author. Because both these
|
||||||
|
// cases are degenerate and we can't resolve NULL into an identity, cast
|
||||||
|
// NULL to the empty string and merge the flows.
|
||||||
|
$author = phutil_string_cast($author);
|
||||||
|
|
||||||
$author_identity = $identity_engine->newResolvedIdentity($author);
|
$author_identity = $identity_engine->newResolvedIdentity($author);
|
||||||
|
|
||||||
if ($has_committer) {
|
if ($has_committer) {
|
||||||
|
@ -102,6 +109,11 @@ abstract class PhabricatorRepositoryCommitMessageParserWorker
|
||||||
'authorPHID',
|
'authorPHID',
|
||||||
$author_identity->getCurrentEffectiveUserPHID());
|
$author_identity->getCurrentEffectiveUserPHID());
|
||||||
|
|
||||||
|
// See T13538. It is possible to synthetically construct a Git commit with
|
||||||
|
// no message. As above, treat this as though it is the same as the empty
|
||||||
|
// message.
|
||||||
|
$message = $ref->getMessage();
|
||||||
|
$message = phutil_string_cast($message);
|
||||||
$data->setCommitMessage($message);
|
$data->setCommitMessage($message);
|
||||||
|
|
||||||
if ($has_committer) {
|
if ($has_committer) {
|
||||||
|
|
Loading…
Reference in a new issue