summaryrefslogtreecommitdiff
path: root/internal/cli
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-07-12 19:57:29 +0300
committerPaul Buetow <paul@buetow.org>2025-07-12 19:57:29 +0300
commit3b2f1284ca768c3da293fd0b09f046c170d95f4d (patch)
tree15d5fa7e2b266f1375b345d8b13a2404c7d0db21 /internal/cli
parent964aa9b6b0049211c926e4bf76500c1ba196f65b (diff)
feat: clear cache and track failed AI release note generations
- Clear cache entry when AI generation fails to allow retry - Track all failed generations for summary at end - Save cache immediately after clearing failed entry - Show helpful summary of failed releases at the end - Suggest running again to retry failed generations - Handle both GitHub and Codeberg org names in failure tracking 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'internal/cli')
-rw-r--r--internal/cli/release.go50
1 files changed, 47 insertions, 3 deletions
diff --git a/internal/cli/release.go b/internal/cli/release.go
index 5b90c31..95794a6 100644
--- a/internal/cli/release.go
+++ b/internal/cli/release.go
@@ -65,13 +65,25 @@ func HandleCheckReleasesForRepos(cfg *config.Config, flags *Flags, repositories
aiReleaseNotesCache := loadAIReleaseNotesCache(cacheFile)
initialCacheSize := len(aiReleaseNotesCache)
- // Print cache summary at the end if cache was modified
+ // Track failed AI generations
+ failedAIGenerations := []string{}
+
+ // Print summary at the end
defer func() {
if len(aiReleaseNotesCache) > initialCacheSize {
fmt.Printf("\nAI release notes cache updated: %d new entries added (total: %d entries)\n",
len(aiReleaseNotesCache)-initialCacheSize, len(aiReleaseNotesCache))
fmt.Printf("Cache file: %s\n", cacheFile)
}
+
+ if len(failedAIGenerations) > 0 {
+ fmt.Printf("\n⚠️ AI release notes generation failed for %d releases:\n", len(failedAIGenerations))
+ for _, failed := range failedAIGenerations {
+ fmt.Printf(" - %s\n", failed)
+ }
+ fmt.Println("\nThese releases were skipped. Their cache entries were cleared.")
+ fmt.Println("Run again to retry generation for these releases.")
+ }
}()
// Set tokens from config with fallback to environment variables and files
@@ -220,7 +232,11 @@ func HandleCheckReleasesForRepos(cfg *config.Config, flags *Flags, repositories
fmt.Printf(" Warning: Failed to generate AI release notes: %v\n", err)
fmt.Printf(" Falling back to standard release notes\n")
releaseNotes = releaseManager.GenerateReleaseNotes(repoPath, tag, localTags)
- // Don't cache on failure
+ // Clear cache on failure and track
+ delete(aiReleaseNotesCache, cacheKey)
+ failedAIGenerations = append(failedAIGenerations, fmt.Sprintf("%s/%s:%s", githubOrg.Name, repoName, tag))
+ // Save cache after clearing the failed entry
+ saveAIReleaseNotesCache(cacheFile, aiReleaseNotesCache)
} else {
releaseNotes = aiNotes
aiReleaseNotesCache[cacheKey] = aiNotes // Cache only on success
@@ -290,7 +306,11 @@ func HandleCheckReleasesForRepos(cfg *config.Config, flags *Flags, repositories
fmt.Printf(" Warning: Failed to generate AI release notes: %v\n", err)
fmt.Printf(" Falling back to standard release notes\n")
releaseNotes = releaseManager.GenerateReleaseNotes(repoPath, tag, localTags)
- // Don't cache on failure
+ // Clear cache on failure and track
+ delete(aiReleaseNotesCache, cacheKey)
+ failedAIGenerations = append(failedAIGenerations, fmt.Sprintf("%s/%s:%s", githubOrg.Name, repoName, tag))
+ // Save cache after clearing the failed entry
+ saveAIReleaseNotesCache(cacheFile, aiReleaseNotesCache)
} else {
releaseNotes = aiNotes
aiReleaseNotesCache[cacheKey] = aiNotes // Cache only on success
@@ -370,6 +390,18 @@ func HandleCheckReleasesForRepos(cfg *config.Config, flags *Flags, repositories
aiNotes, err = releaseManager.GenerateAIReleaseNotes(repoPath, repoName, tag, localTags, commits)
if err != nil {
fmt.Printf(" Warning: Failed to generate AI release notes: %v\n", err)
+ // Clear cache on failure and track
+ delete(aiReleaseNotesCache, cacheKey)
+ // Determine which org we're updating for the failure message
+ orgName := ""
+ if githubOrg != nil && githubOrg.Name != "" {
+ orgName = githubOrg.Name
+ } else if codebergOrg != nil && codebergOrg.Name != "" {
+ orgName = codebergOrg.Name
+ }
+ failedAIGenerations = append(failedAIGenerations, fmt.Sprintf("%s/%s:%s", orgName, repoName, tag))
+ // Save cache after clearing the failed entry
+ saveAIReleaseNotesCache(cacheFile, aiReleaseNotesCache)
continue
}
aiReleaseNotesCache[cacheKey] = aiNotes // Cache only on success
@@ -443,6 +475,18 @@ func HandleCheckReleasesForRepos(cfg *config.Config, flags *Flags, repositories
aiNotes, err = releaseManager.GenerateAIReleaseNotes(repoPath, repoName, tag, localTags, commits)
if err != nil {
fmt.Printf(" Warning: Failed to generate AI release notes: %v\n", err)
+ // Clear cache on failure and track
+ delete(aiReleaseNotesCache, cacheKey)
+ // Determine which org we're updating for the failure message
+ orgName := ""
+ if githubOrg != nil && githubOrg.Name != "" {
+ orgName = githubOrg.Name
+ } else if codebergOrg != nil && codebergOrg.Name != "" {
+ orgName = codebergOrg.Name
+ }
+ failedAIGenerations = append(failedAIGenerations, fmt.Sprintf("%s/%s:%s", orgName, repoName, tag))
+ // Save cache after clearing the failed entry
+ saveAIReleaseNotesCache(cacheFile, aiReleaseNotesCache)
continue
}
aiReleaseNotesCache[cacheKey] = aiNotes // Cache only on success