Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"google.golang.org/appengine"
"google.golang.org/appengine/log"

"github-mirror/mirror"
"github.com/google/git-pull-request-mirror/mirror"
)

const (
Expand Down Expand Up @@ -423,7 +423,7 @@ func restartAbandonedOperations() {

repos, err := getAllRepoData(c)
if err != nil {
log.Errorf(c, "Can't load repos: %s", err.Error)
log.Errorf(c, "Can't load repos: %s", err.Error())
return
}

Expand Down
4 changes: 2 additions & 2 deletions batch/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ import (
"github.com/google/git-appraise/repository"
"github.com/google/go-github/github"

"github-mirror/auth"
"github-mirror/mirror"
"github.com/google/git-pull-request-mirror/auth"
"github.com/google/git-pull-request-mirror/mirror"
)

var remoteRepository = flag.String("target", "", "Github repository to read data from")
Expand Down
14 changes: 7 additions & 7 deletions mirror/conversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func ConvertTime(t time.Time) string {
}

// ConvertStatus converts a commit status fetched from the GitHub API into a CI report.
func ConvertStatus(repoStatus github.RepoStatus) (*ci.Report, error) {
func ConvertStatus(repoStatus *github.RepoStatus) (*ci.Report, error) {
result := ci.Report{}
if repoStatus.UpdatedAt != nil {
result.Timestamp = ConvertTime(*repoStatus.UpdatedAt)
Expand Down Expand Up @@ -80,7 +80,7 @@ func ConvertStatus(repoStatus github.RepoStatus) (*ci.Report, error) {
}

// ConvertPullRequest converts a pull request fetched from the GitHub API into a review request.
func ConvertPullRequest(pr github.PullRequest) (*request.Request, error) {
func ConvertPullRequest(pr *github.PullRequest) (*request.Request, error) {
if pr.Number == nil || pr.User.Login == nil ||
pr.Base == nil || pr.Base.Ref == nil || pr.Base.SHA == nil ||
(pr.CreatedAt == nil && pr.UpdatedAt == nil) {
Expand Down Expand Up @@ -121,7 +121,7 @@ func ConvertPullRequest(pr github.PullRequest) (*request.Request, error) {
}

// ConvertIssueComment converts a comment on the issue associated with a pull request into a git-appraise review comment.
func ConvertIssueComment(issueComment github.IssueComment) (*comment.Comment, error) {
func ConvertIssueComment(issueComment *github.IssueComment) (*comment.Comment, error) {
if issueComment.User == nil || issueComment.User.Login == nil || issueComment.Body == nil ||
(issueComment.UpdatedAt == nil && issueComment.CreatedAt == nil) {
return nil, ErrInsufficientInfo
Expand All @@ -144,7 +144,7 @@ func ConvertIssueComment(issueComment github.IssueComment) (*comment.Comment, er
}

// ConvertDiffComment converts a comment on the diff associated with a pull request into a git-appraise review comment.
func ConvertDiffComment(diffComment github.PullRequestComment) (*comment.Comment, error) {
func ConvertDiffComment(diffComment *github.PullRequestComment) (*comment.Comment, error) {
if diffComment.User == nil || diffComment.User.Login == nil || diffComment.Body == nil ||
(diffComment.UpdatedAt == nil && diffComment.CreatedAt == nil) ||
diffComment.OriginalCommitID == nil {
Expand Down Expand Up @@ -190,7 +190,7 @@ func ConvertDiffComment(diffComment github.PullRequestComment) (*comment.Comment
//
// This method requires a local clone of the repository in order to compute the locations of
// the different commits in the review.
func ConvertPullRequestToReview(pr github.PullRequest, issueComments []github.IssueComment, diffComments []github.PullRequestComment, repo repository.Repo) (*review.Review, error) {
func ConvertPullRequestToReview(pr *github.PullRequest, issueComments []*github.IssueComment, diffComments []*github.PullRequestComment, repo repository.Repo) (*review.Review, error) {
request, err := ConvertPullRequest(pr)
if err != nil {
return nil, err
Expand Down Expand Up @@ -242,7 +242,7 @@ func ConvertPullRequestToReview(pr github.PullRequest, issueComments []github.Is
}

// commentStartLine takes a PullRequestComment and returns the comment's start line.
func commentStartLine(diffComment github.PullRequestComment) (uint32, error) {
func commentStartLine(diffComment *github.PullRequestComment) (uint32, error) {
// This takes some contortions to figure out. The diffComment has a "position"
// field, but that is not the position of the comment. Instead, that is the
// position of the comment within the diff. Furthermore, this diff is a unified diff,
Expand Down Expand Up @@ -288,7 +288,7 @@ func commentStartLine(diffComment github.PullRequestComment) (uint32, error) {
}

// computeReviewStartingCommit computes the first commit in the review.
func computeReviewStartingCommit(pr github.PullRequest, repo repository.Repo) (string, error) {
func computeReviewStartingCommit(pr *github.PullRequest, repo repository.Repo) (string, error) {
if pr.Base == nil || pr.Base.SHA == nil ||
pr.Head == nil || pr.Head.SHA == nil {
return "", ErrInsufficientInfo
Expand Down
18 changes: 9 additions & 9 deletions mirror/readall.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@ var (

// Can be stubbed out in testing; satisfied by github.Client.Repositories
type repositoriesService interface {
ListStatuses(owner, repo, ref string, opt *github.ListOptions) ([]github.RepoStatus, *github.Response, error)
ListStatuses(owner, repo, ref string, opt *github.ListOptions) ([]*github.RepoStatus, *github.Response, error)
}

type pullRequestsService interface {
List(owner string, repo string, opt *github.PullRequestListOptions) ([]github.PullRequest, *github.Response, error)
ListComments(owner string, repo string, number int, opt *github.PullRequestListCommentsOptions) ([]github.PullRequestComment, *github.Response, error)
List(owner string, repo string, opt *github.PullRequestListOptions) ([]*github.PullRequest, *github.Response, error)
ListComments(owner string, repo string, number int, opt *github.PullRequestListCommentsOptions) ([]*github.PullRequestComment, *github.Response, error)
}

type issuesService interface {
ListComments(owner string, repo string, number int, opt *github.IssueListCommentsOptions) ([]github.IssueComment, *github.Response, error)
ListComments(owner string, repo string, number int, opt *github.IssueListCommentsOptions) ([]*github.IssueComment, *github.Response, error)
}

type retryableRequest func() (*github.Response, error)
Expand Down Expand Up @@ -204,8 +204,8 @@ func GetAllPullRequests(local repository.Repo, remoteUser, remoteRepo string, cl
return output, nil
}

func fetchPullRequests(remoteUser, remoteRepo string, prs pullRequestsService) ([]github.PullRequest, error) {
var results []github.PullRequest
func fetchPullRequests(remoteUser, remoteRepo string, prs pullRequestsService) ([]*github.PullRequest, error) {
var results []*github.PullRequest
err := executeListRequest(func(listOpts github.ListOptions) (*github.Response, error) {
opts := &github.PullRequestListOptions{
State: "all",
Expand All @@ -224,8 +224,8 @@ func fetchPullRequests(remoteUser, remoteRepo string, prs pullRequestsService) (
}

// fetchComments fetches all of the comments for each issue it gets and then converts them.
func fetchComments(pr github.PullRequest, remoteUser, remoteRepo string, prs pullRequestsService, is issuesService) ([]github.IssueComment, []github.PullRequestComment, error) {
var issueComments []github.IssueComment
func fetchComments(pr *github.PullRequest, remoteUser, remoteRepo string, prs pullRequestsService, is issuesService) ([]*github.IssueComment, []*github.PullRequestComment, error) {
var issueComments []*github.IssueComment
err := executeListRequest(func(listOpts github.ListOptions) (*github.Response, error) {
listOptions := &github.IssueListCommentsOptions{
ListOptions: listOpts,
Expand All @@ -239,7 +239,7 @@ func fetchComments(pr github.PullRequest, remoteUser, remoteRepo string, prs pul
if err != nil {
return nil, nil, err
}
var diffComments []github.PullRequestComment
var diffComments []*github.PullRequestComment
err = executeListRequest(func(listOpts github.ListOptions) (*github.Response, error) {
listOptions := &github.PullRequestListCommentsOptions{
ListOptions: listOpts,
Expand Down
4 changes: 2 additions & 2 deletions mirror/readall_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type repoServiceStub struct {
Responses []repoServiceResponse
}

func (s *repoServiceStub) ListStatuses(owner, repo, ref string, opt *github.ListOptions) ([]github.RepoStatus, *github.Response, error) {
func (s *repoServiceStub) ListStatuses(owner, repo, ref string, opt *github.ListOptions) ([]*github.RepoStatus, *github.Response, error) {
if s.Index >= len(s.Responses) {
}
r := s.Responses[s.Index]
Expand Down Expand Up @@ -102,7 +102,7 @@ func TestFetchReports(t *testing.T) {
expectedReports = append(expectedReports, *successReport)
expectedReports = append(expectedReports, *failureReport)
responses = append(responses, repoServiceResponse{
Results: []github.RepoStatus{
Results: []*github.RepoStatus{
successResult,
failureResult,
},
Expand Down