dmitri.shuralyov.com/route/github/...

add IssueEventURL and PullRequestEventURL to Router

These methods will be used to produce links to issue and PR events.
dmitshur committed 5 years ago commit 7e79d56078638d1d7d4d6853af037d67de3f9589
Collapse all
github.go
@@ -12,10 +12,13 @@ type Router interface {
	IssueURL(ctx context.Context, owner, repo string, issueID uint64) string

	// IssueCommentURL returns the HTML URL of the specified GitHub issue comment.
	IssueCommentURL(ctx context.Context, owner, repo string, issueID, commentID uint64) string

	// IssueEventURL returns the HTML URL of the specified GitHub issue event.
	IssueEventURL(ctx context.Context, owner, repo string, issueID, eventID uint64) string

	// PullRequestURL returns the HTML URL of the specified GitHub pull request.
	PullRequestURL(ctx context.Context, owner, repo string, prID uint64) string

	// PullRequestCommentURL returns the HTML URL of the specified GitHub pull request comment.
	PullRequestCommentURL(ctx context.Context, owner, repo string, prID, commentID uint64) string
@@ -23,10 +26,13 @@ type Router interface {
	// PullRequestReviewURL returns the HTML URL of the specified GitHub pull request review.
	PullRequestReviewURL(ctx context.Context, owner, repo string, prID, reviewID uint64) string

	// PullRequestReviewCommentURL returns the HTML URL of the specified GitHub pull request review comment.
	PullRequestReviewCommentURL(ctx context.Context, owner, repo string, prID, reviewCommentID uint64) string

	// PullRequestEventURL returns the HTML URL of the specified GitHub pull request event.
	PullRequestEventURL(ctx context.Context, owner, repo string, prID, eventID uint64) string
}

// DotCom provides HTML URLs of GitHub subjects on github.com.
type DotCom struct{}

@@ -38,10 +44,15 @@ func (DotCom) IssueURL(_ context.Context, owner, repo string, issueID uint64) st
// IssueCommentURL returns the HTML URL of the specified GitHub issue comment on github.com.
func (DotCom) IssueCommentURL(_ context.Context, owner, repo string, issueID, commentID uint64) string {
	return fmt.Sprintf("https://github.com/%s/%s/issues/%d#issuecomment-%d", owner, repo, issueID, commentID)
}

// IssueEventURL returns the HTML URL of the specified GitHub issue event on github.com.
func (DotCom) IssueEventURL(_ context.Context, owner, repo string, issueID, eventID uint64) string {
	return fmt.Sprintf("https://github.com/%s/%s/issues/%d#event-%d", owner, repo, issueID, eventID)
}

// PullRequestURL returns the HTML URL of the specified GitHub pull request on github.com.
func (DotCom) PullRequestURL(_ context.Context, owner, repo string, prID uint64) string {
	return fmt.Sprintf("https://github.com/%s/%s/pull/%d", owner, repo, prID)
}

@@ -57,5 +68,10 @@ func (DotCom) PullRequestReviewURL(_ context.Context, owner, repo string, prID,

// PullRequestReviewCommentURL returns the HTML URL of the specified GitHub pull request review comment on github.com.
func (DotCom) PullRequestReviewCommentURL(_ context.Context, owner, repo string, prID, reviewCommentID uint64) string {
	return fmt.Sprintf("https://github.com/%s/%s/pull/%d#discussion_r%d", owner, repo, prID, reviewCommentID)
}

// PullRequestEventURL returns the HTML URL of the specified GitHub pull request event on github.com.
func (DotCom) PullRequestEventURL(_ context.Context, owner, repo string, prID, eventID uint64) string {
	return fmt.Sprintf("https://github.com/%s/%s/pull/%d#event-%d", owner, repo, prID, eventID)
}