From 595e03597bd75c987fb759371a658f997788fea3 Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Fri, 4 Mar 2022 14:33:09 +1100 Subject: [PATCH] chore: update is_badge_url? with new badge path --- lib/pact_broker/api/pact_broker_urls.rb | 4 ++++ lib/pact_broker/api/paths.rb | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/pact_broker/api/pact_broker_urls.rb b/lib/pact_broker/api/pact_broker_urls.rb index f662b51d1..397e9b708 100644 --- a/lib/pact_broker/api/pact_broker_urls.rb +++ b/lib/pact_broker/api/pact_broker_urls.rb @@ -255,6 +255,10 @@ def templated_can_i_deploy_badge_url pacticipant_name, base_url = "" templated_can_i_deploy_url(pacticipant_name, base_url) + "/badge" end + def templated_can_i_deploy_branch_to_environment_badge_url pacticipant_name, base_url = "" + pacticipant_url_from_params({ pacticipant_name: pacticipant_name }, base_url) + "/branches/{branch}/latest-version/can-i-deploy/to-environment/{environment}/badge" + end + def label_url label, base_url "#{labels_url(label.pacticipant, base_url)}/#{url_encode(label.name)}" end diff --git a/lib/pact_broker/api/paths.rb b/lib/pact_broker/api/paths.rb index 05dff320e..e35aeaa50 100644 --- a/lib/pact_broker/api/paths.rb +++ b/lib/pact_broker/api/paths.rb @@ -3,7 +3,8 @@ module Api module Paths PACT_BADGE_PATH = %r{^/pacts/provider/[^/]+/consumer/.*/badge(?:\.[A-Za-z]+)?$}.freeze MATRIX_BADGE_PATH = %r{^/matrix/provider/[^/]+/latest/[^/]+/consumer/[^/]+/latest/[^/]+/badge(?:\.[A-Za-z]+)?$}.freeze - CAN_I_DEPLOY_BADGE_PATH = %r{^/pacticipants/[^/]+/latest-version/[^/]+/can-i-deploy/to/[^/]+/badge(?:\.[A-Za-z]+)?$}.freeze + CAN_I_DEPLOY_TAG_BADGE_PATH = %r{^/pacticipants/[^/]+/latest-version/[^/]+/can-i-deploy/to/[^/]+/badge(?:\.[A-Za-z]+)?$}.freeze + CAN_I_DEPLOY_BRANCH_ENV_BADGE_PATH = %r{^/pacticipants/[^/]+/branches/[^/]+/latest-version/can-i-deploy/to-environment/[^/]+/badge(?:\.[A-Za-z]+)?$}.freeze VERIFICATION_RESULTS = %r{^/pacts/provider/[^/]+/consumer/[^/]+/pact-version/[^/]+/verification-results/[^/]+} extend self @@ -14,7 +15,7 @@ def is_verification_results_path?(path) def is_badge_path?(path) # Optimise by checking include? first - regexp slow - path.include?("/badge") && (path =~ PACT_BADGE_PATH || path =~ MATRIX_BADGE_PATH || path =~ CAN_I_DEPLOY_BADGE_PATH) + path.include?("/badge") && (path =~ PACT_BADGE_PATH || path =~ MATRIX_BADGE_PATH || path =~ CAN_I_DEPLOY_TAG_BADGE_PATH || path =~ CAN_I_DEPLOY_BRANCH_ENV_BADGE_PATH) end end end