260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
|
# File 'lib/spiderfw/setup/app_manager.rb', line 260
def git_install(spec, options={})
require 'git'
if ::File.exist?("apps/#{spec.id}")
Spider.output _("%s already installed, skipping") % spec.id
return
end
repo = nil
if ::File.directory?(File.join(@home_path, '.git'))
repo = Git.open(@home_path)
end
repo_url = options[:rw] ? spec.git_repo_rw : spec.git_repo
Spider.output _("Fetching %s from %s") % [spec.app_id, repo_url]
if options[:ssh_user] && repo_url =~ /ssh:\/\/([^@]+@)?(.+)/
repo_url = "ssh://#{options[:ssh_user]}@#{$2}"
end
ENV['GIT_WORK_TREE'] = nil
if repo
Dir.chdir(@home_path) do
`git submodule add #{repo_url} apps/#{spec.id}`
`git submodule init`
`git submodule update`
repo.add(['.gitmodules', "apps/#{spec.id}"])
begin
repo.commit(_("Added app %s") % spec.id)
rescue Git::GitExecuteError => exc
raise unless exc.message =~ /no changes added/
end
end
else
Dir.chdir(File.join(@home_path, 'apps')) do
Git.clone(repo_url, spec.id)
end
end
app_path = File.join(@home_path, "apps", spec.id)
if spec.branch != 'master'
reset_git_env
Dir.chdir(app_path) do
`git checkout #{spec.branch}`
end
end
end
|