From b8c45e319c9fdeb19165b85be7dc7d870badd6b0 Mon Sep 17 00:00:00 2001 From: Shane C Date: Wed, 11 Sep 2024 14:42:19 -0400 Subject: [PATCH] possible fix for duplicating issues --- cmd/root.go | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index f25c83c..b28d3c0 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -193,6 +193,7 @@ var rootCmd = &cobra.Command{ repoOwner, repoName := actionCtx.Repo() issues, _, err := forgeClient.ListIssues(forgejo.ListIssueOption{ + State: forgejo.StateOpen, ListOptions: forgejo.ListOptions{ Page: -1, }, @@ -202,29 +203,23 @@ var rootCmd = &cobra.Command{ log.Fatalln(err) } - //god help me - pretty.Logln(issues) - - isFound := false for _, issue := range issues { - if issue.Title == "GoSec Report" && actionCtx.Repository == issue.Repository.FullName { - isFound = true + if issue.Title == "GoSec Report" && repoOwner+"/"+repoName == issue.Repository.FullName { + pretty.Println(issue) if _, _, err := forgeClient.EditIssue(repoOwner, repoName, issue.Index, forgejo.EditIssueOption{ Body: &markdownOutputStr, }); err != nil { log.Fatalln(err) } - break + os.Exit(0) } } - if !isFound { - if _, _, err := forgeClient.CreateIssue(repoOwner, repoName, forgejo.CreateIssueOption{ - Title: "GoSec Report", - Body: markdownOutputStr, - }); err != nil { - log.Fatalln(err) - } + if _, _, err := forgeClient.CreateIssue(repoOwner, repoName, forgejo.CreateIssueOption{ + Title: "GoSec Report", + Body: markdownOutputStr, + }); err != nil { + log.Fatalln(err) } }