Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added missing /repos/{owner}/{repo}/pulls/... handlers (#546) #605

Merged
merged 12 commits into from
Jul 29, 2024

Conversation

dmgorsky
Copy link
Contributor

solves #546

@dmgorsky dmgorsky marked this pull request as draft March 11, 2024 21:31
@dmgorsky dmgorsky changed the title added comment handler for /repos/{OWNER}/{REPO}/pulls/comments/{COMMENT_ID} [WIP] added comment handler for /repos/{OWNER}/{REPO}/pulls/comments/{COMMENT_ID} Mar 11, 2024
@dmgorsky dmgorsky closed this Mar 11, 2024
@dmgorsky dmgorsky reopened this Mar 11, 2024
@dmgorsky dmgorsky changed the title [WIP] added comment handler for /repos/{OWNER}/{REPO}/pulls/comments/{COMMENT_ID} added missing /repos/{owner}/{repo}/pulls/... handlers (#546) Mar 17, 2024
@dmgorsky dmgorsky marked this pull request as ready for review March 17, 2024 16:29
src/api/pulls.rs Outdated
Comment on lines 392 to 403
/// creates a builder for the `/repos/{owner}/{repo}/pulls/{pull_number}/......` endpoint
/// working with particular pull request, e.g.
/// * /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/events
/// * /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}
/// * /repos/{owner}/{repo}/pulls/{pull_number}/commits
/// * /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/comments
/// * /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/dismissals
/// * /repos/{owner}/{repo}/pulls/{pull_number}/comments/{comment_id}/replies
///
pub fn pull_number(&self, pull_nr: u64) -> SpecificPullRequestBuilder {
SpecificPullRequestBuilder::new(self, pull_nr)
}
Copy link
Owner

Choose a reason for hiding this comment

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

I think instead of having a specific builder for this, we should instead mimic octokit here, and have each of these methods attached to the pulls builder, and have the pull number as a required argument.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So far it is looking like

octocrab.pulls("owner", "repo")
    .pull_number(42)
    .reviews()
        .review(42).get()

octocrab.pulls("owner", "repo")
    .pull_number(42)
    .reviews()
        .review(42).update("this is a new body")

octocrab.pulls("owner", "repo")
    .pull_number(42)
    .comment(CommentId(42))
    .reply("new comment")

octocrab.pulls("owner", "repo")
    .pull_number(42)
    .reviews().review(42)
    .list_comments()
        .per_page(10)
        .page(3u32)
        .send()

How do you prefer it? Octokit does it like

[ManualRoute("GET", "/repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/comments")]
        public Task<IReadOnlyList<PullRequestReviewComment>> GetAllComments(string owner, string name, int number, long reviewId, ApiOptions options)

so we would have
-=1=-

octocrab.pulls("owner", "repo")
        .get_all_comments(/*pr_nr*/ 42, /*review_nr*/ 42)
        .per_page(10)
        .page(3u32)
        .send()

or even
-=2=-

octocrab.pulls("owner", "repo")
        .get_all_comments(/*pr_nr*/ 42, /*review_nr*/ 42, /*pagination*/ PagingOptions{...})

?

IMHO, in absence of named arguments, the following options are more readable:

  • Builder pattern;
  • Struct parameter.

Anyways, I sense we go with -=1=- (to retain Octocrab pagination style)? TIA @XAMPPRocky

Copy link
Owner

@XAMPPRocky XAMPPRocky Mar 29, 2024

Choose a reason for hiding this comment

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

Yes, 1, I just mean removing the pull_number builder and having the pr number as the first argument in these calls. Keeping the other builders.

Copy link
Contributor Author

@dmgorsky dmgorsky Apr 5, 2024

Choose a reason for hiding this comment

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

@XAMPPRocky please check if it suits: 377342b

@XAMPPRocky
Copy link
Owner

Thank you for your PR!

@XAMPPRocky XAMPPRocky merged commit a147ef2 into XAMPPRocky:main Jul 29, 2024
11 checks passed
@github-actions github-actions bot mentioned this pull request Jul 29, 2024
Comment on lines +425 to +428
/// /repos/{owner}/{repo}/pulls/{pull_number}/commits
// pub fn pr_commits(&self, pull_nr: u64) -> SpecificPullRequestCommentBuilder<'octo, '_> {
// SpecificPullRequestCommentBuilder::new(self, pull_nr, 0)
// }
Copy link
Contributor

Choose a reason for hiding this comment

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

please take a look at #680

@dmgorsky dmgorsky deleted the feature/pulls_546 branch October 11, 2024 08:46
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.

4 participants