Sha256: 1eb7d4c008cf55c03f131589b6da2f4316e6e357377ec2cf18bd759eac8c7f0c

Contents?: true

Size: 1.28 KB

Versions: 14

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

require 'gitlab'

module GitlabQuality
  module TestTooling
    module GitlabClient
      class MergeRequest
        def initialize(token:, project:, merge_request_iid:)
          @token = token
          @project = project
          @merge_request_iid = merge_request_iid
        end

        def find_merge_request
          client.merge_request_changes(project, merge_request_iid)
        end

        def merge_request_changed_files
          find_merge_request["changes"].map do |change|
            change["new_path"]
          end
        end

        def find_note(body:)
          client.merge_request_notes(project, merge_request_iid, per_page: 100).auto_paginate.find do |mr_note|
            mr_note['body'] =~ /#{body}/
          end
        end

        def create_note(note:)
          client.create_merge_request_note(project, merge_request_iid, note)
        end

        def update_note(id:, note:)
          client.edit_merge_request_note(project, merge_request_iid, id, note)
        end

        private

        attr_reader :project, :token, :merge_request_iid

        def client
          @client ||= Gitlab.client(
            endpoint: Runtime::Env.gitlab_api_base,
            private_token: token
          )
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
gitlab_quality-test_tooling-1.9.0 lib/gitlab_quality/test_tooling/gitlab_client/merge_request.rb
gitlab_quality-test_tooling-1.8.1 lib/gitlab_quality/test_tooling/gitlab_client/merge_request.rb
gitlab_quality-test_tooling-1.8.0 lib/gitlab_quality/test_tooling/gitlab_client/merge_request.rb
gitlab_quality-test_tooling-1.7.0 lib/gitlab_quality/test_tooling/gitlab_client/merge_request.rb
gitlab_quality-test_tooling-1.5.4 lib/gitlab_quality/test_tooling/gitlab_client/merge_request.rb
gitlab_quality-test_tooling-1.5.3 lib/gitlab_quality/test_tooling/gitlab_client/merge_request.rb
gitlab_quality-test_tooling-1.5.2 lib/gitlab_quality/test_tooling/gitlab_client/merge_request.rb
gitlab_quality-test_tooling-1.5.1 lib/gitlab_quality/test_tooling/gitlab_client/merge_request.rb
gitlab_quality-test_tooling-1.5.0 lib/gitlab_quality/test_tooling/gitlab_client/merge_request.rb
gitlab_quality-test_tooling-1.4.0 lib/gitlab_quality/test_tooling/gitlab_client/merge_request.rb
gitlab_quality-test_tooling-1.3.0 lib/gitlab_quality/test_tooling/gitlab_client/merge_request.rb
gitlab_quality-test_tooling-1.2.0 lib/gitlab_quality/test_tooling/gitlab_client/merge_request.rb
gitlab_quality-test_tooling-1.1.0 lib/gitlab_quality/test_tooling/gitlab_client/merge_request.rb
gitlab_quality-test_tooling-1.0.0 lib/gitlab_quality/test_tooling/gitlab_client/merge_request.rb