summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-11 18:17:54 +0200
committerPaul Buetow <paul@buetow.org>2026-03-11 18:17:54 +0200
commit224d9059e5c51eaab9295ea5266c64c4dd7fa218 (patch)
treed289cad6b1c5ea1b9a07bce00ef442dafb27cf0b
parentcac633c48dab06556ee8c1098652ffed23b1e96e (diff)
feat(sync): randomize repository sync orderv0.14.0
-rw-r--r--internal/cli/sync_handlers.go19
-rw-r--r--internal/version/version.go2
2 files changed, 18 insertions, 3 deletions
diff --git a/internal/cli/sync_handlers.go b/internal/cli/sync_handlers.go
index b769b03..2c67518 100644
--- a/internal/cli/sync_handlers.go
+++ b/internal/cli/sync_handlers.go
@@ -3,6 +3,7 @@ package cli
import (
"fmt"
"log"
+ "math/rand"
"strings"
"codeberg.org/snonux/gitsyncer/internal/codeberg"
@@ -85,6 +86,8 @@ func HandleSyncAll(cfg *config.Config, flags *Flags) int {
return 1
}
+ repoNames := shuffledRepoNames(cfg.Repositories)
+
var throttleManager *state.Manager
var throttleState *state.State
if flags.Throttle {
@@ -122,8 +125,8 @@ func HandleSyncAll(cfg *config.Config, flags *Flags) int {
// Load descriptions cache
descCache := loadDescriptionCache(flags.WorkDir)
- for i, repo := range cfg.Repositories {
- fmt.Printf("\n[%d/%d] Syncing %s...\n", i+1, len(cfg.Repositories), repo)
+ for i, repo := range repoNames {
+ fmt.Printf("\n[%d/%d] Syncing %s...\n", i+1, len(repoNames), repo)
if flags.Throttle {
decision := evaluateThrottle(repo, throttleState, flags.DryRun)
@@ -264,6 +267,8 @@ func HandleSyncCodebergPublic(cfg *config.Config, flags *Flags) int {
repoNames = filtered
}
+ repoNames = shuffledRepoNames(repoNames)
+
// Show the repositories that will be synced
showReposToSync(repoNames)
@@ -333,6 +338,8 @@ func HandleSyncGitHubPublic(cfg *config.Config, flags *Flags) int {
repoNames = filtered
}
+ repoNames = shuffledRepoNames(repoNames)
+
// Show the repositories that will be synced
showReposToSync(repoNames)
@@ -435,6 +442,14 @@ func showReposToSync(repoNames []string) {
}
}
+func shuffledRepoNames(repoNames []string) []string {
+ shuffled := append([]string(nil), repoNames...)
+ rand.Shuffle(len(shuffled), func(i, j int) {
+ shuffled[i], shuffled[j] = shuffled[j], shuffled[i]
+ })
+ return shuffled
+}
+
func printFullSyncSeparator() {
fmt.Println("\n" + strings.Repeat("=", 70))
fmt.Println("=== Continuing with GitHub to Codeberg sync ===")
diff --git a/internal/version/version.go b/internal/version/version.go
index 50264bf..8f38a6f 100644
--- a/internal/version/version.go
+++ b/internal/version/version.go
@@ -7,7 +7,7 @@ import (
var (
// Version is the current version of gitsyncer
- Version = "0.13.0"
+ Version = "0.14.0"
// GitCommit is the git commit hash at build time
GitCommit = "unknown"