Repository: jenkins-x/lighthouse
Pull request #1132 (2020-10-27 08:34:02)

fix: use assign PR in plugins when working with PR instead of assign issue

jenkins-x-bot: Hi @yelhouti. Thanks for your PR.

I'm waiting for a [jenkins-x](https://github.com/orgs/jenkins-x/people) member to verify that this patch is reasonable to test. If it is, they should reply with `/ok-to-test` on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should [join the org](https://github.com/orgs/jenkins-x/people) to skip this step.

Once the patch is verified, the new status will be reflected by the `ok-to-test` label.

I understand the commands that are listed [here](https://go.k8s.io/bot-commands?repo=jenkins-x%2Flighthouse).

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [jenkins-x/lighthouse](https://github.com/jenkins-x/lighthouse/issues/new?title=Command%20issue:) repository.
</details>

jenkins-x-bot: [APPROVALNOTIFIER] This PR is **NOT APPROVED**

This pull-request has been approved by:
To complete the [pull request process](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process), please assign **pmuir**
You can assign the PR to them by writing `/assign @pmuir` in a comment when ready.

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=jenkins-x%2Flighthouse).

<details open>
Needs approval from an approver in each of these files:

- **[OWNERS](https://github.com/jenkins-x/lighthouse/blob/master/OWNERS)**

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":["pmuir"]} -->
yelhouti: /assign jstrachan
jstrachan: /ok-to-test
jstrachan: /lgtm
jenkins-x-bot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *[jstrachan](https://github.com/jenkins-x/lighthouse/pull/1132#issuecomment-717081234 "LGTM")*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=jenkins-x%2Flighthouse).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com#issuecomment-717081234/jenkins-x/lighthouse/blob/master/OWNERS)~~ [jstrachan]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->
jenkins-x-bot: @yelhouti: The following test **failed**, say `/retest` to rerun them all:

Test name | Commit | Details | Rerun command
--- | --- | --- | ---
pr-build | 88e663c6cfc962b8b01541a35290084025a4a5cf | [link](https://dashboard-jx.jenkins-x.live/teams/jx/projects/jenkins-x/lighthouse/PR-1132/2) | `/test pr-build`

[View all Builds for this Pull Request](https://dashboard-jx.jenkins-x.live/teams/jx/projects/jenkins-x/lighthouse/PR-1132) 

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [jenkins-x/lighthouse](https://github.com/jenkins-x/lighthouse/issues/new?title=Command%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
jenkins-x-bot: @yelhouti: The following tests **failed**, say `/retest` to rerun them all:

Test name | Commit | Details | Rerun command
--- | --- | --- | ---
pr-build | 88e663c6cfc962b8b01541a35290084025a4a5cf | [link](https://dashboard-jx.jenkins-x.live/teams/jx/projects/jenkins-x/lighthouse/PR-1132/2) | `/test pr-build`
jenkins | 88e663c6cfc962b8b01541a35290084025a4a5cf | [link](https://dashboard-jx.jenkins-x.live/teams/jx/projects/jenkins-x/lighthouse/PR-1132/4) | `/test jenkins`

[View all Builds for this Pull Request](https://dashboard-jx.jenkins-x.live/teams/jx/projects/jenkins-x/lighthouse/PR-1132) 

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [jenkins-x/lighthouse](https://github.com/jenkins-x/lighthouse/issues/new?title=Command%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
jstrachan: @yelhouti looks like `make vet` fails...
```
vet: pkg/plugins/assign/assign_test.go:428:75: cannot use fc (variable of type *fakeClient) as scmProviderClient value in argument to newAssignHandler: missing method AssignPR
```
jenkins-x-bot: New changes are detected. LGTM label has been removed.
jenkins-x-bot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *[jstrachan](https://github.com/jenkins-x/lighthouse/pull/1132#issuecomment-717081234 "LGTM")*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=jenkins-x%2Flighthouse).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/jenkins-x/lighthouse/blob/master/OWNERS)~~ [jstrachan]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->
yelhouti: last test failing is because of:
https://github.com/jenkins-x/go-scm/pull/203
please merge this and rebase my PR for this test to pass
jenkins-x-bot: @yelhouti: The following tests **failed**, say `/retest` to rerun them all:

Test name | Commit | Details | Rerun command
--- | --- | --- | ---
jenkins | 88e663c6cfc962b8b01541a35290084025a4a5cf | [link](https://dashboard-jx.jenkins-x.live/teams/jx/projects/jenkins-x/lighthouse/PR-1132/4) | `/test jenkins`
pr-build | 7273f9f0fffd79a17c429f3b3bf9cab47cde2e20 | [link](https://dashboard-jx.jenkins-x.live/teams/jx/projects/jenkins-x/lighthouse/PR-1132/6) | `/test pr-build`

[View all Builds for this Pull Request](https://dashboard-jx.jenkins-x.live/teams/jx/projects/jenkins-x/lighthouse/PR-1132) 

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [jenkins-x/lighthouse](https://github.com/jenkins-x/lighthouse/issues/new?title=Command%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
jenkins-x-bot: @yelhouti: The following tests **failed**, say `/retest` to rerun them all:

Test name | Commit | Details | Rerun command
--- | --- | --- | ---
jenkins | 88e663c6cfc962b8b01541a35290084025a4a5cf | [link](https://dashboard-jx.jenkins-x.live/teams/jx/projects/jenkins-x/lighthouse/PR-1132/4) | `/test jenkins`
pr-build | 7273f9f0fffd79a17c429f3b3bf9cab47cde2e20 | [link](https://dashboard-jx.jenkins-x.live/teams/jx/projects/jenkins-x/lighthouse/PR-1132/6) | `/test pr-build`
tekton | 7273f9f0fffd79a17c429f3b3bf9cab47cde2e20 | [link](https://dashboard-jx.jenkins-x.live/teams/jx/projects/jenkins-x/lighthouse/PR-1132/10) | `/test tekton`

[View all Builds for this Pull Request](https://dashboard-jx.jenkins-x.live/teams/jx/projects/jenkins-x/lighthouse/PR-1132) 

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [jenkins-x/lighthouse](https://github.com/jenkins-x/lighthouse/issues/new?title=Command%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
jstrachan: /retest
jenkins-x-bot: @yelhouti: The following tests **failed**, say `/retest` to rerun them all:

Test name | Commit | Details | Rerun command
--- | --- | --- | ---
tekton | 7273f9f0fffd79a17c429f3b3bf9cab47cde2e20 | [link](https://dashboard-jx.jenkins-x.live/teams/jx/projects/jenkins-x/lighthouse/PR-1132/10) | `/test tekton`
pr-build | 7273f9f0fffd79a17c429f3b3bf9cab47cde2e20 | [link](https://dashboard-jx.jenkins-x.live/teams/jx/projects/jenkins-x/lighthouse/PR-1132/11) | `/test pr-build`

[View all Builds for this Pull Request](https://dashboard-jx.jenkins-x.live/teams/jx/projects/jenkins-x/lighthouse/PR-1132) 

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [jenkins-x/lighthouse](https://github.com/jenkins-x/lighthouse/issues/new?title=Command%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->

Patch:
diff --git a/dependency-matrix/matrix.md b/dependency-matrix/matrix.md
index 4ab65533..76328a4a 100644
--- a/dependency-matrix/matrix.md
+++ b/dependency-matrix/matrix.md
@@ -2,4 +2,4 @@
 
 Dependency | Sources | Version | Mismatched versions
 ---------- | ------- | ------- | -------------------
-[jenkins-x/go-scm](https://github.com/jenkins-x/go-scm) |  | [1.5.189]() | 
+[jenkins-x/go-scm](https://github.com/jenkins-x/go-scm) |  | [1.5.190]() | 
diff --git a/dependency-matrix/matrix.yaml b/dependency-matrix/matrix.yaml
index 811871bf..c021478a 100644
--- a/dependency-matrix/matrix.yaml
+++ b/dependency-matrix/matrix.yaml
@@ -3,5 +3,5 @@ dependencies:
   owner: jenkins-x
   repo: go-scm
   url: https://github.com/jenkins-x/go-scm
-  version: 1.5.189
+  version: 1.5.190
   versionURL: ""
diff --git a/go.mod b/go.mod
index c19280d2..d56d1513 100644
--- a/go.mod
+++ b/go.mod
@@ -10,7 +10,7 @@ require (
 	github.com/google/go-cmp v0.4.1
 	github.com/gorilla/sessions v1.2.0
 	github.com/hashicorp/go-multierror v1.1.0
-	github.com/jenkins-x/go-scm v1.5.189
+	github.com/jenkins-x/go-scm v1.5.190
 	github.com/mattn/go-zglob v0.0.1
 	github.com/onsi/ginkgo v1.11.0
 	github.com/onsi/gomega v1.8.1
diff --git a/go.sum b/go.sum
index fbe40c6d..7c6f2887 100644
--- a/go.sum
+++ b/go.sum
@@ -596,8 +596,8 @@ github.com/jcmturner/gofork v1.0.0/go.mod h1:MK8+TM0La+2rjBD4jE12Kj1pCCxK7d2LK/U
 github.com/jenkins-x/go-scm v1.5.65/go.mod h1:MgGRkJScE/rJ30J/bXYqduN5sDPZqZFITJopsnZmTOw=
 github.com/jenkins-x/go-scm v1.5.79/go.mod h1:PCT338UhP/pQ0IeEeMEf/hoLTYKcH7qjGEKd7jPkeYg=
 github.com/jenkins-x/go-scm v1.5.117/go.mod h1:PCT338UhP/pQ0IeEeMEf/hoLTYKcH7qjGEKd7jPkeYg=
-github.com/jenkins-x/go-scm v1.5.189 h1:WQc3bUSsOTR1b8KBi4CPaU50HiApWRYBCJITOdikKdM=
-github.com/jenkins-x/go-scm v1.5.189/go.mod h1:pTp8HHrCEVGs24H/8Cy+X/CDXFlKv9VC6zmrXBYNkfE=
+github.com/jenkins-x/go-scm v1.5.190 h1:fJKQJmn+WsIcojwFQEorpb7JXFxVJeaYY8y+4lbyweU=
+github.com/jenkins-x/go-scm v1.5.190/go.mod h1:pTp8HHrCEVGs24H/8Cy+X/CDXFlKv9VC6zmrXBYNkfE=
 github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
 github.com/jinzhu/gorm v0.0.0-20170316141641-572d0a0ab1eb/go.mod h1:Vla75njaFJ8clLU1W44h34PjIkijhjHIYnZxMqCdxqo=
 github.com/jinzhu/gorm v1.9.12/go.mod h1:vhTjlKSJUTWNtcbQtrMBFCxy7eXTzeCAzfL5fBZT/Qs=
diff --git a/pkg/plugins/assign/assign.go b/pkg/plugins/assign/assign.go
index adcc18ba..6614ca92 100644
--- a/pkg/plugins/assign/assign.go
+++ b/pkg/plugins/assign/assign.go
@@ -55,8 +55,8 @@ func init() {
 }
 
 type scmProviderClient interface {
-	AssignIssue(owner, repo string, number int, logins []string) error
-	UnassignIssue(owner, repo string, number int, logins []string) error
+	AssignPR(owner, repo string, number int, logins []string) error
+	UnassignPR(owner, repo string, number int, logins []string) error
 
 	RequestReview(org, repo string, number int, logins []string) error
 	UnrequestReview(org, repo string, number int, logins []string) error
@@ -180,8 +180,8 @@ func newAssignHandler(e scmprovider.GenericCommentEvent, spc scmProviderClient,
 
 	return &handler{
 		addFailureResponse: addFailureResponse,
-		remove:             spc.UnassignIssue,
-		add:                spc.AssignIssue,
+		remove:             spc.UnassignPR,
+		add:                spc.AssignPR,
 		event:              &e,
 		command:            "assign",
 		spc:                spc,
diff --git a/pkg/plugins/lgtm/lgtm.go b/pkg/plugins/lgtm/lgtm.go
index 0d51582c..9563849e 100644
--- a/pkg/plugins/lgtm/lgtm.go
+++ b/pkg/plugins/lgtm/lgtm.go
@@ -146,7 +146,7 @@ func optionsForRepo(config *plugins.Configuration, org, repo string) *plugins.Lg
 type scmProviderClient interface {
 	IsCollaborator(owner, repo, login string) (bool, error)
 	AddLabel(owner, repo string, number int, label string, pr bool) error
-	AssignIssue(owner, repo string, number int, assignees []string) error
+	AssignPR(owner, repo string, number int, assignees []string) error
 	CreateComment(owner, repo string, number int, pr bool, comment string) error
 	RemoveLabel(owner, repo string, number int, label string, pr bool) error
 	GetIssueLabels(org, repo string, number int, pr bool) ([]*scm.Label, error)
@@ -302,7 +302,7 @@ func handle(wantLGTM bool, config *plugins.Configuration, ownersClient repoowner
 		// in this case we need to ensure the commentor is assignable to the PR
 		// by assigning them
 		log.Infof("Assigning %s/%s#%d to %s", org, repoName, number, author)
-		if err := spc.AssignIssue(org, repoName, number, []string{author}); err != nil {
+		if err := spc.AssignPR(org, repoName, number, []string{author}); err != nil {
 			log.WithError(err).Errorf("Failed to assign %s/%s#%d to %s", org, repoName, number, author)
 		}
 	} else if !isAuthor && skipCollaborators {
diff --git a/pkg/scmprovider/pull_requests.go b/pkg/scmprovider/pull_requests.go
index 37d83c5d..2da2e6d1 100644
--- a/pkg/scmprovider/pull_requests.go
+++ b/pkg/scmprovider/pull_requests.go
@@ -217,3 +217,19 @@ func (c *Client) FindPullRequestsByAuthor(owner, repo string, author string) ([]
 	}
 	return allPullRequests, err
 }
+
+// AssignPR assigns pr
+func (c *Client) AssignPR(owner, repo string, number int, logins []string) error {
+	ctx := context.Background()
+	fullName := c.repositoryName(owner, repo)
+	_, err := c.client.PullRequests.AssignIssue(ctx, fullName, number, logins)
+	return err
+}
+
+// UnassignPR unassigns pr
+func (c *Client) UnassignPR(owner, repo string, number int, logins []string) error {
+	ctx := context.Background()
+	fullName := c.repositoryName(owner, repo)
+	_, err := c.client.PullRequests.UnassignIssue(ctx, fullName, number, logins)
+	return err
+}


Test patch:
diff --git a/pkg/plugins/assign/assign_test.go b/pkg/plugins/assign/assign_test.go
index 2e0ae610..547cc56f 100644
--- a/pkg/plugins/assign/assign_test.go
+++ b/pkg/plugins/assign/assign_test.go
@@ -36,7 +36,7 @@ type fakeClient struct {
 	commented bool
 }
 
-func (c *fakeClient) UnassignIssue(owner, repo string, number int, assignees []string) error {
+func (c *fakeClient) UnassignPR(owner, repo string, number int, assignees []string) error {
 	for _, who := range assignees {
 		c.unassigned[who]++
 	}
@@ -44,7 +44,7 @@ func (c *fakeClient) UnassignIssue(owner, repo string, number int, assignees []s
 	return nil
 }
 
-func (c *fakeClient) AssignIssue(owner, repo string, number int, assignees []string) error {
+func (c *fakeClient) AssignPR(owner, repo string, number int, assignees []string) error {
 	var missing scmprovider.MissingUsers
 	sort.Strings(assignees)
 	if len(assignees) > 10 {