From 6fef4f0a2e2b7f308daefb63619c6cd5e7bfa530 Mon Sep 17 00:00:00 2001 From: Tomas Bjerre Date: Wed, 4 Jul 2018 12:37:56 +0200 Subject: [PATCH] Loading message template correctly --- CHANGELOG.md | 18 +++++++++++++++++ build.sh | 2 +- gradle.properties | 2 +- .../lib/ViolationCommentsToGitLabApi.java | 20 +++++++++---------- 4 files changed, 30 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4856303..3c01526 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,24 @@ Changelog of Violation comments to gitlab lib. +## 1.31 +### No issue + +**Escaped message and filename** + + +[3c529460568f513](https://github.com/tomasbjerre/violation-comments-to-gitlab-lib/commit/3c529460568f513) Tomas Bjerre *2018-07-04 10:15:17* + + +## 1.30 +### No issue + +**Custom template** + + +[bff1247b8e5b3c5](https://github.com/tomasbjerre/violation-comments-to-gitlab-lib/commit/bff1247b8e5b3c5) Tomas Bjerre *2018-07-04 08:49:00* + + ## 1.29 ### No issue diff --git a/build.sh b/build.sh index c721db7..3a7ceaa 100755 --- a/build.sh +++ b/build.sh @@ -1,2 +1,2 @@ #!/bin/bash -./gradlew --refresh-dependencies clean gitChangelogTask eclipse build install -i +./gradlew clean gitChangelogTask eclipse build install -i diff --git a/gradle.properties b/gradle.properties index a4fb9be..ae10f3d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1 @@ -version = 1.32-SNAPSHOT +version = 1.33-SNAPSHOT diff --git a/src/main/java/se/bjurr/violations/comments/gitlab/lib/ViolationCommentsToGitLabApi.java b/src/main/java/se/bjurr/violations/comments/gitlab/lib/ViolationCommentsToGitLabApi.java index a0ba72e..4891219 100644 --- a/src/main/java/se/bjurr/violations/comments/gitlab/lib/ViolationCommentsToGitLabApi.java +++ b/src/main/java/se/bjurr/violations/comments/gitlab/lib/ViolationCommentsToGitLabApi.java @@ -5,11 +5,10 @@ import static se.bjurr.violations.comments.lib.CommentsCreator.createComments; import static se.bjurr.violations.lib.util.Optional.fromNullable; -import java.net.URI; -import java.nio.charset.Charset; -import java.nio.file.Files; -import java.nio.file.Paths; +import com.github.mustachejava.resolver.DefaultResolver; +import java.io.Reader; import java.util.List; +import java.util.Scanner; import java.util.logging.Logger; import org.gitlab.api.AuthMethod; import org.gitlab.api.TokenType; @@ -24,12 +23,13 @@ public class ViolationCommentsToGitLabApi { static { try { - final URI gitlabCommentTemplateUrl = - ViolationCommentsToGitLabApi.class - .getResource(DEFAULT_VIOLATION_TEMPLATE_MUSTACH) - .toURI(); - final byte[] bytes = Files.readAllBytes(Paths.get(gitlabCommentTemplateUrl)); - DEFAULT_TEMPLATE = new String(bytes, Charset.forName("UTF-8")); + final Reader reader = + new DefaultResolver() // + .getReader(DEFAULT_VIOLATION_TEMPLATE_MUSTACH); + try (Scanner scanner = new Scanner(reader)) { + scanner.useDelimiter("\\A"); + DEFAULT_TEMPLATE = scanner.hasNext() ? scanner.next() : ""; + } } catch (final Throwable t) { Logger.getLogger(ViolationCommentsToGitLabApi.class.getName()).log(SEVERE, t.getMessage(), t); }