-
-
Notifications
You must be signed in to change notification settings - Fork 534
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add PR Decoration Support for Azure DevOps Server
fixing space in url fix PR URL SonarCloud fixes
- Loading branch information
Jeff Boccuzzi
committed
Jul 27, 2020
1 parent
f624269
commit 335bc66
Showing
25 changed files
with
1,811 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,7 @@ | |
*.iml | ||
|
||
#Project libs | ||
/sonarqube-lib/ | ||
/sonarqube-lib/ | ||
|
||
#VSCode | ||
.project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
385 changes: 385 additions & 0 deletions
385
...ke/sonarqube/plugin/ce/pullrequest/azuredevops/AzureDevOpsServerPullRequestDecorator.java
Large diffs are not rendered by default.
Oops, something went wrong.
66 changes: 66 additions & 0 deletions
66
...ub/mc1arke/sonarqube/plugin/ce/pullrequest/azuredevops/model/AzurePullRequestDetails.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package com.github.mc1arke.sonarqube.plugin.ce.pullrequest.azuredevops.model; | ||
|
||
import java.util.Base64; | ||
import java.nio.charset.StandardCharsets; | ||
|
||
public class AzurePullRequestDetails { | ||
|
||
public static final String API_VERSION_PREFIX = "?api-version="; | ||
private final String apiVersion; | ||
private final String authorizationHeader; | ||
private final String azureRepositoryName; | ||
private final String azureProjectId; | ||
private final String azureUrl; | ||
private final String baseBranch; | ||
private final String branch; | ||
private final String pullRequestId; | ||
|
||
public AzurePullRequestDetails(String apiVersion, String azureRepositoryName, String azureProjectId, String azureUrl, | ||
String baseBranch, String branch, String personalAccessToken, String pullRequestId) { | ||
this.apiVersion = apiVersion; | ||
this.authorizationHeader = generateAuthorizationHeader(personalAccessToken); | ||
this.azureRepositoryName = azureRepositoryName; | ||
this.azureProjectId = azureProjectId; | ||
this.azureUrl = azureUrl; | ||
this.baseBranch = baseBranch; | ||
this.branch = branch; | ||
this.pullRequestId = pullRequestId; | ||
} | ||
|
||
private static String generateAuthorizationHeader(String apiToken) { | ||
String encodeBytes = Base64.getEncoder().encodeToString((":" + apiToken).getBytes(StandardCharsets.UTF_8)); | ||
return "Basic " + encodeBytes; | ||
} | ||
|
||
public String getApiVersion() { | ||
return API_VERSION_PREFIX + this.apiVersion; | ||
} | ||
|
||
public String getAuthorizationHeader() { | ||
return this.authorizationHeader; | ||
} | ||
|
||
public String getAzureRepositoryName() { | ||
return this.azureRepositoryName; | ||
} | ||
|
||
public String getAzureProjectId() { | ||
return this.azureProjectId; | ||
} | ||
|
||
public String getAzureUrl() { | ||
return this.azureUrl; | ||
} | ||
|
||
public String getBaseBranch() { | ||
return this.baseBranch; | ||
} | ||
|
||
public String getBranch() { | ||
return this.branch; | ||
} | ||
|
||
public String getPullRequestId() { | ||
return this.pullRequestId; | ||
} | ||
} |
160 changes: 160 additions & 0 deletions
160
...in/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/azuredevops/model/Comment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
package com.github.mc1arke.sonarqube.plugin.ce.pullrequest.azuredevops.model; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.github.mc1arke.sonarqube.plugin.ce.pullrequest.azuredevops.model.enums.CommentType; | ||
|
||
import java.io.Serializable; | ||
import java.util.Date; | ||
import java.util.List; | ||
|
||
|
||
/** | ||
* Represents a comment which is one of potentially many in a comment thread. | ||
*/ | ||
public class Comment implements Serializable { | ||
|
||
private final String content; | ||
private final CommentType commentType; | ||
private final Integer parentCommentId; | ||
private final int id; | ||
private final int threadId; | ||
private final IdentityRef author; | ||
private final Date publishedDate; | ||
private final Date lastUpdatedDate; | ||
private final Date lastContentUpdatedDate; | ||
@JsonProperty("isDeleted") | ||
private final boolean deleted; | ||
private final List<IdentityRef> usersLiked; | ||
@JsonProperty("_links") | ||
private final ReferenceLinks links; | ||
|
||
@JsonCreator | ||
public Comment(@JsonProperty("content") String content, | ||
@JsonProperty("commentType") CommentType commentType, | ||
@JsonProperty("parentCommentId") Integer parentCommentId, | ||
@JsonProperty("id") int id, | ||
@JsonProperty("threadId") int threadId, | ||
@JsonProperty("author") IdentityRef author, | ||
@JsonProperty("publishedDate") Date publishedDate, | ||
@JsonProperty("lastUpdatedDate") Date lastUpdatedDate, | ||
@JsonProperty("lastContentUpdatedDate") Date lastContentUpdatedDate, | ||
@JsonProperty("isDeleted") boolean deleted, | ||
@JsonProperty("usersLiked") List<IdentityRef> usersLiked, | ||
@JsonProperty("_links") ReferenceLinks links) { | ||
|
||
this.content = content; | ||
this.commentType = commentType; | ||
this.parentCommentId = parentCommentId; | ||
this.id = id; | ||
this.threadId = threadId; | ||
this.author = author; | ||
this.publishedDate = publishedDate; | ||
this.lastUpdatedDate = lastUpdatedDate; | ||
this.lastContentUpdatedDate = lastContentUpdatedDate; | ||
this.deleted = deleted; | ||
this.usersLiked = usersLiked; | ||
this.links = links; | ||
} | ||
|
||
public Comment(String content) { | ||
this.content = content; | ||
this.parentCommentId = 0; | ||
this.commentType = CommentType.TEXT; | ||
|
||
this.id = 0; | ||
this.threadId = 0; | ||
this.author = null; | ||
this.publishedDate = null; | ||
this.lastUpdatedDate = null; | ||
this.lastContentUpdatedDate = null; | ||
this.deleted = false; | ||
this.usersLiked = null; | ||
this.links = null; | ||
} | ||
|
||
/** | ||
* The ID of the parent comment. This is used for replies. | ||
*/ | ||
public Integer getParentCommentId() { | ||
return this.parentCommentId; | ||
} | ||
|
||
/** | ||
* The comment content. | ||
*/ | ||
public String getContent() { | ||
return this.content; | ||
} | ||
|
||
/** | ||
* The comment type at the time of creation. | ||
*/ | ||
public CommentType getCommentType() { | ||
return this.commentType; | ||
} | ||
|
||
/** | ||
* The comment ID. IDs start at 1 and are unique to a pull request. | ||
*/ | ||
public int getId() { | ||
return this.id; | ||
} | ||
|
||
/** | ||
* The parent thread ID. Used for internal server purposes only -- note | ||
* that this field is not exposed to the REST client. | ||
*/ | ||
public int getThreadId() { | ||
return this.threadId; | ||
} | ||
|
||
/** | ||
* The author of the comment. | ||
*/ | ||
public IdentityRef getAuthor() { | ||
return this.author; | ||
} | ||
|
||
/** | ||
* The date the comment was first published.; | ||
*/ | ||
public Date getPublishedDate() { | ||
return this.publishedDate; | ||
} | ||
|
||
/** | ||
* The date the comment was last updated. | ||
*/ | ||
public Date getLastUpdatedDate() { | ||
return this.lastUpdatedDate; | ||
} | ||
|
||
/** | ||
* The date the comment's content was last updated. | ||
*/ | ||
public Date getLastContentUpdatedDate() { | ||
return this.lastContentUpdatedDate; | ||
} | ||
|
||
/** | ||
* Whether or not this comment was soft-deleted. | ||
*/ | ||
public boolean isDeleted() { | ||
return this.deleted; | ||
} | ||
|
||
/** | ||
* A list of the users who have liked this comment. | ||
*/ | ||
public List<IdentityRef> getUsersLiked() { | ||
return this.usersLiked; | ||
} | ||
|
||
/** | ||
* Links to other related objects. | ||
*/ | ||
public ReferenceLinks getLinks() { | ||
return this.links; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...com/github/mc1arke/sonarqube/plugin/ce/pullrequest/azuredevops/model/CommentPosition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.github.mc1arke.sonarqube.plugin.ce.pullrequest.azuredevops.model; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import java.io.Serializable; | ||
|
||
public class CommentPosition implements Serializable { | ||
|
||
private final int line; | ||
private final int offset; | ||
|
||
@JsonCreator | ||
public CommentPosition(@JsonProperty("line") int line, @JsonProperty("offset") int offset){ | ||
this.line = line; | ||
this.offset = offset + 1; | ||
} | ||
|
||
/** | ||
*The line number of a thread's position. Starts at 1. /// | ||
*/ | ||
public int getLine() { | ||
return this.line; | ||
} | ||
|
||
/** | ||
*The character offset of a thread's position inside of a line. Starts at 0. | ||
*/ | ||
public int getOffset() { | ||
return this.offset; | ||
} | ||
} |
Oops, something went wrong.