refactor: address trail finding CLI review feedback · Entire

refactor: address trail finding CLI review feedback

edaadf3→main·

dipree·1mo ago·3 files·+15 added/-13 removed

Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

Sessions

138a8d212cffView transcript

Changes

3

// Code snippets from the repository
func verifyTrailReviewHead(ctx context.Context, state api.TrailReviewStateResponse) error {
    want := strings.TrimSpace(optionalStringValue(state.CodeVersion.HeadSHA))
    want := strings.TrimSpace(stringPtrValue(state.CodeVersion.HeadSHA))
    if want == "" {
        return nil
    }
    return fmt.Errorf("path %q escapes the repository", raw)
}

func optionalStringValue(s *string) string {
    if s == nil {
        return ""
    }
    return *s
}

func abbreviate12(s string) string {
    const n = 12
    if len(s) <= n {
        return s
    }
    return s[:n]
}
package main

import (
    "fmt"
    "strings"
)

func TestTrailCommandSurfaceUsesFindings(t *testing.T) {
    t.Parallel()
    trailCmd := newTrailCmd()
    children := map[string]*cobra.Command{}
    for _, child := range trailCmd.Commands() {
        // remainder of test
    }
}
func TestTrailReviewCommentsPath(t *testing.T) {
    t.Parallel()
    got := trailReviewCommentsPath("trail id/with slash", trailReviewListOptions{
        Status:           "open,resolved",
        Severity:         "high,medium",
    })
    // additional assertions
}
func TestLoadTrailReviewCommentPatchFile(t *testing.T) {
    t.Parallel()
    opts, err := loadTrailReviewCommentPatchFile(trailReviewCommentAddOptions{PatchFile: "-"}, strings.NewReader("diff --git a/file.txt b/file.txt\n"))
    if err != nil {
        t.Fatalf("loadTrailReviewCommentPatchFile: %v", err)
    }
}
func TestPrintTrailReviewDashboard(t *testing.T) {
    t.Parallel()
    high := trailReviewSeverityHigh
    medium := trailReviewSeverityMedium
    path := "src/auth/session.ts"
    // further testing functionality
}
func newTrailReviewApplyRepo(t *testing.T) string {
    t.Helper()
    dir := t.TempDir()
    runTrailReviewApplyGit(t, dir, "init")
    paths.ClearWorktreeRootCache()
    t.Chdir(dir)
}