diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/backup/repository.rb | 5 | ||||
-rw-r--r-- | lib/gitlab/commits_calendar.rb | 8 | ||||
-rw-r--r-- | lib/gitlab/force_push_check.rb | 7 | ||||
-rw-r--r-- | lib/gitlab/middleware/timeout.rb | 13 | ||||
-rw-r--r-- | lib/gitlab/push_data_builder.rb | 18 | ||||
-rw-r--r-- | lib/gitlab/visibility_level.rb | 8 | ||||
-rw-r--r-- | lib/tasks/brakeman.rake | 2 | ||||
-rw-r--r-- | lib/tasks/gitlab/cleanup.rake | 9 |
8 files changed, 37 insertions, 33 deletions
diff --git a/lib/backup/repository.rb b/lib/backup/repository.rb index e18bc804437..dfb2da9f84e 100644 --- a/lib/backup/repository.rb +++ b/lib/backup/repository.rb @@ -16,7 +16,7 @@ module Backup if project.empty_repo? $progress.puts "[SKIPPED]".cyan else - cmd = %W(git --git-dir=#{path_to_repo(project)} bundle create #{path_to_bundle(project)} --all) + cmd = %W(tar -cf #{path_to_bundle(project)} -C #{path_to_repo(project)} .) output, status = Gitlab::Popen.popen(cmd) if status.zero? $progress.puts "[DONE]".green @@ -64,7 +64,8 @@ module Backup project.namespace.ensure_dir_exist if project.namespace if File.exists?(path_to_bundle(project)) - cmd = %W(git clone --bare #{path_to_bundle(project)} #{path_to_repo(project)}) + FileUtils.mkdir_p(path_to_repo(project)) + cmd = %W(tar -xf #{path_to_bundle(project)} -C #{path_to_repo(project)}) else cmd = %W(git init --bare #{path_to_repo(project)}) end diff --git a/lib/gitlab/commits_calendar.rb b/lib/gitlab/commits_calendar.rb index 2f30d238e6b..8963d346b6f 100644 --- a/lib/gitlab/commits_calendar.rb +++ b/lib/gitlab/commits_calendar.rb @@ -22,6 +22,14 @@ module Gitlab end end + def self.get_commits_for_date(projects, user, date) + user_commits = {} + projects.reject(&:forked?).each do |project| + user_commits[project] = ProjectContributions.new(project, user).user_commits_on_date(date) + end + user_commits + end + def starting_year (Time.now - 1.year).strftime("%Y") end diff --git a/lib/gitlab/force_push_check.rb b/lib/gitlab/force_push_check.rb index eae9773a067..fdb6a35c78d 100644 --- a/lib/gitlab/force_push_check.rb +++ b/lib/gitlab/force_push_check.rb @@ -3,11 +3,12 @@ module Gitlab def self.force_push?(project, oldrev, newrev) return false if project.empty_repo? - if oldrev != Gitlab::Git::BLANK_SHA && newrev != Gitlab::Git::BLANK_SHA + # Created or deleted branch + if Gitlab::Git.blank_ref?(oldrev) || Gitlab::Git.blank_ref?(newrev) + false + else missed_refs, _ = Gitlab::Popen.popen(%W(git --git-dir=#{project.repository.path_to_repo} rev-list #{oldrev} ^#{newrev})) missed_refs.split("\n").size > 0 - else - false end end end diff --git a/lib/gitlab/middleware/timeout.rb b/lib/gitlab/middleware/timeout.rb deleted file mode 100644 index 015600392b9..00000000000 --- a/lib/gitlab/middleware/timeout.rb +++ /dev/null @@ -1,13 +0,0 @@ -module Gitlab - module Middleware - class Timeout < Rack::Timeout - GRACK_REGEX = /[-\/\w\.]+\.git\//.freeze - - def call(env) - return @app.call(env) if env['PATH_INFO'] =~ GRACK_REGEX - - super - end - end - end -end diff --git a/lib/gitlab/push_data_builder.rb b/lib/gitlab/push_data_builder.rb index ea9012b8844..948cf58fd9a 100644 --- a/lib/gitlab/push_data_builder.rb +++ b/lib/gitlab/push_data_builder.rb @@ -27,6 +27,12 @@ module Gitlab # Get latest 20 commits ASC commits_limited = commits.last(20) + + # For performance purposes maximum 20 latest commits + # will be passed as post receive hook data. + commit_attrs = commits_limited.map do |commit| + commit.hook_attrs(project) + end type = Gitlab::Git.tag_ref?(ref) ? "tag_push" : "push" # Hash to be passed as post_receive_data @@ -49,17 +55,10 @@ module Gitlab git_ssh_url: project.ssh_url_to_repo, visibility_level: project.visibility_level }, - commits: [], + commits: commit_attrs, total_commits_count: commits_count } - # For performance purposes maximum 20 latest commits - # will be passed as post receive hook data. - commits_limited.each do |commit| - data[:commits] << commit.hook_attrs(project) - end - - data[:commits] = "" if data[:commits].count == 0 data end @@ -72,7 +71,8 @@ module Gitlab end def checkout_sha(repository, newrev, ref) - if newrev != Gitlab::Git::BLANK_SHA && Gitlab::Git.tag_ref?(ref) + # Find sha for tag, except when it was deleted. + if Gitlab::Git.tag_ref?(ref) && !Gitlab::Git.blank_ref?(newrev) tag_name = Gitlab::Git.ref_name(ref) tag = repository.find_tag(tag_name) diff --git a/lib/gitlab/visibility_level.rb b/lib/gitlab/visibility_level.rb index 1851e76067c..582fc759efd 100644 --- a/lib/gitlab/visibility_level.rb +++ b/lib/gitlab/visibility_level.rb @@ -35,7 +35,13 @@ module Gitlab end def non_restricted_level?(level) - ! current_application_settings.restricted_visibility_levels.include?(level) + restricted_levels = current_application_settings.restricted_visibility_levels + + if restricted_levels.nil? + true + else + !restricted_levels.include?(level) + end end def valid_level?(level) diff --git a/lib/tasks/brakeman.rake b/lib/tasks/brakeman.rake index abcb5f0ae46..3a225801ff2 100644 --- a/lib/tasks/brakeman.rake +++ b/lib/tasks/brakeman.rake @@ -1,7 +1,7 @@ desc 'Security check via brakeman' task :brakeman do if system("brakeman --skip-files lib/backup/repository.rb -w3 -z") - exit 0 + puts 'Security check succeed' else puts 'Security check failed' exit 1 diff --git a/lib/tasks/gitlab/cleanup.rake b/lib/tasks/gitlab/cleanup.rake index 189ad6090a4..3c9802a0be4 100644 --- a/lib/tasks/gitlab/cleanup.rake +++ b/lib/tasks/gitlab/cleanup.rake @@ -90,13 +90,14 @@ namespace :gitlab do warn_user_is_not_gitlab block_flag = ENV['BLOCK'] - User.ldap.each do |ldap_user| - print "#{ldap_user.name} (#{ldap_user.extern_uid}) ..." - if Gitlab::LDAP::Access.allowed?(ldap_user) + User.find_each do |user| + next unless user.ldap_user? + print "#{user.name} (#{user.ldap_identity.extern_uid}) ..." + if Gitlab::LDAP::Access.allowed?(user) puts " [OK]".green else if block_flag - ldap_user.block! unless ldap_user.blocked? + user.block! unless user.blocked? puts " [BLOCKED]".red else puts " [NOT IN LDAP]".yellow |