diff --git a/README.md b/README.md index c59f109..2335eca 100644 --- a/README.md +++ b/README.md @@ -151,10 +151,9 @@ To test an unreleased change, download that artifact from the workflow run and add the extracted folder as a local repository. ### Manual Installation -1. Build the plugin using the instructions above -2. The built plugin will be in `org.eclipse.egit.pullrequest/target/` -3. Copy the JAR to your Eclipse `dropins/` folder -4. Restart Eclipse +Run `mvn clean verify`. The generated p2 repository is available at +`org.eclipse.egit.pullrequest.repository/target/repository`, and its archive is +`org.eclipse.egit.pullrequest.repository/target/org.eclipse.egit.pullrequest.repository-7.6.0-SNAPSHOT.zip`. ## Troubleshooting a connection diff --git a/org.eclipse.egit.pullrequest.repository/build.properties b/org.eclipse.egit.pullrequest.repository/build.properties new file mode 100644 index 0000000..432ad98 --- /dev/null +++ b/org.eclipse.egit.pullrequest.repository/build.properties @@ -0,0 +1 @@ +bin.includes = category.xml diff --git a/org.eclipse.egit.pullrequest.test/pom.xml b/org.eclipse.egit.pullrequest.test/pom.xml index 23a7272..c9d1d9a 100644 --- a/org.eclipse.egit.pullrequest.test/pom.xml +++ b/org.eclipse.egit.pullrequest.test/pom.xml @@ -47,6 +47,7 @@ org.eclipse.tycho tycho-surefire-plugin + ${tycho-version} @@ -57,15 +58,6 @@ false - - org.apache.maven.plugins - maven-pmd-plugin - - - **/*Test.java - - - diff --git a/org.eclipse.egit.pullrequest.test/src/org/eclipse/egit/pullrequest/internal/bitbucket/BitbucketClientTest.java b/org.eclipse.egit.pullrequest.test/src/org/eclipse/egit/pullrequest/internal/bitbucket/BitbucketClientTest.java index 69efc83..a48c676 100644 --- a/org.eclipse.egit.pullrequest.test/src/org/eclipse/egit/pullrequest/internal/bitbucket/BitbucketClientTest.java +++ b/org.eclipse.egit.pullrequest.test/src/org/eclipse/egit/pullrequest/internal/bitbucket/BitbucketClientTest.java @@ -149,7 +149,7 @@ public void testParseCommentWithAvatarUrl() { baseUrl); assertThat(comment, notNullValue()); - assertThat(comment.getAuthorName(), equalTo("John Doe")); //$NON-NLS-1$ + assertThat(comment.getAuthorDisplayName(), equalTo("John Doe")); //$NON-NLS-1$ assertThat(comment.getAuthorAvatarUrl(), equalTo( "https://bitbucket.example.com/users/jdoe/avatar.png")); //$NON-NLS-1$ } @@ -166,7 +166,7 @@ public void testParseCommentWithoutSlug() { baseUrl); assertThat(comment, notNullValue()); - assertThat(comment.getAuthorName(), equalTo("John Doe")); //$NON-NLS-1$ + assertThat(comment.getAuthorDisplayName(), equalTo("John Doe")); //$NON-NLS-1$ // When slug is missing, avatar URL should fall back to using name assertThat(comment.getAuthorAvatarUrl(), equalTo( "https://bitbucket.example.com/users/jdoe/avatar.png")); //$NON-NLS-1$ @@ -175,15 +175,14 @@ public void testParseCommentWithoutSlug() { @Test public void testParseCommentsArray() { String baseUrl = "https://bitbucket.example.com"; //$NON-NLS-1$ - String json = "{\"size\":2,\"limit\":25,\"isLastPage\":true," //$NON-NLS-1$ - + "\"values\":[" //$NON-NLS-1$ + String json = "[" //$NON-NLS-1$ + "{\"id\":1,\"version\":1,\"text\":\"First comment\"," //$NON-NLS-1$ + "\"author\":{\"name\":\"jdoe\",\"displayName\":\"John Doe\",\"slug\":\"jdoe\"}," //$NON-NLS-1$ + "\"createdDate\":1705318800000}," //$NON-NLS-1$ + "{\"id\":2,\"version\":1,\"text\":\"Second comment\"," //$NON-NLS-1$ + "\"author\":{\"name\":\"asmith\",\"displayName\":\"Alice Smith\",\"slug\":\"asmith\"}," //$NON-NLS-1$ + "\"createdDate\":1705319100000}" //$NON-NLS-1$ - + "]}"; //$NON-NLS-1$ + + "]"; //$NON-NLS-1$ List comments = BitbucketJsonParser .parseCommentArray(json, baseUrl); @@ -192,12 +191,13 @@ public void testParseCommentsArray() { assertThat(comments.size(), equalTo(2)); PullRequestComment first = comments.get(0); - assertThat(first.getAuthorName(), equalTo("John Doe")); //$NON-NLS-1$ + assertThat(first.getAuthorDisplayName(), equalTo("John Doe")); //$NON-NLS-1$ assertThat(first.getAuthorAvatarUrl(), equalTo( "https://bitbucket.example.com/users/jdoe/avatar.png")); //$NON-NLS-1$ PullRequestComment second = comments.get(1); - assertThat(second.getAuthorName(), equalTo("Alice Smith")); //$NON-NLS-1$ + assertThat(second.getAuthorDisplayName(), + equalTo("Alice Smith")); //$NON-NLS-1$ assertThat(second.getAuthorAvatarUrl(), equalTo( "https://bitbucket.example.com/users/asmith/avatar.png")); //$NON-NLS-1$ } diff --git a/org.eclipse.egit.pullrequest.test/src/org/eclipse/egit/pullrequest/internal/github/GitHubJsonParserTest.java b/org.eclipse.egit.pullrequest.test/src/org/eclipse/egit/pullrequest/internal/github/GitHubJsonParserTest.java index 2d4367e..340f98c 100644 --- a/org.eclipse.egit.pullrequest.test/src/org/eclipse/egit/pullrequest/internal/github/GitHubJsonParserTest.java +++ b/org.eclipse.egit.pullrequest.test/src/org/eclipse/egit/pullrequest/internal/github/GitHubJsonParserTest.java @@ -646,7 +646,7 @@ public void testParseCommit() { assertThat(commit.getFirstLine(), equalTo("Fix bug in parser")); //$NON-NLS-1$ assertThat(commit.getAuthorName(), equalTo("John Doe")); //$NON-NLS-1$ assertThat(commit.getAuthorEmail(), equalTo("john@example.com")); //$NON-NLS-1$ - assertThat(commit.getAuthorDate(), equalTo(1736937000000L)); + assertThat(commit.getAuthorDate(), equalTo(1768473000000L)); assertThat(commit.getParents(), hasSize(2)); assertThat(commit.getParents().get(0), equalTo("parent1")); //$NON-NLS-1$ assertThat(commit.getParents().get(1), equalTo("parent2")); //$NON-NLS-1$ @@ -661,7 +661,7 @@ public void testParseCommitMultilineMessage() { assertThat(commit, notNullValue()); assertThat(commit.getMessage(), - equalTo("First line\\n\\nDetailed description\\non multiple lines")); //$NON-NLS-1$ + equalTo("First line\n\nDetailed description\non multiple lines")); //$NON-NLS-1$ assertThat(commit.getFirstLine(), equalTo("First line")); //$NON-NLS-1$ assertThat(commit.getParents(), hasSize(1)); assertThat(commit.isMergeCommit(), equalTo(false)); diff --git a/org.eclipse.egit.pullrequest/META-INF/MANIFEST.MF b/org.eclipse.egit.pullrequest/META-INF/MANIFEST.MF index 7a1cb86..94a2882 100644 --- a/org.eclipse.egit.pullrequest/META-INF/MANIFEST.MF +++ b/org.eclipse.egit.pullrequest/META-INF/MANIFEST.MF @@ -22,8 +22,8 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.20.0,4.0.0)", org.eclipse.ui.ide;bundle-version="[3.10.0,4.0.0)", org.eclipse.team.core;bundle-version="[3.8.0,4.0.0)", org.eclipse.team.ui;bundle-version="[3.8.0,4.0.0)", - org.eclipse.jdt.core;bundle-version="[3.42.0,4.0.0)";resolution:=optional, - org.eclipse.jdt.ui;bundle-version="[3.35.0,4.0.0)";resolution:=optional + org.eclipse.jdt.core;bundle-version="[3.40.0,4.0.0)";resolution:=optional, + org.eclipse.jdt.ui;bundle-version="[3.33.0,4.0.0)";resolution:=optional Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-21 Import-Package: org.eclipse.core.resources.mapping, diff --git a/org.eclipse.egit.pullrequest/plugin.xml b/org.eclipse.egit.pullrequest/plugin.xml index f3f4fec..aeaf542 100644 --- a/org.eclipse.egit.pullrequest/plugin.xml +++ b/org.eclipse.egit.pullrequest/plugin.xml @@ -15,7 +15,6 @@ diff --git a/org.eclipse.egit.pullrequest/pom.xml b/org.eclipse.egit.pullrequest/pom.xml index 433142f..0d9270b 100644 --- a/org.eclipse.egit.pullrequest/pom.xml +++ b/org.eclipse.egit.pullrequest/pom.xml @@ -31,6 +31,7 @@ org.eclipse.tycho tycho-source-plugin + ${tycho-version} diff --git a/org.eclipse.egit.pullrequest/src/org/eclipse/egit/pullrequest/internal/github/GitHubJsonParser.java b/org.eclipse.egit.pullrequest/src/org/eclipse/egit/pullrequest/internal/github/GitHubJsonParser.java index b265c66..ac0759b 100644 --- a/org.eclipse.egit.pullrequest/src/org/eclipse/egit/pullrequest/internal/github/GitHubJsonParser.java +++ b/org.eclipse.egit.pullrequest/src/org/eclipse/egit/pullrequest/internal/github/GitHubJsonParser.java @@ -175,15 +175,20 @@ private static PullRequest parseSinglePullRequestObject(String json) { int reviewComments = extractInt(json, "review_comments"); //$NON-NLS-1$ pr.setCommentCount(issueComments + reviewComments); - // Parse reviewers (requested_reviewers) + // Parse individual and team reviewers + List reviewers = new ArrayList<>(); String requestedReviewersJson = extractArray(json, "requested_reviewers"); //$NON-NLS-1$ if (requestedReviewersJson != null) { - List reviewers = parseReviewers( - requestedReviewersJson); - if (!reviewers.isEmpty()) { - pr.setReviewers(reviewers); - } + reviewers.addAll(parseReviewers(requestedReviewersJson)); + } + String requestedTeamsJson = extractArray(json, + "requested_teams"); //$NON-NLS-1$ + if (requestedTeamsJson != null) { + reviewers.addAll(parseReviewers(requestedTeamsJson)); + } + if (!reviewers.isEmpty()) { + pr.setReviewers(reviewers); } // Parse links @@ -1104,9 +1109,10 @@ private static PullRequest.PullRequestParticipant parseReviewer( PullRequest.User user = new PullRequest.User(); user.setName(extractString(json, "login")); //$NON-NLS-1$ - // For teams, use slug as name + // For teams, use slug as name. GitHub's requested_teams payload does + // not always include a type field. String type = extractString(json, "type"); //$NON-NLS-1$ - if ("Team".equals(type)) { //$NON-NLS-1$ + if ("Team".equals(type) || user.getName() == null) { //$NON-NLS-1$ String slug = extractString(json, "slug"); //$NON-NLS-1$ if (slug != null) { user.setName(slug); @@ -1115,6 +1121,7 @@ private static PullRequest.PullRequestParticipant parseReviewer( user.setDisplayName(extractString(json, "name", //$NON-NLS-1$ extractString(json, "login"))); //$NON-NLS-1$ + user.setEmailAddress(extractString(json, "email")); //$NON-NLS-1$ user.setAvatarUrl(extractString(json, "avatar_url")); //$NON-NLS-1$ reviewer.setUser(user); reviewer.setRole("REVIEWER"); //$NON-NLS-1$