From 7b155e62a7e7a994b97e6b4ac31a6d082cd415f5 Mon Sep 17 00:00:00 2001 From: t-kikuc Date: Wed, 6 Nov 2024 17:58:41 +0900 Subject: [PATCH] refactor: use noChange variable Signed-off-by: t-kikuc --- pkg/app/piped/eventwatcher/eventwatcher.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/app/piped/eventwatcher/eventwatcher.go b/pkg/app/piped/eventwatcher/eventwatcher.go index e24a3893f3..8689e04497 100644 --- a/pkg/app/piped/eventwatcher/eventwatcher.go +++ b/pkg/app/piped/eventwatcher/eventwatcher.go @@ -391,7 +391,8 @@ func (w *watcher) execute(ctx context.Context, repo git.Repo, repoID string, eve switch handler.Type { case config.EventWatcherHandlerTypeGitUpdate: branchName, err := w.commitFiles(ctx, latestEvent, matcher.Name, handler.Config.CommitMessage, e.GitPath, handler.Config.Replacements, tmpRepo, handler.Config.MakePullRequest) - if err != nil && !errors.Is(err, errNoChanges) { + noChange := errors.Is(err, errNoChanges) + if err != nil && !noChange { w.logger.Error("failed to commit outdated files", zap.Error(err)) handledEvent := &pipedservice.ReportEventStatusesRequest_Event{ Id: latestEvent.Id, @@ -406,7 +407,7 @@ func (w *watcher) execute(ctx context.Context, repo git.Repo, repoID string, eve Id: latestEvent.Id, Status: model.EventStatus_EVENT_SUCCESS, } - if errors.Is(err, errNoChanges) { + if noChange { handledEvent.StatusDescription = "Nothing to commit" gitNoChangeEvents = append(gitNoChangeEvents, handledEvent) } else {