diff options
| author | Paul Buetow <paul@buetow.org> | 2025-10-31 20:13:32 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-10-31 20:13:32 +0200 |
| commit | 11eea6a82cbfdde40ec1457c6ea080da4da6b7dc (patch) | |
| tree | 8026068f6a3beb3ee02c45f06f4487f4b89caaf1 /internal/showcase/metadata.go | |
| parent | 5c3e0b5cf99d028c4f06be7a825388b296e37a22 (diff) | |
feat: implement amp AI tool support and replace Taskfile with Magev0.10.0
- Add amp as default AI tool for release notes and showcase generation
- Fallback chain: amp → hexai → claude → aichat
- Replace Taskfile.yaml with magefile.go for build automation
- Update all documentation (README.md, AGENTS.md, doc/development.md)
- Update version to 0.10.0
Amp-Thread-ID: https://ampcode.com/threads/T-735ba1e2-0255-4b43-8ed1-6c0d2f78301b
Co-authored-by: Amp <amp@ampcode.com>
Diffstat (limited to 'internal/showcase/metadata.go')
| -rw-r--r-- | internal/showcase/metadata.go | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/internal/showcase/metadata.go b/internal/showcase/metadata.go index ca8af05..147e714 100644 --- a/internal/showcase/metadata.go +++ b/internal/showcase/metadata.go @@ -22,8 +22,8 @@ type RepoMetadata struct { Languages []LanguageStats // Programming languages with usage statistics Documentation []LanguageStats // Documentation/text files with usage statistics CommitCount int - LinesOfCode int // Lines of code (excluding documentation) - LinesOfDocs int // Lines of documentation + LinesOfCode int // Lines of code (excluding documentation) + LinesOfDocs int // Lines of documentation FirstCommitDate string LastCommitDate string License string @@ -58,7 +58,7 @@ func extractRepoMetadata(repoPath string) (*RepoMetadata, error) { loc += lang.Lines } metadata.LinesOfCode = loc - + locDocs := 0 for _, doc := range metadata.Documentation { locDocs += doc.Lines @@ -101,7 +101,6 @@ func extractRepoMetadata(repoPath string) (*RepoMetadata, error) { return metadata, nil } - // getCommitCount returns the total number of commits func getCommitCount(repoPath string) (int, error) { cmd := exec.Command("git", "-C", repoPath, "rev-list", "--all", "--count") @@ -126,7 +125,7 @@ func countLinesOfCode(repoPath string) (int, error) { `cd "%s" && git ls-files | grep -E '\.(go|py|js|ts|java|c|cpp|h|hpp|cs|rb|php|swift|kt|rs|scala|r|sh|bash|zsh|pl|lua|vim|el|clj|hs|ml|ex|exs|dart|jl|nim|v|zig|html|css|scss|sass|json|xml|yaml|yml|toml|ini|conf|cfg)$' | xargs wc -l 2>/dev/null | tail -n 1 | awk '{print $1}'`, repoPath, )) - + output, err := cmd.Output() if err != nil { // Fallback: try a simpler approach @@ -264,12 +263,12 @@ func getAverageCommitAge(repoPath string, commitCount int) (float64, error) { if line == "" { continue } - + timestamp, err := strconv.ParseInt(line, 10, 64) if err != nil { continue } - + age := (now - float64(timestamp)) / 86400 // Convert to days totalAge += age validCommits++ @@ -310,12 +309,12 @@ func getLatestTag(repoPath string) (string, string, bool, error) { break } } - + if latestTag == "" { // No version-like tags found return "", "", false, nil } - + // Get the date of the latest tag cmd = exec.Command("git", "-C", repoPath, "log", "-1", "--format=%ai", latestTag) dateOutput, err := cmd.Output() @@ -323,7 +322,7 @@ func getLatestTag(repoPath string) (string, string, bool, error) { // Tag exists but couldn't get date return latestTag, "", true, nil } - + // Extract just the date part (YYYY-MM-DD) parts := strings.Fields(string(dateOutput)) tagDate := "" @@ -339,24 +338,24 @@ func getLatestTag(repoPath string) (string, string, bool, error) { func isVersionTag(tag string) bool { // Remove 'v' prefix if present versionStr := strings.TrimPrefix(tag, "v") - + // Check if the remaining string contains at least one digit and one dot hasDigit := false hasDot := false - + for _, ch := range versionStr { if ch >= '0' && ch <= '9' { hasDigit = true } else if ch == '.' { hasDot = true - } else if ch != '-' && ch != '+' && ch != '_' && - (ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z') { + } else if ch != '-' && ch != '+' && ch != '_' && + (ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z') { // Allow alphanumeric characters and common separators // but anything else makes it not a version return false } } - + // Must have at least one digit, and either: // - have a dot (e.g., 1.0, 0.1.2) // - be just digits (e.g., 2, 2024) @@ -367,6 +366,6 @@ func isVersionTag(tag string) bool { return true } } - + return hasDigit && hasDot -}
\ No newline at end of file +} |
