[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class ReleephWorkGetBranchCommitMessageConduitAPIMethod 4 extends ReleephConduitAPIMethod { 5 6 public function getAPIMethodName() { 7 return 'releephwork.getbranchcommitmessage'; 8 } 9 10 public function getMethodStatus() { 11 return self::METHOD_STATUS_UNSTABLE; 12 } 13 14 public function getMethodDescription() { 15 return 'Get a commit message for committing a Releeph branch.'; 16 } 17 18 public function defineParamTypes() { 19 return array( 20 'branchPHID' => 'required string', 21 ); 22 } 23 24 public function defineReturnType() { 25 return 'nonempty string'; 26 } 27 28 public function defineErrorTypes() { 29 return array(); 30 } 31 32 protected function execute(ConduitAPIRequest $request) { 33 $viewer = $request->getUser(); 34 35 $branch = id(new ReleephBranchQuery()) 36 ->setViewer($viewer) 37 ->withPHIDs(array($request->getValue('branchPHID'))) 38 ->executeOne(); 39 40 $project = $branch->getProduct(); 41 42 $creator_phid = $branch->getCreatedByUserPHID(); 43 $cut_phid = $branch->getCutPointCommitPHID(); 44 45 $phids = array( 46 $branch->getPHID(), 47 $project->getPHID(), 48 $creator_phid, 49 $cut_phid, 50 ); 51 52 $handles = id(new PhabricatorHandleQuery()) 53 ->setViewer($request->getUser()) 54 ->withPHIDs($phids) 55 ->execute(); 56 57 $h_branch = $handles[$branch->getPHID()]; 58 $h_project = $handles[$project->getPHID()]; 59 60 // Not as customizable as a ReleephRequest's commit message. It doesn't 61 // really need to be. 62 // TODO: Yes it does, see FB-specific stuff below. 63 $commit_message = array(); 64 $commit_message[] = $h_branch->getFullName(); 65 $commit_message[] = $h_branch->getURI(); 66 67 $commit_message[] = 'Cut Point: '.$handles[$cut_phid]->getName(); 68 69 $cut_point_pr_commit = id(new PhabricatorRepositoryCommit()) 70 ->loadOneWhere('phid = %s', $cut_phid); 71 $cut_point_commit_date = strftime( 72 '%Y-%m-%d %H:%M:%S%z', 73 $cut_point_pr_commit->getEpoch()); 74 $commit_message[] = "Cut Point Date: {$cut_point_commit_date}"; 75 76 $commit_message[] = 'Created By: '.$handles[$creator_phid]->getName(); 77 78 $project_uri = $project->getURI(); 79 $commit_message[] = 'Project: '.$h_project->getName().' '.$project_uri; 80 81 /** 82 * Required for 090-limit_new_branch_creations.sh in 83 * admin/scripts/git/hosting/hooks/update.d (in the E repo): 84 * 85 * http://fburl.com/2372545 86 * 87 * The commit message must have a line saying: 88 * 89 * @new-branch: <branch-name> 90 * 91 */ 92 $repo = $project->getRepository(); 93 switch ($repo->getVersionControlSystem()) { 94 case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT: 95 $commit_message[] = sprintf( 96 '@new-branch: %s', 97 $branch->getName()); 98 break; 99 } 100 101 return implode("\n\n", $commit_message); 102 } 103 104 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |