Skip to content

Commit

Permalink
Enabling commenting only changed parts of files #27
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbjerre committed Nov 1, 2016
1 parent 9c284a3 commit fcfe5cd
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 104 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ Changelog of Violation Comments to Bitbucket Server Plugin.
## Unreleased
### No issue

**Optionally let only changed lines to be commented**


[9c284a3635144d7](https://github.com/jenkinsci/violation-comments-to-stash-plugin/commit/9c284a3635144d7) Tomas Bjerre *2016-10-31 21:19:34*


## 1.33
### No issue

**Markdown in comments and not commenting unchanged files**


Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ job('example') {
usernamePasswordCredentialsId(null)
useUsernamePasswordCredentials(false)
useUsernamePassword(true)
createCommentWithAllSingleFileComments(true)
commentOnlyChangedContent(true)
violationConfigs {
violationConfig {
reporter("FINDBUGS")
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ Changelog of Violation Comments to Bitbucket Server Plugin.
<dependency>
<groupId>se.bjurr.violations</groupId>
<artifactId>violation-comments-to-bitbucket-server-lib</artifactId>
<version>1.12</version>
<version>1.13</version>
</dependency>

<!-- test // -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jenkinsci.plugins.jvctb;

import static org.jenkinsci.plugins.jvctb.config.ViolationsToBitbucketServerConfigHelper.FIELD_BITBUCKETSERVERURL;
import static org.jenkinsci.plugins.jvctb.config.ViolationsToBitbucketServerConfigHelper.FIELD_COMMENTONLYCHANGEDCONTENT;
import static org.jenkinsci.plugins.jvctb.config.ViolationsToBitbucketServerConfigHelper.FIELD_CREATECOMMENTWITHALLSINGLEFILECOMMENTS;
import static org.jenkinsci.plugins.jvctb.config.ViolationsToBitbucketServerConfigHelper.FIELD_CREATESINGLEFILECOMMENTS;
import static org.jenkinsci.plugins.jvctb.config.ViolationsToBitbucketServerConfigHelper.FIELD_PASSWORD;
Expand All @@ -13,27 +14,27 @@
import static org.jenkinsci.plugins.jvctb.config.ViolationsToBitbucketServerConfigHelper.FIELD_USEUSERNAMEPASSWORD;
import static org.jenkinsci.plugins.jvctb.config.ViolationsToBitbucketServerConfigHelper.FIELD_USEUSERNAMEPASSWORDCREDENTIALS;
import static org.jenkinsci.plugins.jvctb.config.ViolationsToBitbucketServerConfigHelper.createNewConfig;
import hudson.model.AbstractProject;
import hudson.tasks.BuildStepDescriptor;
import hudson.tasks.Publisher;
import hudson.util.ListBoxModel;

import java.util.List;

import net.sf.json.JSONObject;

import org.jenkinsci.plugins.jvctb.config.CredentialsHelper;
import org.jenkinsci.plugins.jvctb.config.ViolationsToBitbucketServerConfig;
import org.kohsuke.stapler.StaplerRequest;

import hudson.model.AbstractProject;
import hudson.tasks.BuildStepDescriptor;
import hudson.tasks.Publisher;
import hudson.util.ListBoxModel;
import net.sf.json.JSONObject;

public final class ViolationsToBitbucketServerDescriptor extends BuildStepDescriptor<Publisher> {
private ViolationsToBitbucketServerConfig config;

public ViolationsToBitbucketServerDescriptor() {
super(ViolationsToBitbucketServerRecorder.class);
load();
if (this.config == null || this.config.getViolationConfigs().size() != createNewConfig().getViolationConfigs().size()) {
this.config = createNewConfig();
if (config == null || config.getViolationConfigs().size() != createNewConfig().getViolationConfigs().size()) {
config = createNewConfig();
}
}

Expand Down Expand Up @@ -79,10 +80,11 @@ public Publisher newInstance(StaplerRequest req, JSONObject formData) throws hud
config.setUseUsernamePasswordCredentials(formData.getBoolean(FIELD_USEUSERNAMEPASSWORDCREDENTIALS));
config.setUsernamePasswordCredentialsId(formData.getString(FIELD_USERNAMEPASSWORDCREDENTIALSID));

config.setCreateCommentWithAllSingleFileComments(formData.getString(FIELD_CREATECOMMENTWITHALLSINGLEFILECOMMENTS)
.equalsIgnoreCase("true"));
config.setCreateCommentWithAllSingleFileComments(
formData.getString(FIELD_CREATECOMMENTWITHALLSINGLEFILECOMMENTS).equalsIgnoreCase("true"));

config.setCreateSingleFileComments(formData.getString(FIELD_CREATESINGLEFILECOMMENTS).equalsIgnoreCase("true"));
config.setCommentOnlyChangedContent(formData.getString(FIELD_COMMENTONLYCHANGEDCONTENT).equalsIgnoreCase("true"));
int i = 0;
for (String pattern : (List<String>) formData.get(FIELD_PATTERN)) {
config.getViolationConfigs().get(i++).setPattern(pattern);
Expand Down
Loading

0 comments on commit fcfe5cd

Please sign in to comment.