Class: PdkSync::GithubClient

Inherits:
Object
  • Object
show all
Defined in:
lib/pdksync/githubclient.rb

Instance Method Summary collapse

Constructor Details

#initialize(access_token) ⇒ GithubClient

Returns a new instance of GithubClient.

Parameters:

  • access_token

    The Github access token, required to access the Github API



13
14
15
16
# File 'lib/pdksync/githubclient.rb', line 13

def initialize(access_token)
  @client = Octokit::Client.new(access_token: access_token.to_s)
  @client.user.
end

Instance Method Details

#create_pull_request(repo_name, create_pr_against, head, title, message) ⇒ Object

Returns An Octokit pull request object for the newly created pull request.

Parameters:

  • repo_name (String)

    The full repository name, i.e. “namespace/repo_name” in which to create the pull request

  • create_pr_against (String)

    The target branch against which to create the pull request

  • head (String)

    The source branch from which to create the pull request

  • title (String)

    The title/name of the pull request to create

  • message (String)

    The pull request message/body

Returns:

  • An Octokit pull request object for the newly created pull request



39
40
41
# File 'lib/pdksync/githubclient.rb', line 39

def create_pull_request(repo_name, create_pr_against, head, title, message)
  @client.create_pull_request(repo_name, create_pr_against, head, title, message)
end

#delete_branch(repo_name, branch_name) ⇒ Boolean

Returns true on success, false on failure.

Parameters:

  • repo_name (String)

    The full repository name, i.e. “namespace/repo_name” in which to delete the branch

  • branch_name (String)

    The name of the branch to delete

Returns:

  • (Boolean)

    true on success, false on failure



72
73
74
# File 'lib/pdksync/githubclient.rb', line 72

def delete_branch(repo_name, branch_name)
  @client.delete_branch(repo_name, branch_name)
end

#labels(repo_name) ⇒ Array

Returns List of available labels in the repository.

Parameters:

  • repo_name (String)

    The full repository name, i.e. “namespace/repo_name”, from which to get the available labels

Returns:

  • (Array)

    List of available labels in the repository



48
49
50
# File 'lib/pdksync/githubclient.rb', line 48

def labels(repo_name)
  @client.labels(repo_name)
end

#repository?(repository) ⇒ Boolean

Returns true if the repository exists, false otherwise.

Parameters:

  • repository (String)

    The full repository name, i.e. “namespace/repo_name”

Returns:

  • (Boolean)

    true if the repository exists, false otherwise



22
23
24
# File 'lib/pdksync/githubclient.rb', line 22

def repository?(repository)
  @client.repository?(repository)
end

#update_issue(repo_name, issue_number, options) ⇒ Object

Returns An Octokit issue object of the updated issue.

Parameters:

  • repo_name (String)

    The full repository name, i.e. “namespace/repo_name” in which to update the issue

  • issue_number (Integer)

    The id number of the issue/pull request to update

  • options (Hash)

    A hash of options definint the changes to the issue

Returns:

  • An Octokit issue object of the updated issue



61
62
63
# File 'lib/pdksync/githubclient.rb', line 61

def update_issue(repo_name, issue_number, options)
  @client.update_issue(repo_name, issue_number, options)
end