Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 37 additions & 37 deletions .github/workflows/issue-monster.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions pkg/workflow/compiler_draft_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/github/gh-aw/pkg/stringutil"

"github.com/github/gh-aw/pkg/testutil"
"github.com/stretchr/testify/assert"
)

func TestPullRequestDraftFilter(t *testing.T) {
Expand Down Expand Up @@ -539,5 +540,19 @@ func TestCommentOutProcessedFieldsInOnSection(t *testing.T) {
}
}

func TestCommentOutProcessedFieldsInOnSectionBlankLineInBlock(t *testing.T) {
compiler := NewCompiler()

result := compiler.commentOutProcessedFieldsInOnSection(`on:
steps: |
echo hello

echo world
workflow_dispatch:`, map[string]any{})

assert.Contains(t, result, "\n#\n")
assert.NotContains(t, result, "# \n")
}

// containsInNonCommentLines checks if a string appears in any non-comment lines
// A comment line is one that starts with '#' (after trimming leading whitespace)
10 changes: 9 additions & 1 deletion pkg/workflow/frontmatter_extraction_yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ func (c *Compiler) indentYAMLLines(yamlContent, indent string) string {
if strings.TrimSpace(lines[i]) != "" {
result.WriteString("\n" + indent + lines[i])
} else {
result.WriteString("\n" + lines[i])
// Emit a bare newline for blank/whitespace-only lines so we don't
// carry the surrounding indentation as trailing whitespace, which
// yamllint flags as trailing-spaces.
result.WriteString("\n")
}
}

Expand Down Expand Up @@ -754,6 +757,11 @@ func (c *Compiler) commentOutProcessedFieldsInOnSection(yamlStr string, frontmat
}

commentedLine := indentation + "# " + trimmed + commentReason
// Blank lines inside multi-line blocks would otherwise become "# "
// with trailing whitespace, which yamllint flags as trailing-spaces.
if trimmed == "" {
commentedLine = strings.TrimRight(commentedLine, " \t")
}
result = append(result, commentedLine)
} else {
result = append(result, line)
Expand Down
4 changes: 2 additions & 2 deletions pkg/workflow/frontmatter_extraction_yaml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ func TestIndentYAMLLines(t *testing.T) {
wantOut: "name: test\n runs-on: ubuntu-latest\n steps:",
},
{
name: "blank lines are preserved without extra indentation",
name: "blank lines are normalized without trailing whitespace",
input: "first: value\n\nsecond: value\n \nthird: value",
indent: " ",
wantOut: "first: value\n\n second: value\n \n third: value",
wantOut: "first: value\n\n second: value\n\n third: value",
},

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing test for the primary fix (commentOutProcessedFieldsInOnSection blank-line case): the PR correctly adds a blank-line normalization test for indentYAMLLines, but the higher-impact fix — which produces the 39-warning reduction — has no corresponding unit test asserting that a blank line inside a commented-out block yields bare # rather than # .

💡 Suggested addition

Add a case to TestCommentOutProcessedFieldsInOnSection (in compiler_yaml_test.go):

{
    name: "blank line inside on.steps emits bare # not # ",
    input: "on:\n  steps:\n    - name: test\n      run: |\n        echo hello\n\n        echo world\n",
    // blank line inside steps block should become "#" not "# "
    mustNotContain: []string{"# \n"},
    mustContain:    []string{"#\n"},
},

This mirrors what the PR does for TestIndentYAMLLines and protects the main regression target from regressing silently.

}

Expand Down
Loading