/** * GitVersioning constructor. * * @param string $input * @param string $gitDir * @param int $timeout */ public function __construct($input, $gitDir = null, $timeout = 300) { RequirementsChecker::check('git'); $this->input = $input; $this->gitDir = $gitDir; $this->gitWrapper = new GitWrapper(); $this->gitWrapper->setTimeout($timeout); }
/** * @param Config $config */ public function __construct(Config $config, GitWrapper $gitWrapper, GitLoggerListener $gitLoggerListener) { $this->config = $config; $this->wrapper = $gitWrapper; $this->wrapper->setTimeout(self::TIMEOUT); $this->wrapper->streamOutput(0); $this->wrapper->addLoggerListener($gitLoggerListener); $this->git = $this->wrapper->workingCopy($this->config->getBasePath()); }
} foreach ($defaultAuth as $codingUserName => $auth) { requestAPI::logging('当前用户: ' . $auth[0], 'info'); $codingApi = requestAPI::start($codingUserName, $auth, $cookieDirPath); if (!$codingApi->isLogin()) { $bool = $codingApi->login(); if (!$bool) { requestAPI::logging('用户 ' . $codingUserName . ' 登录失败, 不知道原因, 退出....', 'error', true); } } //检查一下Coding上面有没有项目 没有就创建 foreach ($defaultRepository as $repositoryName => $repositoryUrl) { $codingApi->selectProject($repositoryName); } $wrapper = new GitWrapper(); $wrapper->setTimeout(3600); $defaultRepositoryTotal = count($defaultRepository); // 总数量 $i = 1; // 只要一个仓库新建任务就可以了 requestAPI::logging('当前用户 ' . $codingUserName . ' 需要执行 ' . $defaultRepositoryTotal . ' 个仓库', 'info'); foreach ($defaultRepository as $repositoryName => $repositoryUrl) { requestAPI::logging('执行第 ' . $i . ' 个仓库', 'info'); $projectPathName = $repositoryDir . '/' . $repositoryName; // 本地没有这个库 就去 git clone 下来 if (!is_dir($projectPathName)) { requestAPI::logging('本地没有此仓库: ' . $repositoryName . ' 开始从 ' . $repositoryUrl . ' Clone ....', 'info'); $git = $wrapper->cloneRepository($repositoryUrl, $projectPathName); if (!$git) { requestAPI::logging('Clone 失败 ' . $repositoryName . ' 退出...', 'error', true); }