Class: Dependabot::PullRequestUpdater::Github

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Includes:
Clients::GithubResourceParser
Defined in:
lib/dependabot/pull_request_updater/github.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source:, base_commit:, old_commit:, files:, credentials:, pull_request_number:, author_details: nil, signature_key: nil, commit_message: nil) ⇒ Github

Returns a new instance of Github.



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/dependabot/pull_request_updater/github.rb', line 56

def initialize(
  source:,
  base_commit:,
  old_commit:,
  files:,
  credentials:,
  pull_request_number:,
  author_details: nil,
  signature_key: nil,
  commit_message: nil
)
  @source              = source
  @base_commit         = base_commit
  @old_commit          = old_commit
  @files               = files
  @credentials         = credentials
  @pull_request_number = pull_request_number
  @author_details      = author_details
  @signature_key       = signature_key
  @commit_message      = commit_message
end

Instance Attribute Details

#author_detailsObject (readonly)

Returns the value of attribute author_details.



37
38
39
# File 'lib/dependabot/pull_request_updater/github.rb', line 37

def author_details
  @author_details
end

#base_commitObject (readonly)

Returns the value of attribute base_commit.



25
26
27
# File 'lib/dependabot/pull_request_updater/github.rb', line 25

def base_commit
  @base_commit
end

#credentialsObject (readonly)

Returns the value of attribute credentials.



31
32
33
# File 'lib/dependabot/pull_request_updater/github.rb', line 31

def credentials
  @credentials
end

#filesObject (readonly)

Returns the value of attribute files.



22
23
24
# File 'lib/dependabot/pull_request_updater/github.rb', line 22

def files
  @files
end

#old_commitObject (readonly)

Returns the value of attribute old_commit.



28
29
30
# File 'lib/dependabot/pull_request_updater/github.rb', line 28

def old_commit
  @old_commit
end

#pull_request_numberObject (readonly)

Returns the value of attribute pull_request_number.



34
35
36
# File 'lib/dependabot/pull_request_updater/github.rb', line 34

def pull_request_number
  @pull_request_number
end

#signature_keyObject (readonly)

Returns the value of attribute signature_key.



40
41
42
# File 'lib/dependabot/pull_request_updater/github.rb', line 40

def signature_key
  @signature_key
end

#sourceObject (readonly)

Returns the value of attribute source.



19
20
21
# File 'lib/dependabot/pull_request_updater/github.rb', line 19

def source
  @source
end

Instance Method Details

#updateObject



79
80
81
82
83
84
85
86
87
# File 'lib/dependabot/pull_request_updater/github.rb', line 79

def update
  return unless pull_request_exists?
  return unless branch_exists?(github_string(github_resource(pull_request, :head, "pull request"), :ref, "head"))

  commit = create_commit
  branch = update_branch(commit)
  update_pull_request_target_branch
  branch
end