diff --git a/pkg/app/piped/eventwatcher/eventwatcher.go b/pkg/app/piped/eventwatcher/eventwatcher.go index f9d34f01eb..f29b244e20 100644 --- a/pkg/app/piped/eventwatcher/eventwatcher.go +++ b/pkg/app/piped/eventwatcher/eventwatcher.go @@ -198,12 +198,14 @@ func (w *watcher) run(ctx context.Context, repo git.Repo, repoCfg config.PipedRe w.logger.Info("Try to re-clone because it's more likely to be unable to pull the next time too", zap.String("repo-id", repoCfg.RepoID), ) - repo, err = w.cloneRepo(ctx, repoCfg) + newRepo, err := w.cloneRepo(ctx, repoCfg) if err != nil { w.logger.Error("failed to re-clone repository", zap.String("repo-id", repoCfg.RepoID), zap.Error(err), ) + } else { + repo = newRepo } continue } diff --git a/pkg/app/pipedv1/eventwatcher/eventwatcher.go b/pkg/app/pipedv1/eventwatcher/eventwatcher.go index ac749bf94e..96adf31450 100644 --- a/pkg/app/pipedv1/eventwatcher/eventwatcher.go +++ b/pkg/app/pipedv1/eventwatcher/eventwatcher.go @@ -194,12 +194,14 @@ func (w *watcher) run(ctx context.Context, repo git.Repo, repoCfg config.PipedRe w.logger.Info("Try to re-clone because it's more likely to be unable to pull the next time too", zap.String("repo-id", repoCfg.RepoID), ) - repo, err = w.cloneRepo(ctx, repoCfg) + newRepo, err := w.cloneRepo(ctx, repoCfg) if err != nil { w.logger.Error("failed to re-clone repository", zap.String("repo-id", repoCfg.RepoID), zap.Error(err), ) + } else { + repo = newRepo } continue }