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


PHP Client::updateFile方法代码示例

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


在下文中一共展示了Client::updateFile方法的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;
     }
 }
开发者ID:RepoMon,项目名称:update,代码行数:44,代码来源:Updater.php


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