class Dependabot::Publish
Attributes
dependency[R]
git[R]
pull_request[R]
Public Class Methods
new(dependency, git: Dependabot::Git.for(dependency))
click to toggle source
# 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
Public Instance Methods
update!(push: false)
click to toggle source
# 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
Private Instance Methods
no_changes?()
click to toggle source
# File lib/dependabot/publish.rb, line 49 def no_changes? git.patch.empty? end
reset()
click to toggle source
# File lib/dependabot/publish.rb, line 44 def reset git.repo.checkout_head(strategy: :force) git.repo.checkout(pull_request.base) end
transaction(push:) { |Callback| ... }
click to toggle source
# File lib/dependabot/publish.rb, line 30 def transaction(push:) git.checkout(branch: pull_request.head) callback = yield Callback return if no_changes? git.commit(all: true, message: pull_request.commit_message) return unless push git.push(remote: "origin", branch: pull_request.head) callback.call ensure reset end