summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG1
-rw-r--r--app/models/namespace.rb1
-rw-r--r--db/migrate/20150324133047_remove_periods_at_ends_of_usernames.rb10
-rw-r--r--lib/tasks/gitlab/check.rake17
4 files changed, 24 insertions, 5 deletions
diff --git a/CHANGELOG b/CHANGELOG
index c1cb67b2e42..adcc3b96d11 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -26,6 +26,7 @@ v 7.10.0 (unreleased)
- Don't leak existence of group or project via search.
- Fix bug where Wiki pages that included a '/' were no longer accessible (Stan Hu)
- Fix bug where error messages from Dropzone would not be displayed on the issues page (Stan Hu)
+ - Add a rake task to check repository integrity with `git fsck`
- Add ability to configure Reply-To address in gitlab.yml (Stan Hu)
- Move current user to the top of the list in assignee/author filters (Stan Hu)
- Fix broken side-by-side diff view on merge request page (Stan Hu)
diff --git a/app/models/namespace.rb b/app/models/namespace.rb
index a0d79d7e5c0..e1de114375e 100644
--- a/app/models/namespace.rb
+++ b/app/models/namespace.rb
@@ -59,6 +59,7 @@ class Namespace < ActiveRecord::Base
end
def clean_path(path)
+ path = path.dup
path.gsub!(/@.*\z/, "")
path.gsub!(/\.git\z/, "")
path.gsub!(/\A-+/, "")
diff --git a/db/migrate/20150324133047_remove_periods_at_ends_of_usernames.rb b/db/migrate/20150324133047_remove_periods_at_ends_of_usernames.rb
index 7ce53c2a0d6..dc38b0eceb7 100644
--- a/db/migrate/20150324133047_remove_periods_at_ends_of_usernames.rb
+++ b/db/migrate/20150324133047_remove_periods_at_ends_of_usernames.rb
@@ -3,21 +3,21 @@ class RemovePeriodsAtEndsOfUsernames < ActiveRecord::Migration
class Namespace < ActiveRecord::Base
class << self
- def by_path(path)
- where('lower(path) = :value', value: path.downcase).first
+ def find_by_path_or_name(path)
+ find_by("lower(path) = :path OR lower(name) = :path", path: path.downcase)
end
def clean_path(path)
path = path.dup
path.gsub!(/@.*\z/, "")
path.gsub!(/\.git\z/, "")
- path.gsub!(/\A-/, "")
- path.gsub!(/.\z/, "")
+ path.gsub!(/\A-+/, "")
+ path.gsub!(/\.+\z/, "")
path.gsub!(/[^a-zA-Z0-9_\-\.]/, "")
counter = 0
base = path
- while Namespace.by_path(path).present?
+ while Namespace.find_by_path_or_name(path)
counter += 1
path = "#{base}#{counter}"
end
diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake
index d791b7155f9..04a2eb12db0 100644
--- a/lib/tasks/gitlab/check.rake
+++ b/lib/tasks/gitlab/check.rake
@@ -687,6 +687,23 @@ namespace :gitlab do
end
end
+ namespace :repo do
+ desc "GITLAB | Check the integrity of the repositories managed by GitLab"
+ task check: :environment do
+ namespace_dirs = Dir.glob(
+ File.join(Gitlab.config.gitlab_shell.repos_path, '*')
+ )
+
+ namespace_dirs.each do |namespace_dir|
+ repo_dirs = Dir.glob(File.join(namespace_dir, '*'))
+ repo_dirs.each do |dir|
+ puts "\nChecking repo at #{dir}"
+ system(*%w(git fsck), chdir: dir)
+ end
+ end
+ end
+ end
+
# Helper methods
##########################