Class: StepUp::GitExtensions::Strategy::KeepNotes

Inherits:
Object
  • Object
show all
Defined in:
lib/step-up/git_extensions.rb

Instance Method Summary collapse

Instance Method Details

#steps_for_archiving_notes(objects_with_notes, tag, driver) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/step-up/git_extensions.rb', line 38

def steps_for_archiving_notes(objects_with_notes, tag, driver)
  commands = []
  objects = []
  changelog_message = CONFIG.notes.after_versioned.changelog_message
  CONFIG.notes_sections.names.each do |section|
    next unless objects_with_notes.has_key?(section)
    objects_with_notes[section].each do |object|
      next if object[2] == RangedNotes::COMMIT_NOTE
      unless objects.include?(object[0])
        objects << object[0]
        kept_message = changelog_message.gsub(/\{version\}/, tag)
        commands << "git notes --ref=#{ CONFIG.notes.after_versioned.section } add -m \"#{ kept_message.gsub(/([\$\\"])/, '\\\\\1') }\" #{ object[0] }"
      end
    end
  end
  commands << "git push #{ driver.notes_remote } refs/notes/#{ CONFIG.notes.after_versioned.section }" unless objects.empty? || driver.cached_fetched_remotes.empty?
  commands
end