diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 65187fe2a0..926a6a2d33 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -68,6 +68,7 @@ phutil_register_library_map(array( 'ConduitAPI_differential_createrevision_Method' => 'applications/conduit/method/differential/createrevision', 'ConduitAPI_differential_find_Method' => 'applications/conduit/method/differential/find', 'ConduitAPI_differential_getcommitmessage_Method' => 'applications/conduit/method/differential/getcommitmessage', + 'ConduitAPI_differential_markcommitted_Method' => 'applications/conduit/method/differential/markcommitted', 'ConduitAPI_differential_parsecommitmessage_Method' => 'applications/conduit/method/differential/parsecommitmessage', 'ConduitAPI_differential_setdiffproperty_Method' => 'applications/conduit/method/differential/setdiffproperty', 'ConduitAPI_differential_updaterevision_Method' => 'applications/conduit/method/differential/updaterevision', @@ -296,6 +297,7 @@ phutil_register_library_map(array( 'ConduitAPI_differential_createrevision_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_find_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_getcommitmessage_Method' => 'ConduitAPIMethod', + 'ConduitAPI_differential_markcommitted_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_parsecommitmessage_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_setdiffproperty_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_updaterevision_Method' => 'ConduitAPIMethod', diff --git a/src/applications/conduit/method/differential/markcommitted/ConduitAPI_differential_markcommitted_Method.php b/src/applications/conduit/method/differential/markcommitted/ConduitAPI_differential_markcommitted_Method.php new file mode 100644 index 0000000000..ec8858c28a --- /dev/null +++ b/src/applications/conduit/method/differential/markcommitted/ConduitAPI_differential_markcommitted_Method.php @@ -0,0 +1,74 @@ + 'required revision_id', + ); + } + + public function defineReturnType() { + return 'void'; + } + + public function defineErrorTypes() { + return array( + 'ERR_NOT_FOUND' => 'Revision was not found.', + ); + } + + protected function execute(ConduitAPIRequest $request) { + $id = $request->getValue('revision_id'); + + $revision = id(new DifferentialRevision())->load($id); + if (!$revision) { + throw new ConduitException('ERR_NOT_FOUND'); + } + + if ($revision->getStatus() == DifferentialRevisionStatus::COMMITTED) { + // This can occur if someone runs 'mark-committed' and hits a race, or + // they have a remote hook installed but don't have the + // 'remote_hook_installed' flag set, or similar. In any case, just treat + // it as a no-op rather than adding another "X committed this revision" + // message to the revision comments. + return; + } + + $revision->loadRelationships(); + + $editor = new DifferentialCommentEditor( + $revision, + $revision->getAuthorPHID(), + DifferentialAction::ACTION_COMMIT, + $inline_comments = array()); + $editor->save(); + + $revision->setStatus(DifferentialRevisionStatus::COMMITTED); + $revision->setDateCommitted(time()); + $revision->save(); + + return; + } + +} diff --git a/src/applications/conduit/method/differential/markcommitted/__init__.php b/src/applications/conduit/method/differential/markcommitted/__init__.php new file mode 100644 index 0000000000..7dcc2ff73b --- /dev/null +++ b/src/applications/conduit/method/differential/markcommitted/__init__.php @@ -0,0 +1,19 @@ +