本文整理匯總了PHP中Github\Client::getFileInfo方法的典型用法代碼示例。如果您正苦於以下問題:PHP Client::getFileInfo方法的具體用法?PHP Client::getFileInfo怎麽用?PHP Client::getFileInfo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Github\Client
的用法示例。
在下文中一共展示了Client::getFileInfo方法的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;
}
}