prontolabs/pronto

View on GitHub
lib/pronto/formatter/gitlab_merge_request_review_formatter.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
94%
module Pronto
  module Formatter
    class GitlabMergeRequestReviewFormatter < PullRequestFormatter
      def self.name
        'gitlab_mr'
      end

      def client_module
        Gitlab
      end

      def pretty_name
        'Gitlab'
      end

      def existing_comments(_, client, repo)
        sha = repo.head_commit_sha
        comments = client.pull_comments(sha)
        grouped_comments(comments)
      end

      def submit_comments(client, comments)
        client.create_pull_request_review(comments)
      rescue => e
        $stderr.puts "Failed to post: #{e.message}"
      end

      def line_number(message, _)
        message.line.line.new_lineno if message.line
      end
    end
  end
end

Pronto::Formatter.register(Pronto::Formatter::GitlabMergeRequestReviewFormatter)