-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- updates expected output files to provide an example of simple and full outputs - adds logic for handling new lines (Markdown requires two empty spaces followed by a newline to correctly create a new line in text) - adds logic for open by default in the feature section - adds collapsible sections
- Loading branch information
Showing
8 changed files
with
140 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
test heading | ||
|
||
## Features :rocket: | ||
|
||
0000000 ci test | ||
|
||
## Bug fixes :bug: | ||
|
||
0000000 huge bug | ||
|
||
## Chores and Improvements :wrench: | ||
|
||
0000000 testing | ||
0000000 this should end up in chores | ||
|
||
## Other :package: | ||
|
||
0000000 merge master in something | ||
0000000 random |
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 |
---|---|---|
@@ -1,20 +1,31 @@ | ||
|
||
test heading | ||
|
||
## Features :rocket: | ||
|
||
- 0000000 ci test | ||
<details open><summary>0000000 ci test</summary> | ||
|
||
- Body | ||
|
||
</details> | ||
|
||
## Bug fixes :bug: | ||
|
||
- 0000000 huge bug | ||
<details><summary>0000000 huge bug</summary> | ||
|
||
Body | ||
|
||
</details> | ||
|
||
## Chores and Improvements :wrench: | ||
|
||
- 0000000 testing | ||
- 0000000 this should end up in chores | ||
<details><summary>0000000 testing</summary> | ||
|
||
## Other :package: | ||
- Body | ||
|
||
- 0000000 merge master in something | ||
- 0000000 random | ||
</details> | ||
0000000 this should end up in chores | ||
|
||
## Other :package: | ||
|
||
0000000 merge master in something | ||
0000000 random |
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 |
---|---|---|
@@ -1,25 +1,60 @@ | ||
package text | ||
|
||
import "strings" | ||
import ( | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
func (r *ReleaseNotes) buildSingleCommit(commit Commit) string { | ||
func (r *ReleaseNotes) buildSingleCommit(commit Commit, isLast, open bool) string { | ||
builder := strings.Builder{} | ||
|
||
commitMessage := buildSimpleCommit(commit) | ||
builder.WriteString(commitMessage) | ||
if r.Simple || commit.Body == "" { | ||
simpleCommitMessage := buildSimpleCommit(commit) | ||
builder.WriteString(simpleCommitMessage) | ||
} else { | ||
commitMessage := buildFullCommit(commit, open) | ||
builder.WriteString(commitMessage) | ||
} | ||
|
||
// Double space + \n creates a new line in markdown | ||
if !isLast { | ||
builder.WriteString(" ") | ||
} | ||
builder.WriteString("\n") | ||
|
||
return builder.String() | ||
} | ||
|
||
func buildSimpleCommit(commit Commit) string { | ||
builder := strings.Builder{} | ||
|
||
builder.WriteString("- ") | ||
// Short version of hash usable on Github | ||
builder.WriteString(commit.Hash.String()[:7]) | ||
builder.WriteString(" ") | ||
builder.WriteString(commit.Heading) | ||
builder.WriteString("\n") | ||
|
||
return builder.String() | ||
} | ||
|
||
func buildFullCommit(commit Commit, open bool) string { | ||
builder := strings.Builder{} | ||
|
||
// closed receives empty string | ||
openString := "" | ||
if open { | ||
openString = " open" | ||
} | ||
detailsWrapperStart := fmt.Sprintf("<details%v>", openString) | ||
builder.WriteString(detailsWrapperStart) | ||
builder.WriteString("<summary>") | ||
builder.WriteString(commit.Hash.String()[:7]) | ||
builder.WriteString(" ") | ||
builder.WriteString(commit.Heading) | ||
builder.WriteString("</summary>") | ||
builder.WriteString("\n\n") | ||
builder.WriteString(commit.Body) | ||
builder.WriteString("\n\n") | ||
builder.WriteString("</details>") | ||
|
||
return builder.String() | ||
} |
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,20 @@ | ||
package text | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestBuildFullCommit(t *testing.T) { | ||
testCommit := Commit{Heading: "stuff", Body: "hi"} | ||
|
||
text := buildFullCommit(testCommit, false) | ||
|
||
expectedText := "<details><summary>0000000 stuff</summary>\n\nhi\n\n</details>" | ||
assert.Equal(t, expectedText, text) | ||
|
||
expectedOpenText := "<details open><summary>0000000 stuff</summary>\n\nhi\n\n</details>" | ||
openText := buildFullCommit(testCommit, true) | ||
assert.Equal(t, expectedOpenText, openText) | ||
} |
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