retry with event subset for legacy stash versions#90
Merged
bradrydzewski merged 1 commit intodrone:masterfrom Jan 27, 2021
bakito:stash-version
Merged
retry with event subset for legacy stash versions#90bradrydzewski merged 1 commit intodrone:masterfrom bakito:stash-version
bradrydzewski merged 1 commit intodrone:masterfrom
bakito:stash-version
Conversation
Contributor
|
hey there, I appreciate the pull request. I have given this some more thought, and I think we can simplify this a bit without requiring the user provide their bitbucket server version. Also I'm not too keen to add a third party runtime dependency; this library currently does not have any runtime dependencies outside of the Go standard library. I think the easiest solution would be to detect the error in legacy versions of the software and then retry: res, err := s.client.do(ctx, "POST", path, in, out)
+ if err != nil && isUnknownHookEvent(err) {
+ downgradeHookInput(in)
+ res, err = s.client.do(ctx, "POST", path, in, out)
+ }
return convertHook(out), res, err+func isUnknownHookEvent(err error) bool {
+ return strings.Contains(err, "pr:from_ref_updated is unknown")
+}
+
+func downgradeHookInput(in *hookInput) {
+ var events []string
+ for _, event := range in.Events {
+ if event != "pr:from_ref_updated" {
+ events = append(events, event)
+ }
+ }
+ in.Events = events
+} |
Contributor
Author
|
I could successfully verify the simplified implementation in my setup. |
|
Any schedule to have this fix deployed on version 2 or latest? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
stash 7.x supports more hook events that 6.x therefore the event setup should be possible by defining the stash version.
This PR implements the solution proposed here: https://discourse.drone.io/t/attempt-to-enable-repo-on-older-bitbucket-servers-fails/8486
The client is intentionally kept backwards compatible, to not break the drone server when go-scm is updated.