-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Skip commit and push when no replacement happens in EventWatcher #5310
Conversation
Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5310 +/- ##
==========================================
+ Coverage 25.23% 25.26% +0.03%
==========================================
Files 444 444
Lines 47480 47528 +48
==========================================
+ Hits 11982 12010 +28
- Misses 34556 34575 +19
- Partials 942 943 +1 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got your point, thanks 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the imporvement! I left an imo comment
@@ -388,7 +391,7 @@ 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 { | |||
if err != nil && !errors.Is(err, errNoChanges) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[IMO] How about using the bool variable like change
to minimize the scope of the error variable and also for the readability?
if err != nil && !errors.Is(err, errNoChanges) { | |
noChange := false | |
if err != nil { | |
// | |
if errors.Is(err, errNoChanges) { | |
noChange = true | |
} else { | |
... | |
continue | |
} | |
} | |
if noChange { | |
handledEvent.StatusDescription = "Nothing to commit" | |
gitNoChangeEvents = append(gitNoChangeEvents, handledEvent) | |
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you , got it, i fixed in 7b155e6
Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* fix: skip push if no diff exist Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * modify message Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * refactor: use noChange variable Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> --------- Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> Signed-off-by: pipecd-bot <pipecd.dev@gmail.com>
* Add event context (#5295) * Add contexts to the RegisterEventRequest Signed-off-by: Yoshiki Fujikane <ffjlabo@gmail.com> * Add contexts to model.Event Signed-off-by: Yoshiki Fujikane <ffjlabo@gmail.com> * Store event context in Control Plane Signed-off-by: Yoshiki Fujikane <ffjlabo@gmail.com> * Add trailers when commiting on event watcher Signed-off-by: Yoshiki Fujikane <ffjlabo@gmail.com> * Fix for failed build Signed-off-by: Yoshiki Fujikane <ffjlabo@gmail.com> --------- Signed-off-by: Yoshiki Fujikane <ffjlabo@gmail.com> Signed-off-by: pipecd-bot <pipecd.dev@gmail.com> * Add docs for pipectl event register --contexts on the event watcher usage page (#5299) * Add docs for pipectl event register --contexts on the event watcher usage page Signed-off-by: Yoshiki Fujikane <ffjlabo@gmail.com> * Fix docs Signed-off-by: Yoshiki Fujikane <ffjlabo@gmail.com> * Fix command Signed-off-by: Yoshiki Fujikane <ffjlabo@gmail.com> --------- Signed-off-by: Yoshiki Fujikane <ffjlabo@gmail.com> Signed-off-by: pipecd-bot <pipecd.dev@gmail.com> * Clone manifests not to modify original manifests (#5306) Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> Signed-off-by: pipecd-bot <pipecd.dev@gmail.com> * Lambda: clone manifests not to modify original manifests (#5308) Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> Signed-off-by: pipecd-bot <pipecd.dev@gmail.com> * Skip commit and push when no replacement happens in EventWatcher (#5310) * fix: skip push if no diff exist Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * modify message Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> * refactor: use noChange variable Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> --------- Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> Signed-off-by: pipecd-bot <pipecd.dev@gmail.com> * Execute git clean partially when drift detection for every app is done (#5312) * Execute git clean partially when drift detection for every app is done Signed-off-by: Yoshiki Fujikane <ffjlabo@gmail.com> * Rename to CleanPath Signed-off-by: Yoshiki Fujikane <ffjlabo@gmail.com> * Add test for the outside dir pattern Signed-off-by: Yoshiki Fujikane <ffjlabo@gmail.com> --------- Signed-off-by: Yoshiki Fujikane <ffjlabo@gmail.com> Signed-off-by: pipecd-bot <pipecd.dev@gmail.com> * Update RELEASE and docs to v0.49.3 (#5315) Signed-off-by: Yoshiki Fujikane <ffjlabo@gmail.com> Signed-off-by: pipecd-bot <pipecd.dev@gmail.com> --------- Signed-off-by: Yoshiki Fujikane <ffjlabo@gmail.com> Signed-off-by: pipecd-bot <pipecd.dev@gmail.com> Signed-off-by: t-kikuc <tkikuchi07f@gmail.com> Co-authored-by: Yoshiki Fujikane <40124947+ffjlabo@users.noreply.github.com> Co-authored-by: Tetsuya Kikuchi <97105818+t-kikuc@users.noreply.github.com>
What this PR does:
Why we need it:
Before fix:
Failed to push changed files: err: exit status 128, out: fatal: invalid refspec ''
After fix:
Nothing to commit
branchName
will be nil as below.pipecd/pkg/app/piped/eventwatcher/eventwatcher.go
Lines 643 to 645 in d7f4369
Which issue(s) this PR fixes:
Does this PR introduce a user-facing change?: