Skip to content

Conversation

dziemba
Copy link
Member

@dziemba dziemba commented May 13, 2022

@codecov
Copy link

codecov bot commented May 13, 2022

Codecov Report

Merging #100 (f3fc0a4) into master (e19601c) will increase coverage by 0.13%.
The diff coverage is 100.00%.

@@             Coverage Diff              @@
##             master     #100      +/-   ##
============================================
+ Coverage     70.62%   70.76%   +0.13%     
- Complexity      225      226       +1     
============================================
  Files            36       36              
  Lines           851      855       +4     
  Branches         35       35              
============================================
+ Hits            601      605       +4     
  Misses          225      225              
  Partials         25       25              
Impacted Files Coverage Δ
...om/spotify/github/v3/clients/RepositoryClient.java 66.05% <100.00%> (+1.29%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e19601c...f3fc0a4. Read the comment docs.

Copy link
Contributor

@sathish-kumar-subramani sathish-kumar-subramani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.
Since this API responds with first 30 prs, should we handle this with pagination?
Like

public Iterator<AsyncPage<Status>> listCommitStatuses(final String sha, final int itemsPerPage) {
// FIXME Use itemsPerPage property
final String path = String.format(STATUS_URI_TEMPLATE, owner, repo, sha);
log.debug("Fetching commits from " + path);
return new GithubPageIterator<>(new GithubPage<>(github, path, LIST_STATUS_TYPE_REFERENCE));
}

note: But we do not handle pagination for most of the other APIs as well.

@dziemba
Copy link
Member Author

dziemba commented May 13, 2022

Yes I think we don't need this and don't do pagination anywhere else. Let's keep it simple for now and add it if we need it later. I don't think it's ever needed in this case: will there ever be more than 30 PRs containing the same commit? Probably not 😉

import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import javax.ws.rs.core.HttpHeaders;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an alternative class which we could use com.google.common.net.HttpHeaders

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just copied this from other classes in this project, doesn't matter much I think 🤷

final String path = String.format(COMMIT_PULL_REQUESTS_SHA_URI_TEMPLATE, owner, repo, sha);

// As of GHE 3.2, this feature is still in preview, so we need to add the extra header.
// https://developer.github.com/changes/2019-04-11-pulls-branches-for-commit/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great addition.

json.fromJson("[" + getFixture("../prs/pull_request_item.json") + "]", LIST_PR_TYPE_REFERENCE));
when(github.request(eq("/repos/someowner/somerepo/commits/thesha/pulls"), eq(LIST_PR_TYPE_REFERENCE), any()))
.thenReturn(fixture);
final List<PullRequestItem> commits = repoClient.listPullRequestsForCommit("thesha").get();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it return commits? Or pull requests? if the latter is true, should be renamed to pullRequests? (as list)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@dziemba dziemba merged commit bf30ce0 into master May 13, 2022
@dziemba dziemba deleted the prs-for-commit branch May 13, 2022 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants