Enable Pull Request Review API for GitHub Enterprise
Now that Pull Request Review API became official[1], it's time to
use in GitHub Enterprise too.
If GitHub Enterprise version is too low to use new API, you should use
old review dog version. (<0.9.7)
[1]:
Fixes
@@ -8,8 +8,6 @@ import (
"strings"
"sync"
- "golang.org/x/sync/errgroup"
-
"github.com/google/go-github/github"
)
@@ -108,13 +106,8 @@ func (g *GitHubPullRequest) Flush(ctx context.Context) error {
if err := g.setPostedComment(ctx); err != nil {
return err
}
- // TODO(haya14busa,#58): remove host check when GitHub Enterprise supports
- // Pull Request API.
- if g.cli.BaseURL.Host == githubAPIHost {
return g.postAsReviewComment(ctx)
}
- return g.postCommentsForEach(ctx)
-}
func (g *GitHubPullRequest) postAsReviewComment(ctx context.Context) error {
comments := make([]*github.DraftReviewComment, 0, len(g.postComments))
@@ -144,28 +137,6 @@ func (g *GitHubPullRequest) postAsReviewComment(ctx context.Context) error {
return err
}
-func (g *GitHubPullRequest) postCommentsForEach(ctx context.Context) error {
- var eg errgroup.Group
- for _, c := range g.postComments {
- comment := c
- if g.postedcs.IsPosted(comment) {
- continue
- }
- eg.Go(func() error {
- body := commentBody(comment)
- prcomment := &github.PullRequestComment{
- CommitID: &g.sha,
- Body: &body,
- Path: &comment.Path,
- Position: &comment.LnumDiff,
- }
- _, _, err := g.cli.PullRequests.CreateComment(ctx, g.owner, g.repo, g.pr, prcomment)
- return err
- })
- }
- return eg.Wait()
-}
-
func (g *GitHubPullRequest) setPostedComment(ctx context.Context) error {
g.postedcs = make(postedcomments)
cs, err := g.comment(ctx)
