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/cli/description_sync.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/cli/description_sync.go')
| -rw-r--r-- | internal/cli/description_sync.go | 185 |
1 files changed, 92 insertions, 93 deletions
diff --git a/internal/cli/description_sync.go b/internal/cli/description_sync.go index ae275ce..4904b56 100644 --- a/internal/cli/description_sync.go +++ b/internal/cli/description_sync.go @@ -1,113 +1,112 @@ package cli import ( - "fmt" - "strings" + "fmt" + "strings" - "codeberg.org/snonux/gitsyncer/internal/codeberg" - "codeberg.org/snonux/gitsyncer/internal/config" - "codeberg.org/snonux/gitsyncer/internal/github" + "codeberg.org/snonux/gitsyncer/internal/codeberg" + "codeberg.org/snonux/gitsyncer/internal/config" + "codeberg.org/snonux/gitsyncer/internal/github" ) // syncRepoDescriptions ensures both platforms have the canonical description // Precedence: Codeberg > GitHub; if Codeberg empty and GitHub has one, use GitHub. // knownCBDesc and knownGHDesc can be empty; the function fetches as needed. func syncRepoDescriptions(cfg *config.Config, dryRun bool, repoName, knownCBDesc, knownGHDesc string, cache map[string]string) { - // Load orgs - ghOrg := cfg.FindGitHubOrg() - cbOrg := cfg.FindCodebergOrg() + // Load orgs + ghOrg := cfg.FindGitHubOrg() + cbOrg := cfg.FindCodebergOrg() - var ghClient *github.Client - var cbClient *codeberg.Client - if ghOrg != nil { - c := github.NewClient(ghOrg.GitHubToken, ghOrg.Name) - ghClient = &c - } - if cbOrg != nil { - c := codeberg.NewClient(cbOrg.Name, cbOrg.CodebergToken) - cbClient = &c - } + var ghClient *github.Client + var cbClient *codeberg.Client + if ghOrg != nil { + c := github.NewClient(ghOrg.GitHubToken, ghOrg.Name) + ghClient = &c + } + if cbOrg != nil { + c := codeberg.NewClient(cbOrg.Name, cbOrg.CodebergToken) + cbClient = &c + } - // Get current descriptions (use known if provided) - cbDesc := strings.TrimSpace(knownCBDesc) - ghDesc := strings.TrimSpace(knownGHDesc) - var cbExists, ghExists bool + // Get current descriptions (use known if provided) + cbDesc := strings.TrimSpace(knownCBDesc) + ghDesc := strings.TrimSpace(knownGHDesc) + var cbExists, ghExists bool - if cbDesc == "" && cbClient != nil { - if repo, exists, err := cbClient.GetRepo(repoName); err == nil { - cbExists = exists - if exists { - cbDesc = strings.TrimSpace(repo.Description) - } - } else { - fmt.Printf(" Warning: Codeberg repo lookup failed: %v\n", err) - } - } else if cbClient != nil { - cbExists = true - } + if cbDesc == "" && cbClient != nil { + if repo, exists, err := cbClient.GetRepo(repoName); err == nil { + cbExists = exists + if exists { + cbDesc = strings.TrimSpace(repo.Description) + } + } else { + fmt.Printf(" Warning: Codeberg repo lookup failed: %v\n", err) + } + } else if cbClient != nil { + cbExists = true + } - if ghClient != nil { - if ghDesc == "" || !ghExists { - if repo, exists, err := ghClient.GetRepo(repoName); err == nil { - ghExists = exists - if exists { - ghDesc = strings.TrimSpace(repo.Description) - } - } else { - fmt.Printf(" Warning: GitHub repo lookup failed: %v\n", err) - } - } - } + if ghClient != nil { + if ghDesc == "" || !ghExists { + if repo, exists, err := ghClient.GetRepo(repoName); err == nil { + ghExists = exists + if exists { + ghDesc = strings.TrimSpace(repo.Description) + } + } else { + fmt.Printf(" Warning: GitHub repo lookup failed: %v\n", err) + } + } + } - // Determine canonical description - canonical := cbDesc - if canonical == "" { - canonical = ghDesc - } - canonical = strings.TrimSpace(canonical) + // Determine canonical description + canonical := cbDesc + if canonical == "" { + canonical = ghDesc + } + canonical = strings.TrimSpace(canonical) - // If nothing to sync, bail - if canonical == "" { - return - } + // If nothing to sync, bail + if canonical == "" { + return + } - // Update Codeberg if needed - if cbClient != nil && cbExists { - if cbDesc != canonical { - if dryRun { - fmt.Printf(" [DRY RUN] Would update Codeberg description for %s -> %q\n", repoName, canonical) - } else if cbClient.HasToken() { - if err := cbClient.UpdateRepoDescription(repoName, canonical); err != nil { - fmt.Printf(" Warning: Failed to update Codeberg description: %v\n", err) - } else { - fmt.Printf(" Updated Codeberg description for %s\n", repoName) - } - } else { - fmt.Println(" Warning: No Codeberg token; cannot update description") - } - } - } + // Update Codeberg if needed + if cbClient != nil && cbExists { + if cbDesc != canonical { + if dryRun { + fmt.Printf(" [DRY RUN] Would update Codeberg description for %s -> %q\n", repoName, canonical) + } else if cbClient.HasToken() { + if err := cbClient.UpdateRepoDescription(repoName, canonical); err != nil { + fmt.Printf(" Warning: Failed to update Codeberg description: %v\n", err) + } else { + fmt.Printf(" Updated Codeberg description for %s\n", repoName) + } + } else { + fmt.Println(" Warning: No Codeberg token; cannot update description") + } + } + } - // Update GitHub if needed - if ghClient != nil && ghExists { - if ghDesc != canonical { - if dryRun { - fmt.Printf(" [DRY RUN] Would update GitHub description for %s -> %q\n", repoName, canonical) - } else if ghClient.HasToken() { - if err := ghClient.UpdateRepoDescription(repoName, canonical); err != nil { - fmt.Printf(" Warning: Failed to update GitHub description: %v\n", err) - } else { - fmt.Printf(" Updated GitHub description for %s\n", repoName) - } - } else { - fmt.Println(" Warning: No GitHub token; cannot update description") - } - } - } + // Update GitHub if needed + if ghClient != nil && ghExists { + if ghDesc != canonical { + if dryRun { + fmt.Printf(" [DRY RUN] Would update GitHub description for %s -> %q\n", repoName, canonical) + } else if ghClient.HasToken() { + if err := ghClient.UpdateRepoDescription(repoName, canonical); err != nil { + fmt.Printf(" Warning: Failed to update GitHub description: %v\n", err) + } else { + fmt.Printf(" Updated GitHub description for %s\n", repoName) + } + } else { + fmt.Println(" Warning: No GitHub token; cannot update description") + } + } + } - // Update cache - if cache != nil { - cache[repoName] = canonical - } + // Update cache + if cache != nil { + cache[repoName] = canonical + } } - |
