Skip to content

Commit

Permalink
shouldCommentOnlyChangedContent
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbjerre committed Jun 9, 2019
1 parent e5db5b7 commit fb6c009
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,14 @@ Missing a format? Open an issue [here](https://github.com/tomasbjerre/violations
# Usage

```shell
-comment-only-changed-content-context, -coccc <integer> <integer>: -2,147,483,648 to 2,147,483,647
Default: 5
-comment-only-changed-content, -cocc <boolean> True if only changed
parts of the changed files
should be commented. False if
all findings on the
changed files should be
commented.
<boolean>: true or false
Default: true
-comment-template <string> https://github.
com/tomasbjerre/violation-comments-lib
<string>: any string
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand Down
27 changes: 14 additions & 13 deletions src/main/java/se/bjurr/violations/main/Runner.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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<Integer> commentOnlyChangedContentContextArg =
integerArgument("-comment-only-changed-content-context", "-coccc").defaultValue(5).build();
final Argument<Boolean> 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<Integer> maxNumberOfViolationsArg =
integerArgument("-max-number-of-violations", "-max")
.defaultValue(Integer.MAX_VALUE)
Expand All @@ -123,7 +126,7 @@ public void main(final String args[]) throws Exception {
repositorySlugArg, //
usernameArg, //
passwordArg, //
commentOnlyChangedContentContextArg, //
shouldCommentOnlyChangedContentArg, //
maxNumberOfViolationsArg //
) //
.parse(args);
Expand All @@ -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)) {
Expand Down Expand Up @@ -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) //
Expand Down Expand Up @@ -240,11 +243,9 @@ public String toString() {
+ ", username="
+ username
+ ", password="
+ password
+ ", personalAccessToken="
+ personalAccessToken
+ ", commentOnlyChangedContentContext="
+ commentOnlyChangedContentContext
+ (password != null)
+ ", shouldCommentOnlyChangedContent="
+ shouldCommentOnlyChangedContent
+ ", maxNumberOfViolations="
+ maxNumberOfViolations
+ "]";
Expand Down

0 comments on commit fb6c009

Please sign in to comment.