scm.rb
2.74 KB
1
2
3
4
5
6
7
8
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
module Capistrano
# Base class for SCM strategy providers.
#
# @abstract
#
# @attr_reader [Rake] context
#
# @author Hartog de Mik
#
class SCM
attr_reader :context
# Provide a wrapper for the SCM that loads a strategy for the user.
#
# @param [Rake] context The context in which the strategy should run
# @param [Module] strategy A module to include into the SCM instance. The
# module should provide the abstract methods of Capistrano::SCM
#
def initialize(context, strategy)
@context = context
singleton = class << self; self; end
singleton.send(:include, strategy)
end
# Call test in context
def test!(*args)
context.test(*args)
end
# The repository URL according to the context
def repo_url
context.repo_url
end
# The repository path according to the context
def repo_path
context.repo_path
end
# The release path according to the context
def release_path
context.release_path
end
# Fetch a var from the context
# @param [Symbol] variable The variable to fetch
# @param [Object] default The default value if not found
#
def fetch(*args)
context.fetch(*args)
end
# @abstract
#
# Your implementation should check the existence of a cache repository on
# the deployment target
#
# @return [Boolean]
#
def test
raise NotImplementedError, "Your SCM strategy module should provide a #test method"
end
# @abstract
#
# Your implementation should check if the specified remote-repository is
# available.
#
# @return [Boolean]
#
def check
raise NotImplementedError, "Your SCM strategy module should provide a #check method"
end
# @abstract
#
# Create a (new) clone of the remote-repository on the deployment target
#
# @return void
#
def clone
raise NotImplementedError, "Your SCM strategy module should provide a #clone method"
end
# @abstract
#
# Update the clone on the deployment target
#
# @return void
#
def update
raise NotImplementedError, "Your SCM strategy module should provide a #update method"
end
# @abstract
#
# Copy the contents of the cache-repository onto the release path
#
# @return void
#
def release
raise NotImplementedError, "Your SCM strategy module should provide a #release method"
end
# @abstract
#
# Identify the SHA of the commit that will be deployed. This will most likely involve SshKit's capture method.
#
# @return void
#
def fetch_revision
raise NotImplementedError, "Your SCM strategy module should provide a #fetch_revision method"
end
end
end