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()); }
/** * Add a new commit to the master branch. * * @param WordPress_GitHub_Sync_Commit $commit Commit to create. * * @return bool|mixed|WordPress_GitHub_Sync_Commit|WP_Error */ public function commit(WordPress_GitHub_Sync_Commit $commit) { if (!$commit->tree()->is_changed()) { return new WP_Error('no_commit', __('There were no changes, so no additional commit was added.', 'wordpress-github-sync')); } $tree = $this->create_tree($commit->tree()); if (is_wp_error($tree)) { return $tree; } $commit->tree()->set_sha($tree->sha); $commit = $this->create_commit($commit); if (is_wp_error($commit)) { return $commit; } $ref = $this->set_ref($commit->sha); if (is_wp_error($ref)) { return $ref; } return true; }