当前位置: 首页>>代码示例>>PHP>>正文


PHP Branch::setBaseBranchName方法代码示例

本文整理汇总了PHP中Branch::setBaseBranchName方法的典型用法代码示例。如果您正苦于以下问题:PHP Branch::setBaseBranchName方法的具体用法?PHP Branch::setBaseBranchName怎么用?PHP Branch::setBaseBranchName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Branch的用法示例。


在下文中一共展示了Branch::setBaseBranchName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 /**
  * @param sfWebRequest $request
  * @return void
  */
 public function execute($request)
 {
     $projectId = $request->getParameter('project_id');
     $baseBranchName = $request->getParameter('base_branch');
     $branchName = $request->getParameter('branch');
     $commit = (string) $request->getParameter('commit');
     // Last commit
     $result = array();
     file_put_contents(sprintf("%s/api.log", sfConfig::get('sf_log_dir')), sprintf("%s [%s] set review = projectId : %s - baseBranchName : %s - branchName : %s - commit : %s\n", date('d/m/Y H:i:s'), $_SERVER['REMOTE_ADDR'], $projectId, $baseBranchName, $branchName, $commit), FILE_APPEND);
     $repository = RepositoryQuery::create()->filterById($projectId)->findOne();
     if ($repository) {
         $branch = BranchQuery::create()->filterByRepositoryId($repository->getId())->filterByName($branchName)->findOne();
         if (!$branch) {
             $branch = new Branch();
             $branch->setName($branchName)->setRepositoryId($repository->getId())->setBaseBranchName($baseBranchName)->save();
         }
         if ($branch->getBaseBranchName() != $baseBranchName) {
             $branch->setBaseBranchName($baseBranchName)->save();
         }
         if (($nbFiles = BranchPeer::synchronize($this->gitCommand, $repository, $branch)) != 0) {
             $result['message'] = sprintf("Your branch '%s' has too many files : %s (max : %s)", $branch->__toString(), $nbFiles, sfConfig::get('app_max_number_of_files_to_review', 4096));
             $this->getResponse()->setStatusCode('500');
         } elseif (!$branch->isDeleted()) {
             if (strlen($commit) === 40) {
                 if (!$this->gitCommand->commitIsInHistory($repository->getGitDir(), $branch->getCommitStatusChanged(), $commit)) {
                     $result['message'] = sprintf("Review has been %sengaged [old status : %s]", $branch->getReviewRequest() ? 're' : '', BranchPeer::getLabelStatus($branch->getStatus()));
                     $branch->setReviewRequest(1)->setStatus(BranchPeer::A_TRAITER)->setIsBlacklisted(0)->save();
                     $this->getResponse()->setStatusCode('201');
                     $this->dispatcher->notify(new sfEvent($this, 'notification.review-request', array('project-id' => $branch->getRepositoryId(), 'object' => $branch)));
                 } else {
                     $result['message'] = sprintf("Commit already used : '%s'", $commit);
                     $this->getResponse()->setStatusCode('200');
                 }
             } else {
                 $result['message'] = sprintf("No valid commit '%s'", $commit);
                 $this->getResponse()->setStatusCode('422');
             }
         } else {
             $result['message'] = sprintf("Unknown branch '%s' in project '%s'", $branchName, $repository->getName());
             $this->getResponse()->setStatusCode('404');
         }
     } else {
         $result['message'] = sprintf("No valid project '%s'", $projectId);
         $this->getResponse()->setStatusCode('400');
     }
     $this->getResponse()->setContentType('application/json');
     return $this->renderText(json_encode($result));
 }
开发者ID:ratibus,项目名称:Crew,代码行数:52,代码来源:setAction.class.php


注:本文中的Branch::setBaseBranchName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。