From 66481007ad0c9b3736dd5528f028d14f7c0ba0fd Mon Sep 17 00:00:00 2001 From: packet-mover Date: Sun, 5 Apr 2026 21:16:18 +0200 Subject: [PATCH] fix: simplify ReportRepo config to repo name only MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Org is already in Config.Org — no need to repeat it in ReportRepo. Remove parseReportRepo helper. Co-Authored-By: Claude Opus 4.6 (1M context) --- cmd/scanner/main.go | 2 +- scanner.go | 17 ++--------------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/cmd/scanner/main.go b/cmd/scanner/main.go index 98d8a3c..31cd87b 100644 --- a/cmd/scanner/main.go +++ b/cmd/scanner/main.go @@ -11,7 +11,7 @@ import ( func main() { org := os.Getenv("CODATUS_ORG") token := os.Getenv("CODATUS_TOKEN") - reportRepo := os.Getenv("CODATUS_REPORT_REPO") + reportRepo := os.Getenv("CODATUS_REPORT_REPO") // repo name only, org is inferred from CODATUS_ORG if org == "" { log.Fatal("CODATUS_ORG is required") diff --git a/scanner.go b/scanner.go index 6ebf8b8..abf745e 100644 --- a/scanner.go +++ b/scanner.go @@ -5,7 +5,6 @@ import ( "fmt" "log" "sort" - "strings" ) // Config holds the configuration needed to run a scan. @@ -35,27 +34,15 @@ func Run(ctx context.Context, cfg Config) error { report := GenerateReport(cfg.Org, results) - owner, repo, err := parseReportRepo(cfg.ReportRepo) - if err != nil { - return err - } - title := fmt.Sprintf("Codatus — %s Compliance Report", cfg.Org) - if err := client.CreateIssue(ctx, owner, repo, title, report); err != nil { - return fmt.Errorf("post report to %s: %w", cfg.ReportRepo, err) + if err := client.CreateIssue(ctx, cfg.Org, cfg.ReportRepo, title, report); err != nil { + return fmt.Errorf("post report to %s/%s: %w", cfg.Org, cfg.ReportRepo, err) } log.Printf("report posted to %s", cfg.ReportRepo) return nil } -func parseReportRepo(reportRepo string) (string, string, error) { - parts := strings.SplitN(reportRepo, "/", 2) - if len(parts) != 2 || parts[0] == "" || parts[1] == "" { - return "", "", fmt.Errorf("invalid report repo format %q: expected owner/repo", reportRepo) - } - return parts[0], parts[1], nil -} // Scan lists all non-archived repos in the org and evaluates every rule against each. func Scan(ctx context.Context, client GitHubClient, org string) ([]RepoResult, error) {