Class: Chandler::GitHub

Inherits:
Object
  • Object
show all
Defined in:
lib/chandler/github.rb,
lib/chandler/github/client.rb,
lib/chandler/github/errors.rb,
lib/chandler/github/remote.rb

Overview

A facade for performing GitHub API operations on a given GitHub repository (specified as a git URL or as ‘owner/repo` format). Requires either that “~/.netrc” is properly configured with GitHub credentials or an auth token is available in the host environment at “CHANDLER_GITHUB_API_TOKEN”“

Defined Under Namespace

Classes: Client, InvalidRepository, NetrcAuthenticationFailure, Remote, TokenAuthenticationFailure

Constant Summary collapse

Error =
Class.new(StandardError)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repository:, config:) ⇒ GitHub

Returns a new instance of GitHub.



14
15
16
17
18
# File 'lib/chandler/github.rb', line 14

def initialize(repository:, config:)
  @repository = repository
  @remote = Remote.parse(repository)
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



12
13
14
# File 'lib/chandler/github.rb', line 12

def config
  @config
end

#repositoryObject (readonly)

Returns the value of attribute repository.



12
13
14
# File 'lib/chandler/github.rb', line 12

def repository
  @repository
end

Instance Method Details

#create_or_update_release(tag:, title:, description:) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/chandler/github.rb', line 20

def create_or_update_release(tag:, title:, description:)
  return if config.dry_run?

  release = existing_release(tag)
  return update_release(release, title, description) if release

  create_release(tag, title, description)
rescue Octokit::NotFound
  raise InvalidRepository, repository
end