Repository: lindell/multi-gitter
Pull request #98 (2021-04-07 16:02:13)

refactor: renamed GetPullRequestStatuses -> GetPullRequests


Patch:
diff --git a/internal/multigitter/close.go b/internal/multigitter/close.go
index c9d826f..d5a8a5d 100644
--- a/internal/multigitter/close.go
+++ b/internal/multigitter/close.go
@@ -16,7 +16,7 @@ type Closer struct {
 
 // Close closes pull requests
 func (s Closer) Close(ctx context.Context) error {
-	prs, err := s.VersionController.GetPullRequestStatuses(ctx, s.FeatureBranch)
+	prs, err := s.VersionController.GetPullRequests(ctx, s.FeatureBranch)
 	if err != nil {
 		return err
 	}
diff --git a/internal/multigitter/merge.go b/internal/multigitter/merge.go
index 819ca7c..90092bc 100644
--- a/internal/multigitter/merge.go
+++ b/internal/multigitter/merge.go
@@ -17,7 +17,7 @@ type Merger struct {
 
 // Merge merges pull requests in an organization
 func (s Merger) Merge(ctx context.Context) error {
-	prs, err := s.VersionController.GetPullRequestStatuses(ctx, s.FeatureBranch)
+	prs, err := s.VersionController.GetPullRequests(ctx, s.FeatureBranch)
 	if err != nil {
 		return err
 	}
diff --git a/internal/multigitter/run.go b/internal/multigitter/run.go
index ad82d7e..dc62ed7 100755
--- a/internal/multigitter/run.go
+++ b/internal/multigitter/run.go
@@ -23,7 +23,7 @@ import (
 type VersionController interface {
 	GetRepositories(ctx context.Context) ([]domain.Repository, error)
 	CreatePullRequest(ctx context.Context, repo domain.Repository, newPR domain.NewPullRequest) (domain.PullRequest, error)
-	GetPullRequestStatuses(ctx context.Context, branchName string) ([]domain.PullRequest, error)
+	GetPullRequests(ctx context.Context, branchName string) ([]domain.PullRequest, error)
 	MergePullRequest(ctx context.Context, pr domain.PullRequest) error
 	ClosePullRequest(ctx context.Context, pr domain.PullRequest) error
 }
diff --git a/internal/multigitter/status.go b/internal/multigitter/status.go
index b39290c..953b3a8 100644
--- a/internal/multigitter/status.go
+++ b/internal/multigitter/status.go
@@ -19,7 +19,7 @@ type Statuser struct {
 
 // Statuses checks the statuses of pull requests
 func (s Statuser) Statuses(ctx context.Context) error {
-	prs, err := s.VersionController.GetPullRequestStatuses(ctx, s.FeatureBranch)
+	prs, err := s.VersionController.GetPullRequests(ctx, s.FeatureBranch)
 	if err != nil {
 		return err
 	}
diff --git a/internal/scm/README.md b/internal/scm/README.md
index bb9ee3f..3528d2f 100644
--- a/internal/scm/README.md
+++ b/internal/scm/README.md
@@ -9,7 +9,7 @@ type VersionController interface {
     // Creates a pull request. The repo parameter can be expected to originate from the GetRepositories function in the same package
 	CreatePullRequest(ctx context.Context, repo domain.Repository, newPR domain.NewPullRequest) (domain.PullRequest, error)
 
-	GetPullRequestStatuses(ctx context.Context, branchName string) ([]domain.PullRequest, error)
+	GetPullRequests(ctx context.Context, branchName string) ([]domain.PullRequest, error)
 
 	MergePullRequest(ctx context.Context, pr domain.PullRequest) error
 
diff --git a/internal/scm/github/github.go b/internal/scm/github/github.go
index f089fb2..29e4df7 100755
--- a/internal/scm/github/github.go
+++ b/internal/scm/github/github.go
@@ -293,8 +293,8 @@ func (g Github) addReviewers(ctx context.Context, repo repository, newPR domain.
 	return err
 }
 
-// GetPullRequestStatuses gets the statuses of all pull requests of with a specific branch
-func (g Github) GetPullRequestStatuses(ctx context.Context, branchName string) ([]domain.PullRequest, error) {
+// GetPullRequests gets all pull requests of with a specific branch
+func (g Github) GetPullRequests(ctx context.Context, branchName string) ([]domain.PullRequest, error) {
 	// TODO: If this is implemented with the GitHub v4 graphql api, it would be much faster
 
 	repos, err := g.getRepositories(ctx)
diff --git a/internal/scm/gitlab/gitlab.go b/internal/scm/gitlab/gitlab.go
index 3f6988a..cf70529 100644
--- a/internal/scm/gitlab/gitlab.go
+++ b/internal/scm/gitlab/gitlab.go
@@ -288,8 +288,8 @@ func (g *Gitlab) getUserIDs(ctx context.Context, usernames []string) ([]int, err
 	return userIDs, nil
 }
 
-// GetPullRequestStatuses gets the statuses of all pull requests of with a specific branch
-func (g *Gitlab) GetPullRequestStatuses(ctx context.Context, branchName string) ([]domain.PullRequest, error) {
+// GetPullRequests gets all pull requests of with a specific branch
+func (g *Gitlab) GetPullRequests(ctx context.Context, branchName string) ([]domain.PullRequest, error) {
 	projects, err := g.getProjects(ctx)
 	if err != nil {
 		return nil, err


Test patch:
diff --git a/tests/vcmock/vcmock.go b/tests/vcmock/vcmock.go
index 6fb0985..5d713bf 100644
--- a/tests/vcmock/vcmock.go
+++ b/tests/vcmock/vcmock.go
@@ -43,8 +43,8 @@ func (vc *VersionController) CreatePullRequest(ctx context.Context, repo domain.
 	return pr, nil
 }
 
-// GetPullRequestStatuses gets mock pull request statuses
-func (vc *VersionController) GetPullRequestStatuses(ctx context.Context, branchName string) ([]domain.PullRequest, error) {
+// GetPullRequests gets mock pull request statuses
+func (vc *VersionController) GetPullRequests(ctx context.Context, branchName string) ([]domain.PullRequest, error) {
 	ret := make([]domain.PullRequest, 0, len(vc.PullRequests))
 	for _, pr := range vc.PullRequests {
 		if pr.NewPullRequest.Head == branchName {