Sha256: dd5fe364a18849b0eed9a5ba8e76f63560bd3d2c53214946539796409dad86ce

Contents?: true

Size: 1.46 KB

Versions: 11

Compression:

Stored size: 1.46 KB

Contents

require "pact_broker/logging"
require "pact_broker/repositories"
require "pact_broker/messages"
require "forwardable"

module PactBroker
  module Versions
    class BranchService
      extend PactBroker::Repositories

      class << self
        extend Forwardable
        delegate [:delete_branch_version] => :branch_version_repository
      end


      def self.find_branch_version(pacticipant_name:, branch_name:, version_number:, **)
        BranchVersion.where(
          version: PactBroker::Domain::Version.where_pacticipant_name_and_version_number(pacticipant_name, version_number),
          branch: Branch.where(name: branch_name)
        ).single_record
      end

      def self.find_or_create_branch_version(pacticipant_name:, branch_name:, version_number:, **)
        pacticipant = pacticipant_repository.find_by_name_or_create(pacticipant_name)
        version = version_repository.find_by_pacticipant_id_and_number_or_create(pacticipant.id, version_number)
        branch_version_repository.add_branch(version, branch_name)
      end

      def self.find_branch(pacticipant_name:, branch_name:)
        Branch
          .select_all_qualified
          .join(:pacticipants, { Sequel[:branches][:pacticipant_id] => Sequel[:pacticipants][:id] }) do
            PactBroker::Repositories::Helpers.name_like(Sequel[:pacticipants][:name], pacticipant_name)
          end
          .where(Sequel[:branches][:name] => branch_name)
          .single_record
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
pact_broker-2.107.1 lib/pact_broker/versions/branch_service.rb
pact_broker-2.107.0 lib/pact_broker/versions/branch_service.rb
pact_broker-2.107.0.beta.1 lib/pact_broker/versions/branch_service.rb
pact_broker-2.106.0 lib/pact_broker/versions/branch_service.rb
pact_broker-2.105.0 lib/pact_broker/versions/branch_service.rb
pact_broker-2.104.0 lib/pact_broker/versions/branch_service.rb
pact_broker-2.103.0 lib/pact_broker/versions/branch_service.rb
pact_broker-2.102.2 lib/pact_broker/versions/branch_service.rb
pact_broker-2.102.1 lib/pact_broker/versions/branch_service.rb
pact_broker-2.102.0 lib/pact_broker/versions/branch_service.rb
pact_broker-2.101.0 lib/pact_broker/versions/branch_service.rb