Skip to content

Commit ef5be01

Browse files
takecyclaude
andcommitted
refactor(syncer): drop unused Err field from failed repo records
failedRepo carried both the repo path and the error returned by the git invocation, but the error field was never read after assignment. The per-repo failure reason is already streamed to stderr at execution time via PrintMsgErr ("Failed: <repo>\n<err>"), and printSummary only needs the repo path to print the trailing failed-repo list. Replace the failedRepo struct with a plain []string and update addFailed and the summary printer accordingly. The test that asserted on stats.failed[0].Repo becomes stats.failed[0] — same coverage, slightly cleaner. Reported by GitHub Copilot on PR #26. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent b852302 commit ef5be01

2 files changed

Lines changed: 9 additions & 17 deletions

File tree

syncer/syncer.go

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,14 @@ type Sync struct {
5555
Gitter Executor
5656
}
5757

58-
// failedRepo carries the repository path together with the error that caused
59-
// the failure so that it can be reported in the final summary.
60-
type failedRepo struct {
61-
Repo string
62-
Err error
63-
}
64-
6558
// runStats accumulates per-repository outcomes safely from concurrent goroutines.
59+
// Each bucket is just a list of repository paths — the per-repo error message
60+
// is already streamed to stderr at execution time via PrintMsgErr, so there is
61+
// no need to retain it here.
6662
type runStats struct {
6763
mu sync.Mutex
6864
succeeded []string
69-
failed []failedRepo
65+
failed []string
7066
timedOut []string
7167
}
7268

@@ -76,10 +72,10 @@ func (s *runStats) addSuccess(r string) {
7672
s.succeeded = append(s.succeeded, r)
7773
}
7874

79-
func (s *runStats) addFailed(r string, e error) {
75+
func (s *runStats) addFailed(r string) {
8076
s.mu.Lock()
8177
defer s.mu.Unlock()
82-
s.failed = append(s.failed, failedRepo{Repo: r, Err: e})
78+
s.failed = append(s.failed, r)
8379
}
8480

8581
func (s *runStats) addTimedOut(r string) {
@@ -203,7 +199,7 @@ func (s *Sync) execute(parent context.Context, repos []string, perRepoTimeout ti
203199
stats.addTimedOut(r)
204200
s.Writer.PrintMsgErr(fmt.Sprintf("Timeout: %s", r))
205201
default:
206-
stats.addFailed(r, err)
202+
stats.addFailed(r)
207203
s.Writer.PrintMsgErr(fmt.Sprintf("Failed: %s\n%v", r, err))
208204
}
209205

@@ -245,11 +241,7 @@ func (s *Sync) printSummary(stats *runStats) {
245241
))
246242

247243
if len(stats.failed) > 0 {
248-
repos := make([]string, len(stats.failed))
249-
for i, f := range stats.failed {
250-
repos[i] = f.Repo
251-
}
252-
s.Writer.PrintRepoErr("Failed repositories:", repos)
244+
s.Writer.PrintRepoErr("Failed repositories:", stats.failed)
253245
}
254246
if len(stats.timedOut) > 0 {
255247
s.Writer.PrintRepoErr("Timed out repositories:", stats.timedOut)

syncer/syncer_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func TestSync_Execute(t *testing.T) {
5959
stats := s.execute(context.Background(), []string{"a", "b", "c"}, time.Second)
6060
is.Equal(len(stats.succeeded), 2)
6161
is.Equal(len(stats.failed), 1)
62-
is.Equal(filepath.Base(stats.failed[0].Repo), "b")
62+
is.Equal(filepath.Base(stats.failed[0]), "b")
6363
})
6464

6565
t.Run("timeout is classified separately", func(t *testing.T) {

0 commit comments

Comments
 (0)