Skip to content

Commit

Permalink
Extract lock namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Gehrke committed May 31, 2016
1 parent f829afd commit 55e3375
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion git/lib/git_update.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'json'
require File.join(File.expand_path('../../../lib', __FILE__), 'subprocess')
require 'ontohub_net'
require File.join(File.expand_path('../../../lib', __FILE__), 'git_repository')

class GitUpdate

Expand All @@ -26,7 +27,7 @@ def initialize(repo_path, key_id, refs)
end

def exec
Semaphore.exclusively("action:#{@repo_name}") do
Semaphore.exclusively("#{GitRepository::LOCK_NAMESPACE}:#{@repo_name}") do
exec_without_lock
end
end
Expand Down
2 changes: 2 additions & 0 deletions lib/git_repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
class GitRepository
require 'git_repository/config'

LOCK_NAMESPACE = "git"

include \
Config,
Cloning,
Expand Down
2 changes: 1 addition & 1 deletion lib/git_repository/commit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def add_file(userinfo, tmp_path, target_path, message, &block)
end

def commit_file(userinfo, file_contents, target_path, message, &block)
Semaphore.exclusively("action:#{repo}") do
Semaphore.exclusively("#{GitRepository::LOCK_NAMESPACE}:#{repo}") do
commit_file_without_lock(userinfo,
file_contents,
target_path,
Expand Down

0 comments on commit 55e3375

Please sign in to comment.