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
2 changes: 1 addition & 1 deletion pkg/agentdrain/miner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ func TestConcurrency(t *testing.T) {
for i := range linesEach {
line := fmt.Sprintf("stage=work goroutine=%d iter=%d", id, i)
_, trainErr := m.Train(line)
require.NoError(t, trainErr, "Train should not error during concurrent access")
assert.NoError(t, trainErr, "Train should not error during concurrent access")
}
}(g)
}
Expand Down
11 changes: 4 additions & 7 deletions pkg/cli/codemod_checkout_persist_credentials_false.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cli

import (
"fmt"
"strings"

"github.com/github/gh-aw/pkg/logger"
Expand Down Expand Up @@ -309,22 +308,20 @@ func transformCheckoutWithinSection(sectionLines []string, sectionIndent string)
func ensureStepCheckoutPersistCredentials(stepLines []string, stepIndent string) ([]string, bool) {
usesIdx := -1
usesIndent := ""
isUsesInline := false
withStart := -1
withEnd := -1
withIndent := ""
withKeyIndentLen := 0
persistIdx := -1

for i := 0; i < len(stepLines); i++ {
for i := range stepLines {
line := stepLines[i]
trimmed := strings.TrimSpace(line)
indent := getIndentation(line)

usesMatch, usesValue, _ := parseStepKeyLine(trimmed, indent, stepIndent, "uses")
if usesMatch && isCheckoutUsesValue(usesValue) {
usesIdx = i
isUsesInline = strings.HasPrefix(trimmed, "- uses:") && len(indent) == len(stepIndent)
isUsesInline := strings.HasPrefix(trimmed, "- uses:") && len(indent) == len(stepIndent)
if isUsesInline {
usesIndent = stepIndent + " "
} else {
Expand All @@ -343,7 +340,7 @@ func ensureStepCheckoutPersistCredentials(stepLines []string, stepIndent string)
withStart = i
withEnd = i
withIndent = indent
withKeyIndentLen = currentWithKeyIndentLen
withKeyIndentLen := currentWithKeyIndentLen
for j := i + 1; j < len(stepLines); j++ {
t := strings.TrimSpace(stepLines[j])
if len(t) == 0 {
Expand Down Expand Up @@ -375,7 +372,7 @@ func ensureStepCheckoutPersistCredentials(stepLines []string, stepIndent string)

if withStart != -1 {
insertAt := withEnd + 1
insertLine := fmt.Sprintf("%spersist-credentials: false", withIndent+" ")
insertLine := withIndent + " persist-credentials: false"
updated := append([]string{}, stepLines[:insertAt]...)
updated = append(updated, insertLine)
updated = append(updated, stepLines[insertAt:]...)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
package cli

import (
"fmt"
"strings"
"testing"
)
Expand Down Expand Up @@ -82,9 +81,9 @@ func FuzzCheckoutPersistCredentialsFalseCodemod(f *testing.F) {
}

func buildCheckoutFuzzContent(section, uses string, hasWith, hasPersist, persistTrue, inlineUses bool) string {
usesLine := fmt.Sprintf(" uses: %s", uses)
usesLine := " uses: " + uses
if inlineUses {
usesLine = fmt.Sprintf(" - uses: %s", uses)
usesLine = " - uses: " + uses
}

lines := []string{
Expand Down