Skip to content
This repository has been archived by the owner on Sep 12, 2018. It is now read-only.

Commit

Permalink
2 reviewer bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Sung committed Jan 21, 2015
1 parent eb33152 commit 02c3929
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
9 changes: 5 additions & 4 deletions app/models/PullRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public class PullRequest extends Model implements ResourceConvertible {
joinColumns = @JoinColumn(name = "pull_request_id"),
inverseJoinColumns = @JoinColumn(name = "user_id")
)
public List<User> reviewers = new ArrayList<>();
public Set<User> reviewers = new HashSet<>();

@OneToMany(mappedBy = "pullRequest")
public List<CommentThread> commentThreads = new ArrayList<>();
Expand Down Expand Up @@ -999,7 +999,7 @@ public static void changeStateToClosed() {
}

public void clearReviewers() {
this.reviewers = new ArrayList<>();
this.reviewers = new HashSet<>();
this.update();
}

Expand All @@ -1008,8 +1008,9 @@ public int getRequiredReviewerCount() {
}

public void addReviewer(User user) {
this.reviewers.add(user);
this.update();
if(this.reviewers.add(user)) {
this.update();
}
}

public void removeReviewer(User user) {
Expand Down
20 changes: 20 additions & 0 deletions app/models/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -660,4 +660,24 @@ public void createOrganization(Organization organization) {
private void add(OrganizationUser ou) {
this.organizationUsers.add(ou);
}

@Override
public boolean equals(Object o) {
if(!(o instanceof User)) {
return false;
}
if(o == this) {
return true;
}
User user = (User) o;
return this.id.equals(user.id) && this.loginId.equals(user.loginId);
}

@Override
public int hashCode() {
int result = 31;
result = result * 37 + this.id.hashCode();
result = result * 37 + this.loginId.hashCode();
return result;
}
}

0 comments on commit 02c3929

Please sign in to comment.