summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-06-23 23:57:43 +0300
committerPaul Buetow <paul@buetow.org>2025-06-23 23:57:43 +0300
commitc3837b71a6c6dbb0292091922d209679533ec90d (patch)
tree96c1ed37ab0a5ceed0cf0a052c9c9d8ce865fbf3 /cmd
parentca38df1f30ddedbbdbf73d1f8d4ddd98b12d3740 (diff)
Add --full flag for bidirectional sync and update module name
- Add --full flag that enables both --sync-codeberg-public and --sync-github-public - Also enables --create-github-repos and --create-codeberg-repos with --full - Update module name from github.com/paul/gitsyncer to codeberg.org/snonux/gitsyncer - Update all import statements to use new module name - Fix sync operations to work together when both are enabled - Add visual separator between sync operations in full mode - Update README with full sync documentation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/gitsyncer/main.go56
1 files changed, 43 insertions, 13 deletions
diff --git a/cmd/gitsyncer/main.go b/cmd/gitsyncer/main.go
index 7130d3f..95305df 100644
--- a/cmd/gitsyncer/main.go
+++ b/cmd/gitsyncer/main.go
@@ -8,11 +8,11 @@ import (
"path/filepath"
"strings"
- "github.com/paul/gitsyncer/internal/codeberg"
- "github.com/paul/gitsyncer/internal/config"
- "github.com/paul/gitsyncer/internal/github"
- "github.com/paul/gitsyncer/internal/sync"
- "github.com/paul/gitsyncer/internal/version"
+ "codeberg.org/snonux/gitsyncer/internal/codeberg"
+ "codeberg.org/snonux/gitsyncer/internal/config"
+ "codeberg.org/snonux/gitsyncer/internal/github"
+ "codeberg.org/snonux/gitsyncer/internal/sync"
+ "codeberg.org/snonux/gitsyncer/internal/version"
)
func main() {
@@ -25,6 +25,7 @@ func main() {
syncAll bool
syncCodebergPublic bool
syncGitHubPublic bool
+ fullSync bool
createGitHubRepos bool
createCodebergRepos bool
dryRun bool
@@ -43,6 +44,7 @@ func main() {
flag.BoolVar(&syncAll, "sync-all", false, "sync all configured repositories")
flag.BoolVar(&syncCodebergPublic, "sync-codeberg-public", false, "sync all public Codeberg repositories to GitHub")
flag.BoolVar(&syncGitHubPublic, "sync-github-public", false, "sync all public GitHub repositories to Codeberg")
+ flag.BoolVar(&fullSync, "full", false, "full bidirectional sync (enables --sync-codeberg-public --sync-github-public --create-github-repos --create-codeberg-repos)")
flag.BoolVar(&createGitHubRepos, "create-github-repos", false, "automatically create missing GitHub repositories")
flag.BoolVar(&createCodebergRepos, "create-codeberg-repos", false, "automatically create missing Codeberg repositories")
flag.BoolVar(&dryRun, "dry-run", false, "show what would be synced without actually syncing")
@@ -50,6 +52,20 @@ func main() {
flag.BoolVar(&testGitHubToken, "test-github-token", false, "test GitHub token authentication")
flag.Parse()
+ // Handle --full flag by enabling all sync operations
+ if fullSync {
+ syncCodebergPublic = true
+ syncGitHubPublic = true
+ createGitHubRepos = true
+ createCodebergRepos = true
+ fmt.Println("Full sync mode enabled:")
+ fmt.Println(" - Sync all public Codeberg repos to GitHub")
+ fmt.Println(" - Sync all public GitHub repos to Codeberg")
+ fmt.Println(" - Create missing GitHub repositories")
+ fmt.Println(" - Create missing Codeberg repositories (when implemented)")
+ fmt.Println()
+ }
+
// Handle version flag
if versionFlag {
fmt.Println(version.GetVersion())
@@ -281,15 +297,18 @@ func main() {
}
if dryRun {
- fmt.Printf("\n[DRY RUN] Would sync %d repositories\n", len(repoNames))
+ fmt.Printf("\n[DRY RUN] Would sync %d repositories from Codeberg to GitHub\n", len(repoNames))
if createGitHubRepos {
fmt.Println("Would create missing GitHub repositories")
}
- os.Exit(0)
+ if !syncGitHubPublic {
+ os.Exit(0)
+ }
}
- // If create-github-repos is enabled, pre-create repos on GitHub
- var githubClient *github.Client
+ if !dryRun {
+ // If create-github-repos is enabled, pre-create repos on GitHub
+ var githubClient *github.Client
if createGitHubRepos {
githubOrg := cfg.FindGitHubOrg()
if githubOrg == nil {
@@ -357,8 +376,16 @@ func main() {
fmt.Printf(" - %s\n", repo)
}
}
+ } // End of if !dryRun
- os.Exit(0)
+ if !syncGitHubPublic {
+ os.Exit(0)
+ }
+
+ // Add separator when doing full sync
+ fmt.Println("\n" + strings.Repeat("=", 70))
+ fmt.Println("=== Continuing with GitHub to Codeberg sync ===")
+ fmt.Println(strings.Repeat("=", 70) + "\n")
}
// Handle sync GitHub public repos
@@ -398,15 +425,16 @@ func main() {
}
if dryRun {
- fmt.Printf("\n[DRY RUN] Would sync %d repositories\n", len(repoNames))
+ fmt.Printf("\n[DRY RUN] Would sync %d repositories from GitHub to Codeberg\n", len(repoNames))
if createCodebergRepos {
fmt.Println("Would create missing Codeberg repositories")
}
os.Exit(0)
}
- // TODO: Add Codeberg API client for repo creation
- if createCodebergRepos {
+ if !dryRun {
+ // TODO: Add Codeberg API client for repo creation
+ if createCodebergRepos {
fmt.Println("WARNING: --create-codeberg-repos is not yet implemented")
fmt.Println(" Repositories must exist on Codeberg before syncing")
}
@@ -444,6 +472,7 @@ func main() {
fmt.Printf(" - %s\n", repo)
}
}
+ } // End of if !dryRun
os.Exit(0)
}
@@ -457,6 +486,7 @@ func main() {
fmt.Println(" gitsyncer --sync-all Sync all configured repositories")
fmt.Println(" gitsyncer --sync-codeberg-public Sync all public Codeberg repositories to GitHub")
fmt.Println(" gitsyncer --sync-github-public Sync all public GitHub repositories to Codeberg")
+ fmt.Println(" gitsyncer --full Full bidirectional sync of all public repos")
fmt.Println(" gitsyncer --list-orgs List configured organizations")
fmt.Println(" gitsyncer --list-repos List configured repositories")
fmt.Println(" gitsyncer --test-github-token Test GitHub token authentication")