本文整理汇总了PHP中Github\Client::createPullRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::createPullRequest方法的具体用法?PHP Client::createPullRequest怎么用?PHP Client::createPullRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Github\Client
的用法示例。
在下文中一共展示了Client::createPullRequest方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* @param $from_branch
* @param $to_branch
* @return bool
*/
public function run($from_branch, $to_branch)
{
$this->logger->debug(__METHOD__);
$config_file = $this->repository->findFileInfo($this->dependency_manager->getConfigFileName());
if (is_null($config_file)) {
throw new FileNotFoundException(sprintf("%s : file not found", $this->dependency_manager->getConfigFileName()));
}
// copy config file locally
$config_contents = $this->repository->getFileContents($config_file['path'], $from_branch);
$this->file_system->write($this->dependency_manager->getConfigFileName(), $config_contents);
$lock_file = $this->repository->findFileInfo($this->dependency_manager->getLockFileName());
if (!is_null($lock_file)) {
// copy lock file locally
$lock_contents = $this->repository->getFileContents($lock_file['path'], $from_branch);
$this->file_system->write($this->dependency_manager->getLockFileName(), $lock_contents);
}
$new_contents = $this->dependency_manager->exec($this->file_system->getDirectory());
if (!is_null($new_contents)) {
$this->logger->debug('Lock file updated');
$branch_created = $this->repository->createBranch($from_branch, $to_branch);
if (!is_null($lock_file)) {
// update file info on the lock file from the target branch, get its sha to use when updating it
$lock_file = $this->repository->getFileInfo($lock_file['path'], $to_branch);
$this->repository->updateFile($lock_file['path'], $lock_file['sha'], $new_contents, $to_branch);
} else {
// the lock file does not exist, create it next to config_file['path']
$path = pathinfo($config_file['path'], PATHINFO_DIRNAME);
$this->repository->createFile($path . '/' . $this->dependency_manager->getLockFileName(), $new_contents, $to_branch);
}
// only make a pr if one does not already exist
if ($branch_created) {
$this->repository->createPullRequest('Repository Monitor update', $from_branch, $to_branch, 'Scheduled dependency update');
}
return true;
} else {
$this->logger->debug('No changes made');
return false;
}
}