module Git::Story::Setup
Constants
- HOOKS_DIR
- MARKER
- PREPARE_COMMIT_MESSAGE_DST
- PREPARE_COMMIT_MESSAGE_SRC
Public Instance Methods
file_installed?(filename)
click to toggle source
# File lib/git/story/setup.rb, line 37 def file_installed?(filename) path = File.join(HOOKS_DIR, filename) if File.exist?(path) path end end
install_file(filename)
click to toggle source
# File lib/git/story/setup.rb, line 44 def install_file(filename) File.exist?(HOOKS_DIR) or mkdir_p(HOOKS_DIR) cp File.join(__dir__, filename), File.join(HOOKS_DIR, filename) end
perform(force: false)
click to toggle source
# File lib/git/story/setup.rb, line 13 def perform(force: false) for filename in %w[ prepare-commit-msg pre-push ] if path = file_installed?(filename) if force install_file filename elsif File.read(path).match?(MARKER) ; else ask( prompt: "File #{path.inspect} not created by git-story."\ " Overwrite? (y/n, default is %s) ", default: ?n, ) do |response| if response == ?y install_file filename end end end else install_file filename end end end