class Aid::Scripts::Review::PullRequest

Attributes

id[R]
title[R]
url[R]

Public Class Methods

new(id:, title:, repo_name:) click to toggle source
# File lib/aid/scripts/review.rb, line 278
def initialize(id:, title:, repo_name:)
  @id = id
  @title = title
  @url = "https://github.com/#{repo_name}/pull/#{id}"
end

Public Instance Methods

mark_ready_for_review!() click to toggle source

rubocop:disable Metrics/MethodLength

# File lib/aid/scripts/review.rb, line 285
        def mark_ready_for_review!
          cmd = <<~CMD
            hub api graphql \
              -H "Accept: application/vnd.github.shadow-cat-preview+json" \
              -f query='
                mutation MarkPullRequestReady {
                  markPullRequestReadyForReview(
                    input: {
                      pullRequestId:"#{graphql_id}"
                    }
                  ) {
                    pullRequest {
                      isDraft
                      number
                    }
                  }
                }
              '
          CMD

          `#{cmd}`
        end

Private Instance Methods

find_graphql_id() click to toggle source
# File lib/aid/scripts/review.rb, line 314
        def find_graphql_id
          cmd = <<~CMD
            hub api graphql -f query='
              query FindPullRequestId {
                repository(owner:"abtion", name:"verisure") {
                  pullRequests(states:OPEN, first: 25) {
                    nodes {
                      id
                      number
                    }
                  }
                }
              }
            '
          CMD

          json = `#{cmd}`.strip
          response = JSON.parse(json)

          pull_requests = response.dig(
            "data",
            "repository",
            "pullRequests",
            "nodes"
          )

          request = pull_requests.find { |pr| pr["number"].to_s == id.to_s }
          request["id"]
        end
graphql_id() click to toggle source
# File lib/aid/scripts/review.rb, line 310
def graphql_id
  @graphql_id ||= find_graphql_id
end