Class: PrComet::Github::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/pr_comet/github/client.rb

Overview

GitHub API Client

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(access_token, remote_url) ⇒ Client

Returns a new instance of Client.



9
10
11
12
# File 'lib/pr_comet/github/client.rb', line 9

def initialize(access_token, remote_url)
  @client = Octokit::Client.new(access_token: access_token)
  @repository = remote_url.match(REPOSITORY_MATCHER)[:repository]
end

Instance Attribute Details

#repositoryObject (readonly)

Returns the value of attribute repository.



7
8
9
# File 'lib/pr_comet/github/client.rb', line 7

def repository
  @repository
end

Instance Method Details

#add_labels(issue_number, *labels) ⇒ Object

Description of #add_labels

Parameters:

  • issue_number (Integer)

    Number ID of the issue (or pull request)

  • labels (Array<String>)

    An array of labels to apply to this Issue



31
32
33
# File 'lib/pr_comet/github/client.rb', line 31

def add_labels(issue_number, *labels)
  client.add_labels_to_an_issue(repository, issue_number, labels)
end

#create_pull_request(base:, head:, title:, body:) ⇒ Integer

Create a pull request

Parameters:

  • base (String)

    The branch you want your changes pulled into

  • head (String)

    The branch where your changes are implemented

  • title (String)

    Title for the pull request

  • body (String)

    The body for the pull request

Returns:

  • (Integer)

    Created pull request number



21
22
23
24
25
# File 'lib/pr_comet/github/client.rb', line 21

def create_pull_request(base:, head:, title:, body:)
  response =
    client.create_pull_request(repository, base, head, title, body)
  response.number
end