-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: adding default changelog template #git-changelog-plugin/58
- Loading branch information
1 parent
ecc3815
commit 6be0442
Showing
22 changed files
with
92 additions
and
47 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
57 changes: 57 additions & 0 deletions
57
src/main/java/se/bjurr/gitchangelog/internal/util/ResourceLoader.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,57 @@ | ||
package se.bjurr.gitchangelog.internal.util; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.FileNotFoundException; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.InputStreamReader; | ||
import java.nio.charset.StandardCharsets; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.stream.Collectors; | ||
|
||
public final class ResourceLoader { | ||
private ResourceLoader() {} | ||
|
||
public static String getResourceOrFile(final String resourceName) { | ||
|
||
String templateString = null; | ||
try { | ||
final Path templatePath = Paths.get(resourceName); | ||
if (templatePath.toFile().exists()) { | ||
|
||
Files.readAllBytes(templatePath); | ||
} else { | ||
InputStream inputStream = | ||
getResourceFromClassLoader(resourceName, ResourceLoader.class.getClassLoader()); | ||
if (inputStream == null) { | ||
inputStream = | ||
getResourceFromClassLoader( | ||
resourceName, Thread.currentThread().getContextClassLoader()); | ||
} | ||
|
||
if (inputStream == null) { | ||
throw new FileNotFoundException( | ||
"Was unable to find file, or resouce, \"" + resourceName + "\""); | ||
} | ||
templateString = | ||
new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8)) | ||
.lines() | ||
.collect(Collectors.joining("\n")); | ||
} | ||
} catch (final IOException e) { | ||
throw new RuntimeException(resourceName, e); | ||
} | ||
return templateString; | ||
} | ||
|
||
private static InputStream getResourceFromClassLoader( | ||
final String resourceName, final ClassLoader classLoader) { | ||
InputStream inputStream = classLoader.getResourceAsStream(resourceName); | ||
if (inputStream == null) { | ||
inputStream = classLoader.getResourceAsStream("/" + resourceName); | ||
} | ||
return inputStream; | ||
} | ||
} |
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 @@ | ||
# Changelog | ||
|
||
Changelog for {{ownerName}} {{repoName}}. | ||
|
||
{{#tags}} | ||
## {{name}} | ||
{{#issues}} | ||
{{#hasIssue}} | ||
{{#hasLink}} | ||
### {{name}} [{{issue}}]({{link}}) {{title}} {{#hasIssueType}} *{{issueType}}* {{/hasIssueType}} {{#hasLabels}} {{#labels}} *{{.}}* {{/labels}} {{/hasLabels}} | ||
{{/hasLink}} | ||
{{^hasLink}} | ||
### {{name}} {{issue}} {{title}} {{#hasIssueType}} *{{issueType}}* {{/hasIssueType}} {{#hasLabels}} {{#labels}} *{{.}}* {{/labels}} {{/hasLabels}} | ||
{{/hasLink}} | ||
{{/hasIssue}} | ||
{{^hasIssue}} | ||
### {{name}} | ||
{{/hasIssue}} | ||
|
||
{{#commits}} | ||
**{{{messageTitle}}}** | ||
|
||
{{#messageBodyItems}} | ||
* {{.}} | ||
{{/messageBodyItems}} | ||
|
||
[{{hash}}](https://github.com/{{ownerName}}/{{repoName}}/commit/{{hash}}) {{authorName}} *{{commitTime}}* | ||
|
||
{{/commits}} | ||
|
||
{{/issues}} | ||
{{/tags}} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,6 @@ Changelog of Git Changelog. | |
|
||
{{/commits}} | ||
|
||
|
||
--------------------------------------------- | ||
|
||
settings: | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,6 @@ Changelog of Git Changelog. | |
|
||
{{/authors}} | ||
|
||
|
||
--------------------------------------------- | ||
|
||
settings: | ||
|
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,7 +12,6 @@ Changelog of Git Changelog. | |
|
||
{{/commits}} | ||
|
||
|
||
--------------------------------------------- | ||
|
||
settings: | ||
|
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 |
---|---|---|
|
@@ -19,7 +19,6 @@ Changelog of Git Changelog. | |
|
||
{{/commits}} | ||
|
||
|
||
--------------------------------------------- | ||
|
||
settings: | ||
|
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 |
---|---|---|
|
@@ -10,7 +10,6 @@ template: | |
{{/issues}} | ||
{{/tags}} | ||
|
||
|
||
--------------------------------------------- | ||
|
||
settings: | ||
|
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 |
---|---|---|
|
@@ -6,7 +6,6 @@ template: | |
{{/hasLinkedIssues}} | ||
{{/issues}} | ||
|
||
|
||
--------------------------------------------- | ||
|
||
settings: | ||
|
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 |
---|---|---|
|
@@ -4,7 +4,6 @@ template: | |
{{name}} {{title}} | ||
{{/issues}} | ||
|
||
|
||
--------------------------------------------- | ||
|
||
settings: | ||
|
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
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 |
---|---|---|
|
@@ -9,7 +9,6 @@ template: | |
{{/merge}} | ||
{{/commits}} | ||
|
||
|
||
--------------------------------------------- | ||
|
||
settings: | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,6 @@ template: | |
|
||
{{/commits}} | ||
|
||
|
||
--------------------------------------------- | ||
|
||
settings: | ||
|