Method: GitModel::Transaction#lock

Defined in:
lib/gitmodel/transaction.rb

#lock(&block) ⇒ Object

Wait until we can get an exclusive lock on the branch, then execute the block. We lock the branch by creating refs/heads/<branch>.lock, which the git commands also seem to respect



51
52
53
54
55
56
57
58
59
# File 'lib/gitmodel/transaction.rb', line 51

def lock(&block)
  lockfile = Lockfile.new File.join(GitModel.repo.path, 'refs/heads', branch + '.lock')
  begin
    lockfile.lock
    yield
  ensure
    lockfile.unlock
  end
end