@@ -94,9 +94,10 @@ def find_distinct_pacts_between consumer, options
94
94
distinct
95
95
end
96
96
97
- def pact_has_changed_since_previous_version? pact
97
+ # TODO also take into account overridden revisions
98
+ def pact_is_new_or_pact_has_changed_since_previous_version? pact
98
99
previous_pact = pact_repository . find_previous_pact pact
99
- previous_pact && pact . json_content != previous_pact . json_content
100
+ previous_pact . nil? || pact . json_content != previous_pact . json_content
100
101
end
101
102
102
103
private
@@ -108,6 +109,8 @@ def update_pact params, existing_pact
108
109
109
110
if existing_pact . json_content != updated_pact . json_content
110
111
webhook_service . execute_webhooks updated_pact , nil , PactBroker ::Webhooks ::WebhookEvent ::CONTRACT_CONTENT_CHANGED
112
+ else
113
+ logger . debug "Pact has not changed since previous revision, not triggering webhooks"
111
114
end
112
115
113
116
updated_pact
@@ -122,8 +125,11 @@ def create_pact params, version, provider
122
125
end
123
126
124
127
def trigger_webhooks pact
125
- if pact_has_changed_since_previous_version? pact
128
+ # TODO add tests for this
129
+ if pact_is_new_or_pact_has_changed_since_previous_version? ( pact )
126
130
webhook_service . execute_webhooks pact , nil , PactBroker ::Webhooks ::WebhookEvent ::CONTRACT_CONTENT_CHANGED
131
+ else
132
+ logger . debug "Pact has not changed since previous version, not triggering webhooks"
127
133
end
128
134
end
129
135
end
0 commit comments