Top Level Namespace

Defined Under Namespace

Modules: App, IOS

Instance Method Summary collapse

Instance Method Details

#install_pre_commit_hook(repository) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/ios/install-hooks.rb', line 7

def install_pre_commit_hook(repository)
  hooks_path = File.join(repository.workdir, '.git', 'hooks')
  hook_type = 'pre-commit'
  hook_path = File.join(hooks_path, hook_type)
  source_hook_path = File.join(File.dirname(File.expand_path(__FILE__)), 'hooks', hook_type)

  unless File.directory?(hooks_path)
    puts "Pasta .git/hooks não encontrada. Certifique-se de estar no diretório raiz do seu repositório Git."
    exit 1
  end

  # Copia o script do hook para o diretório .git/hooks
  FileUtils.cp(source_hook_path, hook_path)
  File.chmod(0755, hook_path)
end