Class: BuildTool::VCS::GitSvn
- Inherits:
-
Base
- Object
- Base
- BuildTool::VCS::GitSvn
show all
- Defined in:
- lib/build-tool/vcs/git-svn.rb
Overview
Implementation for the git-svn version control system.
Defined Under Namespace
Classes: GitSvnError
Instance Attribute Summary
Attributes inherited from Base
#config
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#apply_patches_after_rebase?, #check_for_sshkey, #local_path, #local_path_exist?, #patches_supported?, #prepare_for_rebase, #recipe
Constructor Details
#initialize(*args) ⇒ GitSvn
Returns a new instance of GitSvn.
72
73
74
|
# File 'lib/build-tool/vcs/git-svn.rb', line 72
def initialize( *args )
super( *args )
end
|
Class Method Details
.git_svn_available ⇒ Object
Is the git executable available?
81
82
83
84
85
86
|
# File 'lib/build-tool/vcs/git-svn.rb', line 81
def git_svn_available
return @git_svn_available unless @git_svn_available.nil?
%x( git svn --help 2>&1 )
@git_svn_available = $?.success?
return @git_svn_available
end
|
Instance Method Details
#[](var) ⇒ Object
212
213
214
215
216
217
218
219
220
221
222
|
# File 'lib/build-tool/vcs/git-svn.rb', line 212
def[]( var )
case var
when 'external'
return @externals
else
raise NotImplementedError, "#{var}"
end
end
|
#[]=(var, val) ⇒ Object
224
225
226
227
228
229
230
231
232
233
234
235
|
# File 'lib/build-tool/vcs/git-svn.rb', line 224
def[]=( var, val )
case var
when 'external'
tmp = val.split( /#/ )
@externals[tmp[0]] = tmp[1]
else
raise NotImplementedError, "#{var}"
end
end
|
#checkedout? ⇒ Boolean
105
106
107
108
109
110
111
|
# File 'lib/build-tool/vcs/git-svn.rb', line 105
def checkedout?
return false if !local_path_exist?
if !Pathname.new( local_path ).join( ".git" ).exist?
raise Base::VcsError, "Checkout path #{local_path} is not a git repo!"
end
return true
end
|
#clone(verbose = false) ⇒ Object
113
114
115
116
117
118
119
120
121
122
123
124
125
|
# File 'lib/build-tool/vcs/git-svn.rb', line 113
def clone( verbose = false )
if local_path_exist?
raise GitSvnError, "Failed to create repository at '#{local_path}': Path exists"
end
FileUtils.mkdir_p( local_path ) if !$noop
if 0 != ( git_svn "init #{config.repository.url}/#{remote_path}" )
raise GitSvnError, "Error while initializing the repo `git svn init '#{config.repository}/#{remote_path}'`: #{$?}"
end
fetch(false, "HEAD")
end
|
127
128
129
|
# File 'lib/build-tool/vcs/git-svn.rb', line 127
def configure
git.configure
end
|
#fetch(verbose = false, revision = nil) ⇒ Object
Fetch from repository
Initializes the local clone if it does not exist.
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
# File 'lib/build-tool/vcs/git-svn.rb', line 134
def fetch( verbose = false, revision = nil )
if !checkedout? and !$noop
clone( verbose )
else
git.check_config
end
if revision
cmd = "fetch -r#{revision}"
else
cmd = "fetch"
end
if ( rc = git_svn( cmd ) ) != 0
raise GitSvnError, "Error while fetching: #{rc}"
end
update_externals
end
|
#fetching_supported? ⇒ Boolean
97
98
99
|
# File 'lib/build-tool/vcs/git-svn.rb', line 97
def fetching_supported?
true
end
|
#gc ⇒ Object
155
156
157
|
# File 'lib/build-tool/vcs/git-svn.rb', line 155
def gc
git.git( "gc" )
end
|
#git ⇒ Object
159
160
161
162
163
164
|
# File 'lib/build-tool/vcs/git-svn.rb', line 159
def git
if @git.nil?
@git = Git.new( config )
end
@git
end
|
#git_svn(command, wd = local_path, &block) ⇒ Object
Call git-svn with command
167
168
169
|
# File 'lib/build-tool/vcs/git-svn.rb', line 167
def git_svn( command, wd = local_path, &block )
self.class.execute( "git svn " + command, wd, &block )
end
|
#name ⇒ Object
93
94
95
|
# File 'lib/build-tool/vcs/git-svn.rb', line 93
def name
"git-svn"
end
|
#prepare_for_fetch ⇒ Object
171
172
173
174
|
# File 'lib/build-tool/vcs/git-svn.rb', line 171
def prepare_for_fetch
return check_for_sshkey( config.repository.sshkey )
end
|
#ready_for_fetch ⇒ Object
191
192
193
194
195
196
|
# File 'lib/build-tool/vcs/git-svn.rb', line 191
def ready_for_fetch
if not GitSvn.git_svn_available
logger.info( "#{config.module.name}: Calling `git svn` failed!" )
end
return GitSvn.git_svn_available && git.ready_for_fetch
end
|
#ready_for_rebase ⇒ Object
198
199
200
|
# File 'lib/build-tool/vcs/git-svn.rb', line 198
def ready_for_rebase
git.ready_for_rebase
end
|
#rebase(verbose = false) ⇒ Object
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
# File 'lib/build-tool/vcs/git-svn.rb', line 176
def rebase( verbose = false )
git.check_config
remote_branch = "#{config.track_branch}"
if verbose
git.git('log --first-parent --pretty=oneline HEAD..%s' % remote_branch ) do |line|
logger.info( line )
end
end
if 0 != ( git.git "rebase #{remote_branch}" )
raise GitSvnError, "Error while rebasing the repo with `#{remote_branch}': #{$?}"
end
end
|
#remote_path ⇒ Object
202
203
204
|
# File 'lib/build-tool/vcs/git-svn.rb', line 202
def remote_path
@config.remote_path
end
|
#update_externals ⇒ Object
206
207
208
209
210
|
# File 'lib/build-tool/vcs/git-svn.rb', line 206
def update_externals
config.merged_externals.each do |local, remote|
VCS::Svn::svn( "checkout #{remote}@HEAD #{local}", wd = local_path )
end
end
|