Пример #1
0
 public function test_should_set_and_retrieve_tree()
 {
     $commit = new WordPress_GitHub_Sync_Commit(new stdClass());
     $commit->set_tree($this->tree);
     $sha = 'qwsadjflkajsdf';
     $this->tree->shouldReceive('sha')->andReturn($sha);
     $this->assertSame($this->tree, $commit->tree());
     $this->assertSame($sha, $commit->tree_sha());
 }
Пример #2
0
 /**
  * Retrieves a commit by sha from the GitHub API
  *
  * @param string $sha Sha for commit to retrieve.
  *
  * @return WordPress_GitHub_Sync_Commit|WP_Error
  */
 public function commit($sha)
 {
     if ($cache = $this->app->cache()->fetch_commit($sha)) {
         return $cache;
     }
     $data = $this->call('GET', $this->commit_endpoint() . '/' . $sha);
     if (is_wp_error($data)) {
         return $data;
     }
     $commit = new WordPress_GitHub_Sync_Commit($data);
     $tree = $this->tree_recursive($commit->tree_sha());
     if (is_wp_error($tree)) {
         return $tree;
     }
     $commit->set_tree($tree);
     return $this->app->cache()->set_commit($sha, $commit);
 }