コード例 #1
0
 /**
  * Create the commit from tree sha.
  *
  * @param WordPress_GitHub_Sync_Commit $commit Commit to create.
  *
  * @return mixed
  */
 protected function create_commit(WordPress_GitHub_Sync_Commit $commit)
 {
     $body = $commit->to_body();
     if ($author = $this->export_user()) {
         $body['author'] = $author;
     }
     return $this->call('POST', $this->commit_endpoint(), $body);
 }
コード例 #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);
 }
コード例 #3
0
 public function test_should_set_self_to_parent_on_committer_update()
 {
     $sha = '1233567890fghjkaisdfasd';
     $data = new stdClass();
     $data->sha = $sha;
     $commit = new WordPress_GitHub_Sync_Commit($data);
     $commit->set_committer(new stdClass());
     $this->assertCount(1, $parents = $commit->parents());
     $this->assertSame($sha, $parents[0]);
 }