Example #1
0
 /**
  * Push the status on the github analysis.
  *
  * @param \StyleCI\StyleCI\Models\Analysis $analysis
  *
  * @return void
  */
 public function push(Analysis $analysis)
 {
     $repo = $analysis->repo;
     $args = explode('/', $repo->name);
     $decorated = AutoPresenter::decorate($analysis);
     $data = ['state' => $this->getState($decorated->status), 'description' => $this->getDescription($decorated), 'target_url' => route('analysis', $decorated->id), 'context' => 'StyleCI'];
     $client = $this->factory->make($repo);
     $client->repos()->statuses()->create($args[0], $args[1], $analysis->commit, $data);
 }
Example #2
0
 /**
  * Fetch a repo's collaborators from github.
  *
  * @param \StyleCI\StyleCI\Models\User $user
  * @param string                       $name
  *
  * @return array
  */
 protected function fetchFromGitHub(User $user, $name)
 {
     $client = $this->factory->make($user);
     $paginator = new ResultPager($client);
     $list = [];
     foreach ($paginator->fetchAll($client->repo()->collaborators(), 'all', explode('/', $name)) as $user) {
         $list[] = $user['id'];
     }
     return $list;
 }
Example #3
0
 /**
  * Fetch a user's repos from github.
  *
  * @param \StyleCI\StyleCI\Models\User $user
  *
  * @return array
  */
 protected function fetchFromGitHub(User $user)
 {
     $client = $this->factory->make($user);
     $paginator = new ResultPager($client);
     $list = [];
     foreach ($paginator->fetchAll($client->me(), 'repositories', ['public']) as $repo) {
         // set enabled to false by default
         // we'll mark those that are enabled at a later point
         $list[$repo['id']] = ['name' => $repo['full_name'], 'default_branch' => $repo['default_branch'], 'language' => $repo['language'], 'admin' => $repo['permissions']['admin'], 'enabled' => false];
     }
     return $list;
 }
Example #4
0
 /**
  * Disable the styleci webhook for the given repo.
  *
  * @param \StyleCI\StyleCI\Models\Repo $repo
  *
  * @return void
  */
 public function disable(Repo $repo)
 {
     $url = route('home');
     $args = explode('/', $repo->name);
     $client = $this->factory->make($repo);
     $hooks = $client->repo()->hooks();
     $paginator = new ResultPager($client);
     foreach ($paginator->fetchAll($hooks, 'all', $args) as $hook) {
         if ($hook['name'] !== 'web' || StaticStringy::contains($hook['config']['url'], $url, false) !== true) {
             continue;
         }
         $hooks->remove($args[0], $args[1], $hook['id']);
     }
 }
Example #5
0
 /**
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage You must provide a user or repo.
  */
 public function testMakeAndFail()
 {
     $factory = new ClientFactory(Mockery::mock(GitHubFactory::class));
     $factory->make(new Analysis());
 }
Example #6
0
 /**
  * Get information about a specific commit from github.
  *
  * @param \StyleCI\StyleCI\Models\Repo $repo
  * @param string                       $commit
  *
  * @return array
  */
 public function get(Repo $repo, $commit)
 {
     $args = explode('/', $repo->name);
     $client = $this->factory->make($repo);
     return $client->repos()->commits()->show($args[0], $args[1], $commit);
 }
Example #7
0
 /**
  * Fetch the raw branch list from github.
  *
  * @param \StyleCI\StyleCI\Models\Repo $repo
  *
  * @return array
  */
 protected function fetchFromGitHub(Repo $repo)
 {
     $client = $this->factory->make($repo);
     $paginator = new ResultPager($client);
     return $paginator->fetchAll($client->repos(), 'branches', explode('/', $repo->name));
 }