Class: TinyCI::Installer
- Inherits:
-
Object
- Object
- TinyCI::Installer
- Includes:
- GitUtils
- Defined in:
- lib/tinyci/installer.rb
Overview
Responsible for writing the git hook file
Instance Method Summary collapse
-
#initialize(working_dir: nil, logger: nil) ⇒ Installer
constructor
Constructor.
-
#write! ⇒ Object
Write the hook to the relevant path and make it executable.
Methods included from GitUtils
#git_cmd, #git_directory_path, #inside_bare_repo?, #inside_git_directory?, #inside_repository?, #inside_work_tree?, #repo_root
Constructor Details
#initialize(working_dir: nil, logger: nil) ⇒ Installer
Constructor
14 15 16 17 |
# File 'lib/tinyci/installer.rb', line 14 def initialize(working_dir: nil, logger: nil) @logger = logger @working_dir = working_dir || repo_root end |
Instance Method Details
#write! ⇒ Object
Write the hook to the relevant path and make it executable
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/tinyci/installer.rb', line 20 def write! unless inside_repository? log_error "not currently in a git repository" return false end if hook_exists? log_error "post-update hook already exists in this repository" return false end File.open(hook_path, 'a') {|f| f.write hook_content} FileUtils.chmod('u+x', hook_path) log_info 'tinyci post-update hook installed successfully' end |