Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Exceptions are acceptable depending on the circumstances (critical bug fixes tha
- changed `DefaultCommandRunner.RunInteractive` to use `sh -c` for proper shell operator support (redirection, pipes)
- changed the Go module dependencies to their latest versions
- changed the Go module dependencies to their latest versions
- changed per-repo logging in parallel operations to run inside goroutines for progressive feedback

## [0.4.0] - 2026-03-31

Expand Down
11 changes: 6 additions & 5 deletions internal/repo/failover.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ func RunFailover(cfg FailoverConfig) error {
go func(idx int, path string) {
defer wg.Done()
defer func() { <-sem }()
results[idx] = failoverSingleRepo(path, cfg.RootDir, cfg.Runner)
result := failoverSingleRepo(path, cfg.RootDir, cfg.Runner)
log.WithFields(logger.Fields{
"repo": result.Name,
"status": result.Status,
}).Info(result.Status)
results[idx] = result
}(i, repoPath)
}

Expand All @@ -59,10 +64,6 @@ func RunFailover(cfg FailoverConfig) error {

counts := map[string]int{"switched": 0, "skipped": 0, "failed": 0}
for _, r := range results {
log.WithFields(logger.Fields{
"repo": r.Name,
"status": r.Status,
}).Info(r.Status)
category, known := failoverStatusCategory[r.Status]
if !known {
category = "failed"
Expand Down
12 changes: 6 additions & 6 deletions internal/repo/fork_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,12 @@ func parallelForkSync(forks []globalEntities.Repository, cfg ForkSyncConfig) []F
defer wg.Done()
defer func() { <-sem }()
repoPath := filepath.Join(cfg.RootDir, Key(fork))
results[idx] = ForkSyncSingleRepo(repoPath, fork, cfg)
result := ForkSyncSingleRepo(repoPath, fork, cfg)
cfg.Output.WithFields(logger.Fields{
"repo": result.Name,
"status": result.Status,
}).Info("fork-sync result")
results[idx] = result
}(i, f)
}

Expand Down Expand Up @@ -307,11 +312,6 @@ func restoreAfterForkSync(
func logForkSyncSummary(results []ForkSyncResult, log logger.FieldLogger) {
synced, conflicts, failed := 0, 0, 0
for _, r := range results {
log.WithFields(logger.Fields{
"repo": r.Name,
"status": r.Status,
}).Info("fork-sync result")

switch {
case strings.HasPrefix(r.Status, "synced"):
synced++
Expand Down
11 changes: 6 additions & 5 deletions internal/repo/mirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,12 @@ func RunMirror(cfg MirrorConfig) error {
defer wg.Done()
defer func() { <-sem }()
time.Sleep(time.Duration(idx) * mirrorAPIDelay / time.Duration(workers))
results[idx] = mirrorSingleRepo(path, cfg, providerName, owner, mirrorProvider)
result := mirrorSingleRepo(path, cfg, providerName, owner, mirrorProvider)
log.WithFields(logger.Fields{
"repo": result.Name,
"status": result.Status,
}).Info(result.Status)
results[idx] = result
}(i, repoPath)
}

Expand All @@ -100,10 +105,6 @@ func RunMirror(cfg MirrorConfig) error {

counts := map[string]int{"mirrored": 0, "skipped": 0, mirrorStatusFailed: 0}
for _, r := range results {
log.WithFields(logger.Fields{
"repo": r.Name,
"status": r.Status,
}).Info(r.Status)
category, known := mirrorStatusCategory[r.Status]
if !known {
category = mirrorStatusFailed
Expand Down
26 changes: 14 additions & 12 deletions internal/repo/prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ type PruneResult struct {
Status string
}

// isPruneFailure returns true if the given status string indicates a failure.
func isPruneFailure(status string) bool {
return strings.HasPrefix(status, "FAIL") || strings.Contains(strings.ToLower(status), "failed")
}

// RunPrune deletes merged branches in all repositories under rootDir in parallel.
func RunPrune(rootDir string, runner GitRunner, dryRun bool, output io.Writer) error {
log := NewLogger(output)
Expand Down Expand Up @@ -46,26 +51,23 @@ func RunPrune(rootDir string, runner GitRunner, dryRun bool, output io.Writer) e
defer wg.Done()
defer func() { <-sem }()
repoPath := filepath.Join(rootDir, name)
results[idx] = PruneSingleRepo(repoPath, rootDir, runner, dryRun)
result := PruneSingleRepo(repoPath, rootDir, runner, dryRun)
if len(result.Deleted) > 0 || isPruneFailure(result.Status) {
log.WithFields(logger.Fields{
"repo": result.Name,
"status": result.Status,
}).Info("prune result")
}
results[idx] = result
}(i, repoName)
}

wg.Wait()

pruned, skipped, failed := 0, 0, 0
for _, r := range results {
statusLower := strings.ToLower(r.Status)
hasFailure := strings.HasPrefix(r.Status, "FAIL") || strings.Contains(statusLower, "failed")

if len(r.Deleted) > 0 || hasFailure {
log.WithFields(logger.Fields{
"repo": r.Name,
"status": r.Status,
}).Info("prune result")
}

switch {
case hasFailure:
case isPruneFailure(r.Status):
failed++
case len(r.Deleted) > 0:
pruned += len(r.Deleted)
Expand Down
11 changes: 6 additions & 5 deletions internal/repo/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ func RunRestore(cfg RestoreConfig) error {
go func(idx int, path string) {
defer wg.Done()
defer func() { <-sem }()
results[idx] = restoreSingleRepo(path, cfg.RootDir, cfg.Runner)
result := restoreSingleRepo(path, cfg.RootDir, cfg.Runner)
log.WithFields(logger.Fields{
"repo": result.Name,
"status": result.Status,
}).Info(result.Status)
results[idx] = result
}(i, repoPath)
}

Expand All @@ -58,10 +63,6 @@ func RunRestore(cfg RestoreConfig) error {

counts := map[string]int{"restored": 0, "skipped": 0, "failed": 0}
for _, r := range results {
log.WithFields(logger.Fields{
"repo": r.Name,
"status": r.Status,
}).Info(r.Status)
category, known := restoreStatusCategory[r.Status]
if !known {
category = "failed"
Expand Down
11 changes: 6 additions & 5 deletions internal/repo/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,19 @@ func RunSync(rootDir string, runner GitRunner, output io.Writer) error {
go func(idx int, path string) {
defer wg.Done()
defer func() { <-sem }()
results[idx] = SyncSingleRepo(path, rootDir, runner)
result := SyncSingleRepo(path, rootDir, runner)
log.WithFields(logger.Fields{
"repo": result.Name,
"status": result.Status,
}).Info("sync result")
results[idx] = result
}(i, repoPath)
}

wg.Wait()

synced, wip, failed := 0, 0, 0
for _, r := range results {
log.WithFields(logger.Fields{
"repo": r.Name,
"status": r.Status,
}).Info("sync result")
switch {
case strings.HasPrefix(r.Status, "synced"):
synced++
Expand Down
Loading