diff --git a/README.md b/README.md index d8c7c11..c822332 100644 --- a/README.md +++ b/README.md @@ -114,8 +114,14 @@ Missing a format? Open an issue [here](https://github.com/tomasbjerre/violations # Usage ```shell --comment-only-changed-content-context, -coccc : -2,147,483,648 to 2,147,483,647 - Default: 5 +-comment-only-changed-content, -cocc True if only changed + parts of the changed files + should be commented. False if + all findings on the + changed files should be + commented. + : true or false + Default: true -comment-template https://github. com/tomasbjerre/violation-comments-lib : any string diff --git a/build.gradle b/build.gradle index 0153dd3..5125e6a 100644 --- a/build.gradle +++ b/build.gradle @@ -27,7 +27,7 @@ apply from: project.buildscript.classLoader.getResource('violations.gradle').toU dependencies { - compile 'se.bjurr.violations:violation-comments-to-bitbucket-cloud-lib:1.3' + compile 'se.bjurr.violations:violation-comments-to-bitbucket-cloud-lib:1.4' compile 'se.softhouse:jargo:0.1.1' compile 'org.slf4j:slf4j-simple:1.8.0-beta2' } diff --git a/src/main/java/se/bjurr/violations/main/Runner.java b/src/main/java/se/bjurr/violations/main/Runner.java index aa7ca90..0a31f87 100644 --- a/src/main/java/se/bjurr/violations/main/Runner.java +++ b/src/main/java/se/bjurr/violations/main/Runner.java @@ -41,8 +41,7 @@ public class Runner { private String repositorySlug; private String username; private String password; - private String personalAccessToken; - private int commentOnlyChangedContentContext; + private boolean shouldCommentOnlyChangedContent; private Integer maxNumberOfViolations; public void main(final String args[]) throws Exception { @@ -100,8 +99,12 @@ public void main(final String args[]) throws Exception { .defaultValue("") .description("You can create an 'application password' in Bitbucket to use here.") .build(); - final Argument commentOnlyChangedContentContextArg = - integerArgument("-comment-only-changed-content-context", "-coccc").defaultValue(5).build(); + final Argument shouldCommentOnlyChangedContentArg = + booleanArgument("-comment-only-changed-content", "-cocc") + .defaultValue(true) + .description( + "True if only changed parts of the changed files should be commented. False if all findings on the changed files should be commented.") + .build(); final Argument maxNumberOfViolationsArg = integerArgument("-max-number-of-violations", "-max") .defaultValue(Integer.MAX_VALUE) @@ -123,7 +126,7 @@ public void main(final String args[]) throws Exception { repositorySlugArg, // usernameArg, // passwordArg, // - commentOnlyChangedContentContextArg, // + shouldCommentOnlyChangedContentArg, // maxNumberOfViolationsArg // ) // .parse(args); @@ -136,12 +139,12 @@ public void main(final String args[]) throws Exception { this.keepOldComments = parsed.get(keepOldCommentsArg); this.commentTemplate = parsed.get(commentTemplateArg); - pullRequestId = parsed.get(pullRequestIdArg); + this.pullRequestId = parsed.get(pullRequestIdArg); this.workspace = parsed.get(workspaceArg); this.repositorySlug = parsed.get(repositorySlugArg); this.username = parsed.get(usernameArg); this.password = parsed.get(passwordArg); - this.commentOnlyChangedContentContext = parsed.get(commentOnlyChangedContentContextArg); + this.shouldCommentOnlyChangedContent = parsed.get(shouldCommentOnlyChangedContentArg); this.maxNumberOfViolations = parsed.get(maxNumberOfViolationsArg); if (parsed.wasGiven(showDebugInfo)) { @@ -193,7 +196,7 @@ public void main(final String args[]) throws Exception { .withViolations(allParsedViolations) // .withCreateCommentWithAllSingleFileComments(createCommentWithAllSingleFileComments) // .withCreateSingleFileComment(createSingleFileComments) // - .withCommentOnlyChangedContentContext(commentOnlyChangedContentContext) // + .withShouldCommentOnlyChangedContent(shouldCommentOnlyChangedContent) // .withKeepOldComments(keepOldComments) // .withCommentTemplate(commentTemplate) // .withMaxNumberOfViolations(maxNumberOfViolations) // @@ -240,11 +243,9 @@ public String toString() { + ", username=" + username + ", password=" - + password - + ", personalAccessToken=" - + personalAccessToken - + ", commentOnlyChangedContentContext=" - + commentOnlyChangedContentContext + + (password != null) + + ", shouldCommentOnlyChangedContent=" + + shouldCommentOnlyChangedContent + ", maxNumberOfViolations=" + maxNumberOfViolations + "]";