Skip to content

Commit

Permalink
fix: bug handling newline characters (#335)
Browse files Browse the repository at this point in the history
* fix: bug handling newline characters

* Formatted code.

* Update action.yml

* Updated README.

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
jackton1 and github-actions[bot] committed Aug 18, 2022
1 parent 036c06b commit 889e7f5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
3 changes: 2 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var outputsHeader = "## Outputs"
var autoDocStart = "<!-- AUTO-DOC-%s:START - Do not remove or modify this section -->"
var autoDocEnd = "<!-- AUTO-DOC-%s:END -->"
var pipeSeparator = "|"
var newLineSeparator = "\n"
var inputAutoDocStart = fmt.Sprintf(autoDocStart, "INPUT")
var inputAutoDocEnd = fmt.Sprintf(autoDocEnd, "INPUT")
var outputAutoDocStart = fmt.Sprintf(autoDocStart, "OUTPUT")
Expand Down Expand Up @@ -118,7 +119,7 @@ func (a *Action) renderOutput() error {
var defaultValue string
var parts = strings.Split(inputDefault, "\n")

if len(parts) > 1 {
if len(parts) > 1 && inputDefault != newLineSeparator {
for _, part := range parts {
if part != "" {
defaultValue += "`\"" + part + "\"`" + "<br>"
Expand Down
17 changes: 9 additions & 8 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@

<!-- AUTO-DOC-INPUT:START - Do not remove or modify this section -->

| INPUT | TYPE | REQUIRED | DEFAULT | DESCRIPTION |
|-----------|--------|----------|------------------------------------|-------------------------------------------------------------------------------------|
| base_sha | string | false | | Specify a base commit SHA<br>used for comparing changes |
| files | string | false | `"README.md"`<br>`"README.md"`<br> | Check for changes using only<br>this list of files (Defaults<br>to the entire repo) |
| path | string | false | | Specify a relative path under<br>$GITHUB_WORKSPACE to locate the repository<br> |
| separator | string | true | `"\|"` | Split character for array output<br> |
| sha | string | true | `"${{ github.sha }}"` | Specify a current commit SHA<br>used for comparing changes |
| token | string | true | `"${{ github.token }}"` | Github token or Repo Scoped<br>Personal Access Token |
| INPUT | TYPE | REQUIRED | DEFAULT | DESCRIPTION |
|----------------|--------|----------|------------------------------------|-------------------------------------------------------------------------------------|
| base_sha | string | false | | Specify a base commit SHA<br>used for comparing changes |
| files | string | false | `"README.md"`<br>`"README.md"`<br> | Check for changes using only<br>this list of files (Defaults<br>to the entire repo) |
| path | string | false | | Specify a relative path under<br>$GITHUB_WORKSPACE to locate the repository<br> |
| path_separator | string | false | `"\n"` | Path separator |
| separator | string | true | `"\|"` | Split character for array output<br> |
| sha | string | true | `"${{ github.sha }}"` | Specify a current commit SHA<br>used for comparing changes |
| token | string | true | `"${{ github.token }}"` | Github token or Repo Scoped<br>Personal Access Token |

<!-- AUTO-DOC-INPUT:END -->

Expand Down
4 changes: 4 additions & 0 deletions test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ inputs:
path:
description: 'Specify a relative path under $GITHUB_WORKSPACE to locate the repository'
required: false
path_separator:
description: 'Path separator'
required: false
default: "\n"

outputs:
added_files:
Expand Down

0 comments on commit 889e7f5

Please sign in to comment.