Module: StepUp::GitExtensions::Notes

Included in:
Driver::Git
Defined in:
lib/step-up/git_extensions.rb

Instance Method Summary collapse

Instance Method Details

#notes_remoteObject



31
32
33
# File 'lib/step-up/git_extensions.rb', line 31

def notes_remote
  fetched_remotes('notes').first
end

#steps_for_add_notes(section, message, commit_base = nil) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/step-up/git_extensions.rb', line 15

def steps_for_add_notes(section, message, commit_base = nil)
  commands = []
  commands << "git fetch" if cached_fetched_remotes.any?
  commands << "git notes --ref=#{ section } add -m \"#{ message.gsub(/([\$\\"`])/, '\\\\\1') }\" #{ commit_base }"
  commands << "git push #{ notes_remote } refs/notes/#{ section }" if cached_fetched_remotes.any?
  commands
end

#steps_for_archiving_notes(objects_with_notes, tag) ⇒ Object

Raises:

  • (ArgumentError)


9
10
11
12
13
# File 'lib/step-up/git_extensions.rb', line 9

def steps_for_archiving_notes(objects_with_notes, tag)
  strategy = CONFIG.notes.after_versioned["strategy"] || "keep"
  raise ArgumentError, "unknown strategy: #{ strategy }" unless NOTES_STRATEGIES.include?(strategy)
  NOTES_STRATEGIES[strategy].steps_for_archiving_notes(objects_with_notes, tag, self)
end

#steps_to_remove_notes(section, commit_base) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/step-up/git_extensions.rb', line 23

def steps_to_remove_notes(section, commit_base)
  commands = []
  commands << "git fetch" if cached_fetched_remotes.any?
  commands << "git notes --ref=#{ section } remove #{ commit_base }"
  commands << "git push #{ notes_remote } refs/notes/#{ section }" if cached_fetched_remotes.any?
  commands
end