Class: Dependabot::GithubActions::FileUpdater::WorkflowUpdater::SourceCommentUpdater

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/github_actions/file_updater/workflow_updater/source_comment_updater.rb

Instance Method Summary collapse

Constructor Details

#initialize(workflow_file:, commenter:, metadata_builder:, comment_locator:) ⇒ SourceCommentUpdater

Returns a new instance of SourceCommentUpdater.



21
22
23
24
25
26
# File 'lib/dependabot/github_actions/file_updater/workflow_updater/source_comment_updater.rb', line 21

def initialize(workflow_file:, commenter:, metadata_builder:, comment_locator:)
  @workflow_file = workflow_file
  @commenter = commenter
  @metadata_builder = 
  @comment_locator = comment_locator
end

Instance Method Details

#edits_for(update) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/dependabot/github_actions/file_updater/workflow_updater/source_comment_updater.rb', line 29

def edits_for(update)
  located_comment = located_comment_for(update)
  if located_comment
    recognized = commenter.recognized_comment?(
      located_comment.comment,
      update.old_ref,
      update.new_ref
    )
    if located_comment.syntax_adjacent || recognized
      return edits_for_existing_comment(update, located_comment, recognized)
    end
  end

  edits_for_new_comment(update)
end