Class: Chap::Strategy::Checkout
Constant Summary
Chap::SpecialMethods::SPECIAL_METHODS
Instance Attribute Summary
Attributes inherited from Base
#config, #options
Instance Method Summary
collapse
#benchmarks, included, #report_benchmarks, #shorten_name
Methods inherited from Base
#initialize
included
Instance Method Details
#checkout ⇒ Object
33
34
35
36
37
38
39
40
|
# File 'lib/chap/strategy/checkout.rb', line 33
def checkout
command =<<BASH
git clone -q #{config.chap[:repo]} #{cached_path} && \
cd #{cached_path} && \
git checkout -q -b deploy #{revision}
BASH
run(command)
end
|
#copy ⇒ Object
42
43
44
45
46
|
# File 'lib/chap/strategy/checkout.rb', line 42
def copy
command = "cp -RPp #{cached_path} #{release_path} && #{mark}"
run command
log "Code copied to #{release_path}".colorize(:green)
end
|
#deploy ⇒ Object
6
7
8
9
|
# File 'lib/chap/strategy/checkout.rb', line 6
def deploy
update
copy
end
|
#sync ⇒ Object
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/chap/strategy/checkout.rb', line 22
def sync
command =<<-BASH
cd #{cached_path} && \
git fetch -q origin && \
git fetch --tags -q origin && \
git reset -q --hard #{revision} && \
git clean -q -d -x -f
BASH
run(command)
end
|
#update ⇒ Object
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/chap/strategy/checkout.rb', line 11
def update
log "Updating repo in #{cached_path}".colorize(:green)
cached_root = File.dirname(cached_path)
FileUtils.mkdir_p(cached_root) unless File.exist?(cached_root)
if File.exist?(cached_path)
sync
else
checkout
end
end
|