Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Sawicki2011-09-07 19:24:51 +0000
committerKevin Sawicki2011-09-07 21:49:19 +0000
commit7ec547072cd2fdd50dd7ec313a8943a186213c85 (patch)
tree4c2ae07761bfbe8dfe1e1bcef86ea3532ff99ccf /org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github
parenta0735da70ea400ae681136f780f776202fafd266 (diff)
downloadegit-github-7ec547072cd2fdd50dd7ec313a8943a186213c85.tar.gz
egit-github-7ec547072cd2fdd50dd7ec313a8943a186213c85.tar.xz
egit-github-7ec547072cd2fdd50dd7ec313a8943a186213c85.zip
Only allow collaborators or reporter to update pull requests
Change-Id: I72c059dc4834e6b066adac3ff761efb504d2513d Signed-off-by: Kevin Sawicki <kevin@github.com>
Diffstat (limited to 'org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github')
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/pr/PullRequestTaskDataHandler.java41
1 files changed, 23 insertions, 18 deletions
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/pr/PullRequestTaskDataHandler.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/pr/PullRequestTaskDataHandler.java
index d7f24620..a0dd2fa7 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/pr/PullRequestTaskDataHandler.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/pr/PullRequestTaskDataHandler.java
@@ -186,6 +186,7 @@ public class PullRequestTaskDataHandler extends GitHubTaskDataHandler {
.getRepositoryUrl());
try {
GitHubClient client = IssueConnector.createClient(repository);
+ boolean collaborator = isCollaborator(client, repo);
PullRequestService prService = new PullRequestService(client);
IssueService issueService = new IssueService(client);
if (taskData.isNew()) {
@@ -200,25 +201,29 @@ public class PullRequestTaskDataHandler extends GitHubTaskDataHandler {
issueService.createComment(repo.getOwner(), repo.getName(),
taskId, comment);
- // Handle state change
- TaskAttribute operationAttribute = taskData.getRoot()
- .getAttribute(TaskAttribute.OPERATION);
- if (operationAttribute != null) {
- PullRequestOperation operation = PullRequestOperation
- .fromId(operationAttribute.getValue());
- if (operation != PullRequestOperation.LEAVE)
- switch (operation) {
- case REOPEN:
- pr.setState(IssueService.STATE_OPEN);
- break;
- case CLOSE:
- pr.setState(IssueService.STATE_CLOSED);
- break;
- default:
- break;
- }
+ boolean reporter = attributeMatchesUser(client,
+ PullRequestAttribute.REPORTER.getMetadata(), taskData);
+ if (collaborator || reporter) {
+ // Handle state change
+ TaskAttribute operationAttribute = taskData.getRoot()
+ .getAttribute(TaskAttribute.OPERATION);
+ if (operationAttribute != null) {
+ PullRequestOperation operation = PullRequestOperation
+ .fromId(operationAttribute.getValue());
+ if (operation != PullRequestOperation.LEAVE)
+ switch (operation) {
+ case REOPEN:
+ pr.setState(IssueService.STATE_OPEN);
+ break;
+ case CLOSE:
+ pr.setState(IssueService.STATE_CLOSED);
+ break;
+ default:
+ break;
+ }
+ }
+ prService.editPullRequest(repo, pr);
}
- prService.editPullRequest(repo, pr);
}
return new RepositoryResponse(
taskData.isNew() ? ResponseKind.TASK_CREATED

Back to the top