summaryrefslogtreecommitdiff
path: root/internal/showcase/metadata.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-07-09 00:04:21 +0300
committerPaul Buetow <paul@buetow.org>2025-07-09 00:04:21 +0300
commitad18b17927c76f052d64313466dc7c117ff7719d (patch)
treee43f3e8ecd694763fed1178702598e4a483d5d38 /internal/showcase/metadata.go
parent6a2c0dc0dc81fcf22c513c5bc54b614ce5fb02f6 (diff)
feat: add SVG image support and experimental project detection
- Fix image extraction regex to handle unquoted HTML img src attributes - Add detection of version tags and experimental status for projects - Display "Experimental (no releases yet)" for projects without tags - Successfully extracts SVG images from projects like ior 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'internal/showcase/metadata.go')
-rw-r--r--internal/showcase/metadata.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/internal/showcase/metadata.go b/internal/showcase/metadata.go
index 13caf9f..9627910 100644
--- a/internal/showcase/metadata.go
+++ b/internal/showcase/metadata.go
@@ -28,6 +28,8 @@ type RepoMetadata struct {
LastCommitDate string
License string
AvgCommitAge float64 // Average age of last 42 commits in days
+ LatestTag string // Latest version tag (empty if no tags)
+ HasReleases bool // Whether the project has any releases/tags
}
// extractRepoMetadata extracts metadata from a repository
@@ -86,6 +88,14 @@ func extractRepoMetadata(repoPath string) (*RepoMetadata, error) {
}
metadata.AvgCommitAge = avgAge
+ // Get latest tag and check for releases
+ latestTag, hasReleases, err := getLatestTag(repoPath)
+ if err != nil {
+ fmt.Printf("Warning: Failed to get latest tag: %v\n", err)
+ }
+ metadata.LatestTag = latestTag
+ metadata.HasReleases = hasReleases
+
return metadata, nil
}
@@ -268,4 +278,28 @@ func getAverageCommitAge(repoPath string, commitCount int) (float64, error) {
}
return totalAge / float64(validCommits), nil
+}
+
+// getLatestTag returns the latest git tag and whether the repo has any releases
+func getLatestTag(repoPath string) (string, bool, error) {
+ // First try to get tags sorted by version
+ cmd := exec.Command("git", "-C", repoPath, "tag", "-l", "--sort=-version:refname")
+ output, err := cmd.Output()
+ if err != nil {
+ // Fallback to describe
+ cmd = exec.Command("git", "-C", repoPath, "describe", "--tags", "--abbrev=0")
+ output, err = cmd.Output()
+ if err != nil {
+ // No tags at all
+ return "", false, nil
+ }
+ }
+
+ tags := strings.Split(strings.TrimSpace(string(output)), "\n")
+ if len(tags) == 0 || tags[0] == "" {
+ return "", false, nil
+ }
+
+ // Return the latest tag
+ return tags[0], true, nil
} \ No newline at end of file