mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 00:32:42 +01:00
Close the loop on Diffusion commits posting back to Differential.
This commit is contained in:
parent
ed1eead587
commit
22297b71a0
6 changed files with 73 additions and 1 deletions
6
resources/sql/patches/022.differentialcommit.sql
Normal file
6
resources/sql/patches/022.differentialcommit.sql
Normal file
|
@ -0,0 +1,6 @@
|
|||
CREATE TABLE phabricator_differential.differential_commit (
|
||||
revisionID int unsigned not null,
|
||||
commitPHID varchar(64) binary not null,
|
||||
primary key (revisionID, commitPHID),
|
||||
unique key (commitPHID)
|
||||
);
|
|
@ -65,6 +65,7 @@ class DifferentialRevisionViewController extends DifferentialController {
|
|||
$object_phids = array_merge(
|
||||
$revision->getReviewers(),
|
||||
$revision->getCCPHIDs(),
|
||||
$revision->loadCommitPHIDs(),
|
||||
array(
|
||||
$revision->getAuthorPHID(),
|
||||
$user->getPHID(),
|
||||
|
@ -250,6 +251,15 @@ class DifferentialRevisionViewController extends DifferentialController {
|
|||
$properties['Maniphest Tasks'] = implode('<br />', $links);
|
||||
}
|
||||
|
||||
$commit_phids = $revision->getCommitPHIDs();
|
||||
if ($commit_phids) {
|
||||
$links = array();
|
||||
foreach ($commit_phids as $commit_phid) {
|
||||
$links[] = $handles[$commit_phid]->renderLink();
|
||||
}
|
||||
$properties['Commits'] = implode('<br />', $links);
|
||||
}
|
||||
|
||||
return $properties;
|
||||
}
|
||||
|
||||
|
|
|
@ -197,7 +197,12 @@ class DifferentialCommentEditor {
|
|||
break;
|
||||
|
||||
case DifferentialAction::ACTION_COMMIT:
|
||||
// This is handled externally. (TODO)
|
||||
if (!$actor_is_author) {
|
||||
throw new Exception('You can not commit a revision you do not own.');
|
||||
}
|
||||
$revision
|
||||
->setStatus(DifferentialRevisionStatus::COMMITTED)
|
||||
->save();
|
||||
break;
|
||||
|
||||
case DifferentialAction::ACTION_ADDREVIEWERS:
|
||||
|
|
|
@ -36,8 +36,10 @@ class DifferentialRevision extends DifferentialDAO {
|
|||
protected $unsubscribed = array();
|
||||
|
||||
private $relationships;
|
||||
private $commits;
|
||||
|
||||
const RELATIONSHIP_TABLE = 'differential_relationship';
|
||||
const TABLE_COMMIT = 'differential_commit';
|
||||
|
||||
const RELATION_REVIEWER = 'revw';
|
||||
const RELATION_SUBSCRIBED = 'subd';
|
||||
|
@ -52,6 +54,28 @@ class DifferentialRevision extends DifferentialDAO {
|
|||
) + parent::getConfiguration();
|
||||
}
|
||||
|
||||
public function loadCommitPHIDs() {
|
||||
if (!$this->getID()) {
|
||||
return ($this->commits = array());
|
||||
}
|
||||
|
||||
$commits = queryfx_all(
|
||||
$this->establishConnection('r'),
|
||||
'SELECT commitPHID FROM %T WHERE revisionID = %d',
|
||||
self::TABLE_COMMIT,
|
||||
$this->getID());
|
||||
$commits = ipull($commits, 'commitPHID');
|
||||
|
||||
return ($this->commits = $commits);
|
||||
}
|
||||
|
||||
public function getCommitPHIDs() {
|
||||
if ($this->commits === null) {
|
||||
throw new Exception("Must load commits!");
|
||||
}
|
||||
return $this->commits;
|
||||
}
|
||||
|
||||
public function getAttachedPHIDs($type) {
|
||||
return array_keys(idx($this->attached, $type, array()));
|
||||
}
|
||||
|
|
|
@ -44,6 +44,28 @@ abstract class PhabricatorRepositoryCommitMessageParserWorker
|
|||
}
|
||||
|
||||
$data->save();
|
||||
|
||||
$revision_id = $data->getCommitDetail('differential.revisionID');
|
||||
if ($revision_id) {
|
||||
$revision = id(new DifferentialRevision())->load($revision_id);
|
||||
if ($revision) {
|
||||
|
||||
queryfx(
|
||||
$revision->establishConnection('r'),
|
||||
'INSERT IGNORE INTO %T (revisionID, commitPHID) VALUES (%d, %s)',
|
||||
DifferentialRevision::TABLE_COMMIT,
|
||||
$revision->getID(),
|
||||
$commit->getPHID());
|
||||
|
||||
if ($revision->getStatus() != DifferentialRevisionStatus::COMMITTED) {
|
||||
$editor = new DifferentialCommentEditor(
|
||||
$revision,
|
||||
$revision->getAuthorPHID(),
|
||||
DifferentialAction::ACTION_COMMIT);
|
||||
$editor->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,8 +6,13 @@
|
|||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/differential/constants/action');
|
||||
phutil_require_module('phabricator', 'applications/differential/constants/revisionstatus');
|
||||
phutil_require_module('phabricator', 'applications/differential/editor/comment');
|
||||
phutil_require_module('phabricator', 'applications/differential/storage/revision');
|
||||
phutil_require_module('phabricator', 'applications/repository/storage/commitdata');
|
||||
phutil_require_module('phabricator', 'applications/repository/worker/base');
|
||||
phutil_require_module('phabricator', 'storage/queryfx');
|
||||
|
||||
phutil_require_module('phutil', 'symbols');
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
|
Loading…
Reference in a new issue