Module: Git::Story::Setup
Constant Summary collapse
- MARKER =
'Installed by the git-story gem'
- HOOKS_DIR =
'.git/hooks'
- PREPARE_COMMIT_MESSAGE_SRC =
File.join(__dir__, 'prepare-commit-msg')
- PREPARE_COMMIT_MESSAGE_DST =
File.join(HOOKS_DIR, 'prepare-commit-msg')
Class Method Summary collapse
Methods included from Utils
Class Method Details
.install_prepare_commit_msg ⇒ Object
36 37 38 39 |
# File 'lib/git/story/setup.rb', line 36 def install_prepare_commit_msg File.exist?(HOOKS_DIR) or mkdir_p(HOOKS_DIR) cp PREPARE_COMMIT_MESSAGE_SRC, PREPARE_COMMIT_MESSAGE_DST end |
.perform(force: false) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/git/story/setup.rb', line 13 def perform(force: false) pcm = PREPARE_COMMIT_MESSAGE_DST if File.exist?(pcm) if force install_prepare_commit_msg elsif File.read(pcm).match?(MARKER) ; else ask( prompt: "File #{pcm.inspect} not created by git-story."\ " Overwrite? (y/n, default is %s)", default: ?n, ) do |response| if response == ?y install_prepare_commit_msg end end end else install_prepare_commit_msg end end |