-
Notifications
You must be signed in to change notification settings - Fork 445
refactor(workflow): extract helpers to fix function-length lint violations #44008
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 3 commits
cdf3323
b47f4b2
fa98c82
9fba746
745e461
0034e92
b299c85
3f8b0ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,38 +56,7 @@ func computeAntigravityToolsCore(tools map[string]any) []string { | |
|
|
||
| // Map bash neutral tool to run_shell_command | ||
| if bashConfig, hasBash := tools["bash"]; hasBash { | ||
| bashCommands, ok := bashConfig.([]any) | ||
| if !ok || len(bashCommands) == 0 { | ||
| // bash with no specific commands - allow all shell commands | ||
| antigravityToolsLog.Print("bash (no specific commands) → run_shell_command") | ||
| toolsCore = append(toolsCore, "run_shell_command") | ||
| } else { | ||
| // Check for wildcard (* or :*) | ||
| hasWildcard := false | ||
| for _, cmd := range bashCommands { | ||
| if cmdStr, ok := cmd.(string); ok && (cmdStr == "*" || cmdStr == ":*") { | ||
| hasWildcard = true | ||
| break | ||
| } | ||
| } | ||
| if hasWildcard { | ||
| antigravityToolsLog.Print("bash wildcard → run_shell_command") | ||
| toolsCore = append(toolsCore, "run_shell_command") | ||
| } else { | ||
| // Add an entry for each specific command: run_shell_command(cmd) | ||
| for _, cmd := range bashCommands { | ||
| if cmdStr, ok := cmd.(string); ok { | ||
| // Normalize trailing " *" wildcard (e.g. "jq *" → "jq") so that | ||
| // all engines emit the canonical prefix form (run_shell_command(jq)) | ||
| // regardless of whether the command was written with or without the wildcard. | ||
| normalized, _ := normalizeBashCommand(cmdStr) | ||
| entry := fmt.Sprintf("run_shell_command(%s)", normalized) | ||
| antigravityToolsLog.Printf("bash %q → %s", cmdStr, entry) | ||
| toolsCore = append(toolsCore, entry) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| toolsCore = appendBashTools(toolsCore, bashConfig) | ||
| } | ||
|
|
||
| // Map edit neutral tool to write_file and replace (Antigravity's file write tools) | ||
|
|
@@ -108,6 +77,39 @@ func computeAntigravityToolsCore(tools map[string]any) []string { | |
| return toolsCore | ||
| } | ||
|
|
||
| // appendBashTools maps the bash neutral tool configuration to run_shell_command | ||
| // entries and appends them to toolsCore. | ||
| func appendBashTools(toolsCore []string, bashConfig any) []string { | ||
| bashCommands, ok := bashConfig.([]any) | ||
| if !ok || len(bashCommands) == 0 { | ||
| // bash with no specific commands - allow all shell commands | ||
| antigravityToolsLog.Print("bash (no specific commands) → run_shell_command") | ||
| return append(toolsCore, "run_shell_command") | ||
| } | ||
|
|
||
| // Check for wildcard (* or :*) | ||
| for _, cmd := range bashCommands { | ||
| if cmdStr, ok := cmd.(string); ok && (cmdStr == "*" || cmdStr == ":*") { | ||
| antigravityToolsLog.Print("bash wildcard → run_shell_command") | ||
| return append(toolsCore, "run_shell_command") | ||
| } | ||
| } | ||
|
|
||
| // Add an entry for each specific command: run_shell_command(cmd) | ||
| for _, cmd := range bashCommands { | ||
| if cmdStr, ok := cmd.(string); ok { | ||
| // Normalize trailing " *" wildcard (e.g. "jq *" → "jq") so that | ||
| // all engines emit the canonical prefix form (run_shell_command(jq)) | ||
| // regardless of whether the command was written with or without the wildcard. | ||
| normalized, _ := normalizeBashCommand(cmdStr) | ||
| entry := fmt.Sprintf("run_shell_command(%s)", normalized) | ||
| antigravityToolsLog.Printf("bash %q → %s", cmdStr, entry) | ||
| toolsCore = append(toolsCore, entry) | ||
| } | ||
| } | ||
| return toolsCore | ||
| } | ||
|
|
||
| // generateAntigravitySettingsStep creates a GitHub Actions step that writes the | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [/codebase-design] 💡 Consider single-pass alternativeThe current implementation iterates for _, cmd := range bashCommands {
cmdStr, ok := cmd.(string)
if !ok {
continue
}
if cmdStr == "*" || cmdStr == ":*" {
antigravityToolsLog.Print("bash wildcard → run_shell_command")
return append(toolsCore, "run_shell_command")
}
normalized, _ := normalizeBashCommand(cmdStr)
entry := fmt.Sprintf("run_shell_command(%s)", normalized)
antigravityToolsLog.Printf("bash %q → %s", cmdStr, entry)
toolsCore = append(toolsCore, entry)
}
return toolsCoreThis is a nit — the current version is correct and the tests cover both paths. @copilot please address this.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in commit |
||
| // Antigravity CLI project settings file (.antigravity/settings.json) before execution. | ||
| // | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[/tdd]
lookupEmbeddedActionPincontains non-trivial semver matching logic (precise vs. range version comparison) but has no direct test — existingResolveSHAtests only cover cache-hit and network-error paths; the embedded-pin branch is untested.💡 Suggested test
lookupEmbeddedActionPinis package-private and can be unit-tested directly:This locks down the semver-matching logic independently of the cache layer.
@copilot please address this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in commit
b299c85. AddedTestLookupEmbeddedActionPintoaction_resolver_test.gocovering four paths: precise-version match, semver-range match, unknown-repo not-found, and known-repo incompatible-version not-found.