Sha256: 1ded829b40dcfa7bfd64bf24a3f6e5d4b6d4959ad12e55e245bf35fddccc2ca2

Contents?: true

Size: 1.41 KB

Versions: 1

Compression:

Stored size: 1.41 KB

Contents

module Lita
  module GithubPrList
    class CheckList
      attr_accessor :request, :response, :payload, :redis, :comment_body, :comment_id, :issue_owner,
                    :issue_title, :issue_html_url, :repo_name, :github_token, :github_client

      def initialize(params = {})
        self.github_token = params.fetch(:github_token, nil)
        self.response = params.fetch(:response, nil)
        self.request = params.fetch(:request, nil)
        self.redis = params.fetch(:redis, nil)

        raise "invalid params in #{self.class.name}" if response.nil? || request.nil? || redis.nil?

        self.github_client = Octokit::Client.new(access_token: github_token, auto_paginate: true)

        list = "- [ ] Change log
                - [ ] Demo page
                - [ ] Product owner signoff
                - [ ] Merge into master
                - [ ] Deploy to production "

        self.payload = JSON.parse(request.body.read)
        self.comment_body = "#{payload["comment"]["body"]} #{list}"
        self.comment_id = payload["comment"]["id"]
        self.issue_owner = payload["pull_request"]["user"]["login"]
        self.issue_title = payload["pull_request"]["title"]
        self.issue_html_url = payload["pull_request"]["html_url"]
        self.repo_name = payload["pull_request"]["head"]["full_name"]

        github_client.update_comment("octokit/octokit.rb", comment_id.to_i, comment_body)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lita-github_pr_list-0.0.7 lib/lita/github_pr_list/check_list.rb