Class: Dependabot::Publish

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dependency, git: Dependabot::Git.for(dependency)) ⇒ Publish

Returns a new instance of Publish.



7
8
9
10
11
12
13
14
15
16
# File 'lib/dependabot/publish.rb', line 7

def initialize(dependency, git: Dependabot::Git.for(dependency))
  @dependency = dependency
  @git = git
  @pull_request = PullRequest.new(
    nwo: GitHub.name_with_owner_from(git.repo.remotes["origin"].url),
    base: git.repo.head.name,
    head: "dependanot/#{dependency.package_manager}/#{dependency.name}",
    dependency: dependency
  )
end

Instance Attribute Details

#dependencyObject (readonly)

Returns the value of attribute dependency.



5
6
7
# File 'lib/dependabot/publish.rb', line 5

def dependency
  @dependency
end

#gitObject (readonly)

Returns the value of attribute git.



5
6
7
# File 'lib/dependabot/publish.rb', line 5

def git
  @git
end

#pull_requestObject (readonly)

Returns the value of attribute pull_request.



5
6
7
# File 'lib/dependabot/publish.rb', line 5

def pull_request
  @pull_request
end

Instance Method Details

#update!(push: false) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/dependabot/publish.rb', line 18

def update!(push: false)
  transaction(push: push) do |after_commit|
    ::Spandx::Core::Plugin.enhance(dependency)
    after_commit.new do
      Dependabot.logger.debug(git.patch)
      Dependabot.github.create(pull_request)
    end
  end
end