Commit 4718847c authored by Robert Speicher's avatar Robert Speicher

Merge branch 'file_lock_improvements' into 'master'

Address review comments for !440

See merge request !486
parents 8f8101d7 9a686542
...@@ -4,6 +4,6 @@ module PathLocksHelper ...@@ -4,6 +4,6 @@ module PathLocksHelper
end end
def license_allows_file_locks? def license_allows_file_locks?
::License.current && ::License.current.add_on?('GitLab_FileLocks') @license_allows_file_locks ||= (::License.current && ::License.current.add_on?('GitLab_FileLocks'))
end end
end end
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
- if path_lock_info - if path_lock_info
:plain :plain
var label = $("<span>") var label = $("<span>")
.attr('title', 'Locked by #{escape_javascript path_lock_info.user.name }') .attr('title', 'Locked by #{escape_javascript path_lock_info.user.name}')
.attr('data-toggle', 'tooltip') .attr('data-toggle', 'tooltip')
.addClass('fa fa-lock prepend-left-5'); .addClass('fa fa-lock prepend-left-5');
row.find('td.tree-item-file-name').append(label); row.find('td.tree-item-file-name').append(label);
......
# The database stores locked paths as following: # The database stores locked paths as following:
# 'app/models/project.rb' or 'lib/gitlab' # 'app/models/user.rb' or 'app/models'
# To determine that 'lib/gitlab/some_class.rb' is locked we need to generate # To determine that 'app/models/user.rb' is locked we need to generate
# tokens for every requested paths and check every token whether it exist in path locks table or not. # tokens for every requested paths and check every token whether it exist in path locks table or not.
# So for 'lib/gitlab/some_class.rb' path we would need to search next paths: # So for 'app/models/user.rb' path we would need to search next paths:
# 'lib', 'lib/gitlab' and 'lib/gitlab/some_class.rb' # 'app', 'app/models' and 'app/models/user.rb'
# This class also implements a memoization for common paths like 'lib' 'lib/gitlab', 'app', etc. # This class also implements a memoization for common paths like 'app' 'app/models', 'vendor', etc.
class Gitlab::PathLocksFinder class Gitlab::PathLocksFinder
def initialize(project) def initialize(project)
......
FactoryGirl.define do FactoryGirl.define do
factory :path_lock do factory :path_lock do
project project
user { build :user } user
sequence(:path) { |n| "app/model#{n}" } sequence(:path) { |n| "app/model#{n}" }
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment