diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-29 10:52:50 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-29 10:52:50 +0300 |
| commit | 714e81e56b3e8d49359c8098ec85dbaac8f74d4c (patch) | |
| tree | 9e91ca8cf643449a5a7edca3a4606afe024c6e26 /internal/cli/description_sync.go | |
| parent | 4513ccec70871532b5b06aed3f9ed720abf613ed (diff) | |
refactor(cli): inject repo client factory for mq
Diffstat (limited to 'internal/cli/description_sync.go')
| -rw-r--r-- | internal/cli/description_sync.go | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/internal/cli/description_sync.go b/internal/cli/description_sync.go index 6a83c1e..cb008ca 100644 --- a/internal/cli/description_sync.go +++ b/internal/cli/description_sync.go @@ -8,26 +8,29 @@ import ( "path/filepath" "strings" - "codeberg.org/snonux/gitsyncer/internal/codeberg" "codeberg.org/snonux/gitsyncer/internal/config" - "codeberg.org/snonux/gitsyncer/internal/github" + "codeberg.org/snonux/gitsyncer/internal/forge" ) // 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) { + syncRepoDescriptionsWithFactory(cfg, dryRun, repoName, knownCBDesc, knownGHDesc, cache, cliRepoClientFactory) +} + +func syncRepoDescriptionsWithFactory(cfg *config.Config, dryRun bool, repoName, knownCBDesc, knownGHDesc string, cache map[string]string, factory repoClientFactory) { // Load orgs ghOrg := cfg.FindGitHubOrg() cbOrg := cfg.FindCodebergOrg() - var ghClient *github.Client - var cbClient *codeberg.Client + var ghClient forge.RepoDescriptionClient + var cbClient forge.RepoDescriptionClient if ghOrg != nil { - ghClient = github.NewClient(ghOrg.GitHubToken, ghOrg.Name) + ghClient = factory.NewGitHubDescriptionClient(ghOrg.GitHubToken, ghOrg.Name) } if cbOrg != nil { - cbClient = codeberg.NewClient(cbOrg.CodebergToken, cbOrg.Name) + cbClient = factory.NewCodebergDescriptionClient(cbOrg.CodebergToken, cbOrg.Name) } // Get current descriptions (use known if provided) @@ -36,10 +39,10 @@ func syncRepoDescriptions(cfg *config.Config, dryRun bool, repoName, knownCBDesc var cbExists, ghExists bool if cbDesc == "" && cbClient != nil { - if repo, exists, err := cbClient.GetRepo(repoName); err == nil { + if description, exists, err := cbClient.GetRepoDescription(repoName); err == nil { cbExists = exists if exists { - cbDesc = strings.TrimSpace(repo.Description) + cbDesc = strings.TrimSpace(description) } } else { fmt.Printf(" Warning: Codeberg repo lookup failed: %v\n", err) @@ -50,10 +53,10 @@ func syncRepoDescriptions(cfg *config.Config, dryRun bool, repoName, knownCBDesc if ghClient != nil { if ghDesc == "" || !ghExists { - if repo, exists, err := ghClient.GetRepo(repoName); err == nil { + if description, exists, err := ghClient.GetRepoDescription(repoName); err == nil { ghExists = exists if exists { - ghDesc = strings.TrimSpace(repo.Description) + ghDesc = strings.TrimSpace(description) } } else { fmt.Printf(" Warning: GitHub repo lookup failed: %v\n", err) |
