Class: Dependabot::PullRequestCreator::Github

Inherits:
Object
  • Object
show all
Defined in:
lib/dependabot/pull_request_creator/github.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source:, branch_name:, base_commit:, credentials:, files:, commit_message:, pr_description:, pr_name:, author_details:, signature_key:, custom_headers:, labeler:, reviewers:, assignees:, milestone:) ⇒ Github

Returns a new instance of Github.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/dependabot/pull_request_creator/github.rb', line 18

def initialize(source:, branch_name:, base_commit:, credentials:,
               files:, commit_message:, pr_description:, pr_name:,
               author_details:, signature_key:, custom_headers:,
               labeler:, reviewers:, assignees:, milestone:)
  @source         = source
  @branch_name    = branch_name
  @base_commit    = base_commit
  @credentials    = credentials
  @files          = files
  @commit_message = commit_message
  @pr_description = pr_description
  @pr_name        = pr_name
  @author_details = author_details
  @signature_key  = signature_key
  @custom_headers = custom_headers
  @labeler        = labeler
  @reviewers      = reviewers
  @assignees      = assignees
  @milestone      = milestone
end

Instance Attribute Details

#assigneesObject (readonly)

Returns the value of attribute assignees.



13
14
15
# File 'lib/dependabot/pull_request_creator/github.rb', line 13

def assignees
  @assignees
end

#author_detailsObject (readonly)

Returns the value of attribute author_details.



13
14
15
# File 'lib/dependabot/pull_request_creator/github.rb', line 13

def author_details
  @author_details
end

#base_commitObject (readonly)

Returns the value of attribute base_commit.



13
14
15
# File 'lib/dependabot/pull_request_creator/github.rb', line 13

def base_commit
  @base_commit
end

#branch_nameObject (readonly)

Returns the value of attribute branch_name.



13
14
15
# File 'lib/dependabot/pull_request_creator/github.rb', line 13

def branch_name
  @branch_name
end

#commit_messageObject (readonly)

Returns the value of attribute commit_message.



13
14
15
# File 'lib/dependabot/pull_request_creator/github.rb', line 13

def commit_message
  @commit_message
end

#credentialsObject (readonly)

Returns the value of attribute credentials.



13
14
15
# File 'lib/dependabot/pull_request_creator/github.rb', line 13

def credentials
  @credentials
end

#custom_headersObject (readonly)

Returns the value of attribute custom_headers.



13
14
15
# File 'lib/dependabot/pull_request_creator/github.rb', line 13

def custom_headers
  @custom_headers
end

#filesObject (readonly)

Returns the value of attribute files.



13
14
15
# File 'lib/dependabot/pull_request_creator/github.rb', line 13

def files
  @files
end

#labelerObject (readonly)

Returns the value of attribute labeler.



13
14
15
# File 'lib/dependabot/pull_request_creator/github.rb', line 13

def labeler
  @labeler
end

#milestoneObject (readonly)

Returns the value of attribute milestone.



13
14
15
# File 'lib/dependabot/pull_request_creator/github.rb', line 13

def milestone
  @milestone
end

#pr_descriptionObject (readonly)

Returns the value of attribute pr_description.



13
14
15
# File 'lib/dependabot/pull_request_creator/github.rb', line 13

def pr_description
  @pr_description
end

#pr_nameObject (readonly)

Returns the value of attribute pr_name.



13
14
15
# File 'lib/dependabot/pull_request_creator/github.rb', line 13

def pr_name
  @pr_name
end

#reviewersObject (readonly)

Returns the value of attribute reviewers.



13
14
15
# File 'lib/dependabot/pull_request_creator/github.rb', line 13

def reviewers
  @reviewers
end

#signature_keyObject (readonly)

Returns the value of attribute signature_key.



13
14
15
# File 'lib/dependabot/pull_request_creator/github.rb', line 13

def signature_key
  @signature_key
end

#sourceObject (readonly)

Returns the value of attribute source.



13
14
15
# File 'lib/dependabot/pull_request_creator/github.rb', line 13

def source
  @source
end

Instance Method Details

#createObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/dependabot/pull_request_creator/github.rb', line 39

def create
  return if branch_exists?(branch_name) && pull_request_exists?

  commit = create_commit
  branch = create_or_update_branch(commit)
  return unless branch

  pull_request = create_pull_request
  return unless pull_request

  annotate_pull_request(pull_request)

  pull_request
rescue Octokit::Error => e
  handle_error(e)
end