Skip to content

Commit

Permalink
refactor: use noChange variable
Browse files Browse the repository at this point in the history
Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
  • Loading branch information
t-kikuc committed Nov 6, 2024
1 parent 723393b commit 7b155e6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/app/piped/eventwatcher/eventwatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Check warning on line 395 in pkg/app/piped/eventwatcher/eventwatcher.go

View check run for this annotation

Codecov / codecov/patch

pkg/app/piped/eventwatcher/eventwatcher.go#L394-L395

Added lines #L394 - L395 were not covered by tests
w.logger.Error("failed to commit outdated files", zap.Error(err))
handledEvent := &pipedservice.ReportEventStatusesRequest_Event{
Id: latestEvent.Id,
Expand All @@ -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 {
Expand Down

0 comments on commit 7b155e6

Please sign in to comment.