253
254
255
256
257
258
259
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
|
# File 'lib/test_ids.rb', line 253
def lsf_init(git_repo, lsf_publish)
@lsf_manual_init_shutdown = true
local_var_git_database_dir = "#{Origen.app.imports_directory}/test_ids/#{Pathname.new(git_repo).basename}"
FileUtils.mkdir_p(local_var_git_database_dir)
unless File.exist?("#{local_var_git_database_dir}/.git")
FileUtils.rm_rf(local_var_git_database_dir) if File.exist?(local_var_git_database_dir)
FileUtils.mkdir_p(local_var_git_database_dir)
Dir.chdir local_var_git_database_dir do
`git clone #{git_repo} .`
unless File.exist?('lock.json')
exec 'touch lock.json'
exec 'git add lock.json'
exec 'git commit -m "Initial commit"'
exec 'git push'
end
end
end
@local = local_var_git_database_dir
@repo = ::Git.open(local_var_git_database_dir)
@repo.reset_hard
@git = Git.new(local: local_var_git_database_dir, remote: @repo)
if lsf_publish
return if @lock_open
Origen.profile 'Obtaining test IDs lock' do
until @git.available_to_lock?(@repo)
puts
puts "Waiting for lock, currently locked by #{@git.lock_user} (the lock will expire in less than #{@git.lock_minutes_remaining} #{'minute'.pluralize(@git.lock_minutes_remaining)} if not released before that)"
puts
sleep 5
end
data = {
'user' => User.current.name,
'expires' => (Time.now + @git.minutes(5)).to_f
}
@git.write('lock.json', JSON.pretty_generate(data))
repo.commit('Obtaining lock')
repo.push('origin')
end
@lock_open = true
end
end
|