Loading pift.module +24 −20 Original line number Diff line number Diff line Loading @@ -1292,30 +1292,34 @@ function pift_create_job(VersioncontrolGitBranchChange $ref) { /** * Implements hook_drupalorg_versioncontrol_repo_changes(). */ function pift_drupalorg_versioncontrol_repo_changes(VersioncontrolGitBranchChange $ref, $repo_workdir) { function pift_drupalorg_versioncontrol_repo_changes(VersioncontrolGitBranchChange $ref) { if ($commit = $ref->getNewCommit()) { // We only support one drupalci.yml file in the root of the repository. foreach ($commit->loadItemRevisions() as $file) { if ($file->path === '/drupalci.yml' || $file->path === '/core/drupalci.yml') { $repository = $ref->getRepository(); $expected_path = versioncontrol_project_project_load($repository->repo_id)->type === 'project_core' ? '/core/drupalci.yml' : '/drupalci.yml'; $url = $repository->getUrlHandler()->getRepositoryViewUrl() . '/-/raw/' . $ref->refname . $expected_path; try { $contents = (new \GuzzleHttp\Client())->get($url, ['auth' => ['drupal', 'drupal']])->getBody(); db_merge('pift_ci_config')->key([ 'repo_id' => $ref->getRepository()->repo_id, 'repo_id' => $repository->repo_id, 'label_id' => $ref->label_id, 'file_path' => $file->path, ])->fields([ 'repo_name' => $ref->getRepository()->name, 'file_path' => $expected_path, ]) ->condition('contents', $contents, '!=') ->fields([ 'repo_name' => $repository->name, 'branch' => $ref->refname, 'file_type' => 'drupalci_testing_config', 'updated' => REQUEST_TIME, 'contents' => file_get_contents($repo_workdir . $file->path), 'contents' => $contents, ])->execute(); // TODO: Look for drupalci_environments/ folder and store those too. } catch (Exception $e) { watchdog('pift_ci', 'Failure to update build.yml: @error', ['@error' => $e->getMessage()], WATCHDOG_WARNING); } if (!($e instanceof \GuzzleHttp\Exception\ClientException && $e->getCode() == 404)) { watchdog('pift_ci', 'Failure to update drupalci.yml: @error', ['@error' => $e->getMessage()], WATCHDOG_WARNING); } // TODO: Look for drupalci_environments/ folder and store those too. } pift_create_job($ref); } Loading Loading
pift.module +24 −20 Original line number Diff line number Diff line Loading @@ -1292,30 +1292,34 @@ function pift_create_job(VersioncontrolGitBranchChange $ref) { /** * Implements hook_drupalorg_versioncontrol_repo_changes(). */ function pift_drupalorg_versioncontrol_repo_changes(VersioncontrolGitBranchChange $ref, $repo_workdir) { function pift_drupalorg_versioncontrol_repo_changes(VersioncontrolGitBranchChange $ref) { if ($commit = $ref->getNewCommit()) { // We only support one drupalci.yml file in the root of the repository. foreach ($commit->loadItemRevisions() as $file) { if ($file->path === '/drupalci.yml' || $file->path === '/core/drupalci.yml') { $repository = $ref->getRepository(); $expected_path = versioncontrol_project_project_load($repository->repo_id)->type === 'project_core' ? '/core/drupalci.yml' : '/drupalci.yml'; $url = $repository->getUrlHandler()->getRepositoryViewUrl() . '/-/raw/' . $ref->refname . $expected_path; try { $contents = (new \GuzzleHttp\Client())->get($url, ['auth' => ['drupal', 'drupal']])->getBody(); db_merge('pift_ci_config')->key([ 'repo_id' => $ref->getRepository()->repo_id, 'repo_id' => $repository->repo_id, 'label_id' => $ref->label_id, 'file_path' => $file->path, ])->fields([ 'repo_name' => $ref->getRepository()->name, 'file_path' => $expected_path, ]) ->condition('contents', $contents, '!=') ->fields([ 'repo_name' => $repository->name, 'branch' => $ref->refname, 'file_type' => 'drupalci_testing_config', 'updated' => REQUEST_TIME, 'contents' => file_get_contents($repo_workdir . $file->path), 'contents' => $contents, ])->execute(); // TODO: Look for drupalci_environments/ folder and store those too. } catch (Exception $e) { watchdog('pift_ci', 'Failure to update build.yml: @error', ['@error' => $e->getMessage()], WATCHDOG_WARNING); } if (!($e instanceof \GuzzleHttp\Exception\ClientException && $e->getCode() == 404)) { watchdog('pift_ci', 'Failure to update drupalci.yml: @error', ['@error' => $e->getMessage()], WATCHDOG_WARNING); } // TODO: Look for drupalci_environments/ folder and store those too. } pift_create_job($ref); } Loading