/** * 修改合并目标分支 * @throws \Exception * */ function _modify_branch_action() { if ($this->role != 16) { throw new \Exception('firegit.u_power'); } $reposite = new \firegit\git\Reposite($this->gitGroup, $this->gitName); $datas['dest_branch'] = $_POST['branch']; $mergeId = $_POST['merge_id']; $datas['dest_hash'] = $reposite->getBranchHash($datas['dest_branch']); $api = new \firegit\app\mod\git\Merge(); $mergeinfo = $api->getMerge($mergeId); if (!$mergeinfo) { throw new \Exception('firegit.u_notfound'); } if ($datas['dest_branch'] == $mergeinfo['dest_branch']) { throw new \Exception('firegit.alike'); } $merge = new \firegit\app\mod\git\Merge(); $merge->updateDate($mergeId, $datas); }
/** * 通过分支的名字获取分支 * @param $repoGroup * @param $repoName * @param $BrancheName * @return mixed * @throws \Exception */ function getMergeByBrancheName($repoGroup, $repoName, $BrancheName) { if (empty($BrancheName)) { throw new \Exception('firegit.branchError'); } $reposite = new \firegit\git\Reposite($repoGroup, $repoName); $Hash = $reposite->getBranchHash($BrancheName); $branchInfo = Db::get('firegit')->table('fg_merge')->where(array('orig_branch' => $BrancheName, 'orig_hash' => $Hash, 'passed' => 0, 'merge_status' => 1))->getOne(); if (empty($branchInfo)) { return array(); } return $branchInfo; }