Skip to content

Commit bc62232

Browse files
vhvb1989JeffreyCA
andauthored
Apply suggestions from code review
Co-authored-by: JeffreyCA <jeffreyca16@gmail.com>
1 parent f25177d commit bc62232

File tree

3 files changed

+5
-19
lines changed

3 files changed

+5
-19
lines changed

cli/azd/cmd/middleware/error.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,8 +582,7 @@ func (e *ErrorMiddleware) promptExplanationWithConsent(ctx context.Context) (str
582582
selected := choices[*choiceIndex].Value
583583

584584
// Handle "always" variants — save to config and return the scope
585-
if after, ok := strings.CutPrefix(selected, "always."); ok {
586-
scope := after
585+
if scope, ok := strings.CutPrefix(selected, "always."); ok {
587586
configKey := configPrefix + "." + scope
588587
if err := userConfig.Set(configKey, "allow"); err != nil {
589588
return "", fmt.Errorf("failed to set config %s: %w", configKey, err)

cli/azd/extensions/azure.ai.agents/internal/cmd/init.go

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,16 +1615,11 @@ func (a *InitAction) parseGitHubUrlNaive(manifestPointer string) *GitHubUrlInfo
16151615
repoPath := strings.TrimPrefix(parts[0], "/")
16161616
repoSlug := repoPath
16171617

1618-
// The second part is {branch}/{file-path}
1619-
branchAndPath := parts[1]
1620-
before, after, ok := strings.Cut(branchAndPath, "/")
1618+
branch, filePath, ok := strings.Cut(branchAndPath, "/")
16211619
if !ok {
16221620
return nil
16231621
}
16241622

1625-
branch := before
1626-
filePath := after
1627-
16281623
// Only use naive parsing if branch looks like a simple single word (no slashes)
16291624
if strings.Contains(branch, "/") {
16301625
return nil
@@ -1653,18 +1648,12 @@ func (a *InitAction) parseGitHubUrlNaive(manifestPointer string) *GitHubUrlInfo
16531648

16541649
repoSlug := parts[0] + "/" + parts[1]
16551650
rest := parts[2]
1656-
1657-
// Check for refs/heads/ prefix
1658-
if after, ok := strings.CutPrefix(rest, "refs/heads/"); ok {
1659-
rest = after
1660-
before, after, ok := strings.Cut(rest, "/")
1651+
if rest, ok := strings.CutPrefix(rest, "refs/heads/"); ok {
1652+
branch, filePath, ok := strings.Cut(rest, "/")
16611653
if !ok {
16621654
return nil
16631655
}
16641656

1665-
branch := before
1666-
filePath := after
1667-
16681657
// Only use naive parsing if branch looks like a simple single word
16691658
if strings.Contains(branch, "/") {
16701659
return nil

cli/azd/extensions/azure.ai.agents/internal/cmd/invoke.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,7 @@ func readSSEStream(body io.Reader, agentName string) error {
329329
continue
330330
}
331331

332-
if after, ok := strings.CutPrefix(line, "data: "); ok {
333-
data := after
334-
332+
if data, ok := strings.CutPrefix(line, "data: "); ok {
335333
switch currentEvent {
336334
case "response.output_text.delta":
337335
var delta struct {

0 commit comments

Comments
 (0)