Class: Discharger::SetupRunner::Commands::GitCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- Discharger::SetupRunner::Commands::GitCommand
show all
- Defined in:
- lib/discharger/setup_runner/commands/git_command.rb
Instance Attribute Summary
Attributes inherited from BaseCommand
#app_root, #config, #logger
Instance Method Summary
collapse
Methods inherited from BaseCommand
#initialize
Instance Method Details
#can_execute? ⇒ Boolean
35
36
37
|
# File 'lib/discharger/setup_runner/commands/git_command.rb', line 35
def can_execute?
File.directory?(File.join(app_root, ".git"))
end
|
#description ⇒ Object
39
40
41
|
# File 'lib/discharger/setup_runner/commands/git_command.rb', line 39
def description
"Setup git configuration"
end
|
#execute ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/discharger/setup_runner/commands/git_command.rb', line 9
def execute
log "Setting up git configuration"
commit_template = File.join(app_root, ".commit-template")
if File.exist?(commit_template)
system! "git config --local commit.template .commit-template"
log "Git commit template configured"
end
githooks_dir = File.join(app_root, ".githooks")
if File.directory?(githooks_dir)
system! "git config --local core.hooksPath .githooks"
log "Git hooks path configured"
end
if config.respond_to?(:git_config) && config.git_config
config.git_config.each do |key, value|
system! "git config --local #{key} '#{value}'"
log "Set git config #{key}"
end
end
end
|