Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-12-21 01:06:14 +0400
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-12-21 01:06:14 +0400
commit9b07ed06901a584d4928c46b622eac9fed81ab61 (patch)
tree8097eaa688a836f4264e404e8825b782d9569f41
parent2a3f5dae0f562e08436934dbc95e0f6ed6902ee9 (diff)
parent1acff973c85fb836c6b28a5d36aafa4332029424 (diff)
Merge pull request #2323 from riyad/rename-tasks
Rename tasks
-rw-r--r--doc/raketasks/backup_restore.md4
-rw-r--r--doc/raketasks/features.md6
-rw-r--r--doc/raketasks/maintenance.md10
-rw-r--r--doc/raketasks/user_management.md4
-rw-r--r--lib/tasks/bulk_add_permission.rake20
-rw-r--r--lib/tasks/gitlab/backup.rake138
-rw-r--r--lib/tasks/gitlab/bulk_add_permission.rake24
-rw-r--r--lib/tasks/gitlab/check.rake4
-rw-r--r--lib/tasks/gitlab/enable_automerge.rake25
-rw-r--r--lib/tasks/gitlab/enable_namespaces.rake (renamed from lib/tasks/gitlab/activate_namespaces.rake)2
-rw-r--r--lib/tasks/gitlab/setup.rake2
11 files changed, 131 insertions, 108 deletions
diff --git a/doc/raketasks/backup_restore.md b/doc/raketasks/backup_restore.md
index 575467b4371..bbfeeb716fa 100644
--- a/doc/raketasks/backup_restore.md
+++ b/doc/raketasks/backup_restore.md
@@ -4,7 +4,7 @@ Creates a backup archive of the database and all repositories. This archive will
The filename will be `[TIMESTAMP]_gitlab_backup.tar`. This timestamp can be used to restore an specific backup.
```
-bundle exec rake gitlab:app:backup_create
+bundle exec rake gitlab:backup:create
```
Example output:
@@ -40,7 +40,7 @@ Deleting old backups... [SKIPPING]
### Restore a previously created backup
```
-bundle exec rake gitlab:app:backup_restore
+bundle exec rake gitlab:backup:restore
```
Options:
diff --git a/doc/raketasks/features.md b/doc/raketasks/features.md
index 2a66b1caca7..7a2a4b668bd 100644
--- a/doc/raketasks/features.md
+++ b/doc/raketasks/features.md
@@ -1,6 +1,6 @@
### Enable usernames and namespaces for user projects
-This command will enable the namespace feature introduced in v4.0. It will move every project in its namespace folder.
+This command will enable the namespaces feature introduced in v4.0. It will move every project in its namespace folder.
Note:
@@ -13,7 +13,7 @@ Old path: `git@example.org:myrepo.git`
New path: `git@example.org:username/myrepo.git` or `git@example.org:groupname/myrepo.git`
```
-bundle exec rake gitlab:activate_namespaces
+bundle exec rake gitlab:enable_namespaces
```
@@ -22,7 +22,7 @@ bundle exec rake gitlab:activate_namespaces
This command will enable the auto merge feature. After this you will be able to **merge a merge request** via GitLab and use the **online editor**.
```
-bundle exec rake gitlab:app:enable_automerge
+bundle exec rake gitlab:enable_automerge
```
Example output:
diff --git a/doc/raketasks/maintenance.md b/doc/raketasks/maintenance.md
index 7be631a773d..bb8e1ed29f7 100644
--- a/doc/raketasks/maintenance.md
+++ b/doc/raketasks/maintenance.md
@@ -139,6 +139,16 @@ Checking GitLab ... Finished
```
+### (Re-)Create satellite repos
+
+This will create satellite repos for all your projects.
+If necessary, remove the `tmp/repo_satellites` directory and rerun the command below.
+
+```
+bundle exec rake gitlab:satellites:create
+```
+
+
### Rebuild each key at gitolite config
This will send all users ssh public keys to gitolite and grant them access (based on their permission) to their projects.
diff --git a/doc/raketasks/user_management.md b/doc/raketasks/user_management.md
index e4ca5280b78..021ce35931f 100644
--- a/doc/raketasks/user_management.md
+++ b/doc/raketasks/user_management.md
@@ -1,7 +1,7 @@
### Add user to as a developer to all projects
```
-bundle exec rake add_user_to_project_teams[username@domain.tld]
+bundle exec rake gitlab:import:user_to_projects[username@domain.tld]
```
@@ -12,5 +12,5 @@ Notes:
* admin users are added as masters
```
-bundle exec rake add_users_to_project_teams
+bundle exec rake gitlab:import:all_users_to_all_projects
```
diff --git a/lib/tasks/bulk_add_permission.rake b/lib/tasks/bulk_add_permission.rake
deleted file mode 100644
index bf08ace8e9c..00000000000
--- a/lib/tasks/bulk_add_permission.rake
+++ /dev/null
@@ -1,20 +0,0 @@
-desc "Add all users to all projects (admin users are added as masters)"
-task :add_users_to_project_teams => :environment do |t, args|
- user_ids = User.where(:admin => false).pluck(:id)
- admin_ids = User.where(:admin => true).pluck(:id)
-
- Project.find_each do |project|
- puts "Importing #{user_ids.size} users into #{project.code}"
- UsersProject.bulk_import(project, user_ids, UsersProject::DEVELOPER)
- puts "Importing #{admin_ids.size} admins into #{project.code}"
- UsersProject.bulk_import(project, admin_ids, UsersProject::MASTER)
- end
-end
-
-desc "Add user to as a developer to all projects"
-task :add_user_to_project_teams, [:email] => :environment do |t, args|
- user = User.find_by_email args.email
- project_ids = Project.pluck(:id)
-
- UsersProject.user_bulk_import(user, project_ids, UsersProject::DEVELOPER)
-end
diff --git a/lib/tasks/gitlab/backup.rake b/lib/tasks/gitlab/backup.rake
index 307a6288a24..b7a64394ad0 100644
--- a/lib/tasks/gitlab/backup.rake
+++ b/lib/tasks/gitlab/backup.rake
@@ -1,12 +1,12 @@
require 'active_record/fixtures'
namespace :gitlab do
- namespace :app do
+ namespace :backup do
# Create backup of GitLab system
desc "GITLAB | Create a backup of the GitLab system"
- task :backup_create => :environment do
- Rake::Task["gitlab:app:db_dump"].invoke
- Rake::Task["gitlab:app:repo_dump"].invoke
+ task :create => :environment do
+ Rake::Task["gitlab:backup:db:create"].invoke
+ Rake::Task["gitlab:backup:repo:create"].invoke
Dir.chdir(Gitlab.config.backup.path)
@@ -54,7 +54,7 @@ namespace :gitlab do
# Restore backup of GitLab system
desc "GITLAB | Restore a previously created backup"
- task :backup_restore => :environment do
+ task :restore => :environment do
Dir.chdir(Gitlab.config.backup.path)
# check for existing backups in the backup dir
@@ -62,7 +62,7 @@ namespace :gitlab do
puts "no backups found" if file_list.count == 0
if file_list.count > 1 && ENV["BACKUP"].nil?
puts "Found more than one backup, please specify which one you want to restore:"
- puts "rake gitlab:app:backup_restore BACKUP=timestamp_of_backup"
+ puts "rake gitlab:backup:restore BACKUP=timestamp_of_backup"
exit 1;
end
@@ -93,8 +93,8 @@ namespace :gitlab do
exit 1
end
- Rake::Task["gitlab:app:db_restore"].invoke
- Rake::Task["gitlab:app:repo_restore"].invoke
+ Rake::Task["gitlab:backup:db:restore"].invoke
+ Rake::Task["gitlab:backup:repo:restore"].invoke
# cleanup: remove tmp files
print "Deleting tmp directories..."
@@ -110,82 +110,86 @@ namespace :gitlab do
################################# REPOSITORIES #################################
- task :repo_dump => :environment do
- backup_path_repo = File.join(Gitlab.config.backup.path, "repositories")
- FileUtils.mkdir_p(backup_path_repo) until Dir.exists?(backup_path_repo)
- puts "Dumping repositories:"
- project = Project.all.map { |n| [n.path, n.path_to_repo] }
- project << ["gitolite-admin.git", File.join(File.dirname(project.first.second), "gitolite-admin.git")]
- project.each do |project|
- print "- Dumping repository #{project.first}... "
- if Kernel.system("cd #{project.second} > /dev/null 2>&1 && git bundle create #{backup_path_repo}/#{project.first}.bundle --all > /dev/null 2>&1")
- puts "[DONE]".green
- else
- puts "[FAILED]".red
+ namespace :repo do
+ task :create => :environment do
+ backup_path_repo = File.join(Gitlab.config.backup.path, "repositories")
+ FileUtils.mkdir_p(backup_path_repo) until Dir.exists?(backup_path_repo)
+ puts "Dumping repositories:"
+ project = Project.all.map { |n| [n.path, n.path_to_repo] }
+ project << ["gitolite-admin.git", File.join(File.dirname(project.first.second), "gitolite-admin.git")]
+ project.each do |project|
+ print "- Dumping repository #{project.first}... "
+ if Kernel.system("cd #{project.second} > /dev/null 2>&1 && git bundle create #{backup_path_repo}/#{project.first}.bundle --all > /dev/null 2>&1")
+ puts "[DONE]".green
+ else
+ puts "[FAILED]".red
+ end
end
end
- end
- task :repo_restore => :environment do
- backup_path_repo = File.join(Gitlab.config.backup.path, "repositories")
- puts "Restoring repositories:"
- project = Project.all.map { |n| [n.path, n.path_to_repo] }
- project << ["gitolite-admin.git", File.join(File.dirname(project.first.second), "gitolite-admin.git")]
- project.each do |project|
- print "- Restoring repository #{project.first}... "
- FileUtils.rm_rf(project.second) if File.dirname(project.second) # delete old stuff
- if Kernel.system("cd #{File.dirname(project.second)} > /dev/null 2>&1 && git clone --bare #{backup_path_repo}/#{project.first}.bundle #{project.first}.git > /dev/null 2>&1")
- permission_commands = [
- "sudo chmod -R g+rwX #{Gitlab.config.gitolite.repos_path}",
- "sudo chown -R #{Gitlab.config.gitolite.ssh_user}:#{Gitlab.config.gitolite.ssh_user} #{Gitlab.config.gitolite.repos_path}"
- ]
- permission_commands.each { |command| Kernel.system(command) }
- puts "[DONE]".green
- else
- puts "[FAILED]".red
+ task :restore => :environment do
+ backup_path_repo = File.join(Gitlab.config.backup.path, "repositories")
+ puts "Restoring repositories:"
+ project = Project.all.map { |n| [n.path, n.path_to_repo] }
+ project << ["gitolite-admin.git", File.join(File.dirname(project.first.second), "gitolite-admin.git")]
+ project.each do |project|
+ print "- Restoring repository #{project.first}... "
+ FileUtils.rm_rf(project.second) if File.dirname(project.second) # delete old stuff
+ if Kernel.system("cd #{File.dirname(project.second)} > /dev/null 2>&1 && git clone --bare #{backup_path_repo}/#{project.first}.bundle #{project.first}.git > /dev/null 2>&1")
+ permission_commands = [
+ "sudo chmod -R g+rwX #{Gitlab.config.git_base_path}",
+ "sudo chown -R #{Gitlab.config.ssh_user}:#{Gitlab.config.ssh_user} #{Gitlab.config.git_base_path}"
+ ]
+ permission_commands.each { |command| Kernel.system(command) }
+ puts "[DONE]".green
+ else
+ puts "[FAILED]".red
+ end
end
end
end
###################################### DB ######################################
- task :db_dump => :environment do
- backup_path_db = File.join(Gitlab.config.backup.path, "db")
- FileUtils.mkdir_p(backup_path_db) unless Dir.exists?(backup_path_db)
-
- puts "Dumping database tables:"
- ActiveRecord::Base.connection.tables.each do |tbl|
- print "- Dumping table #{tbl}... "
- count = 1
- File.open(File.join(backup_path_db, tbl + ".yml"), "w+") do |file|
- ActiveRecord::Base.connection.select_all("SELECT * FROM `#{tbl}`").each do |line|
- line.delete_if{|k,v| v.blank?}
- output = {tbl + '_' + count.to_s => line}
- file << output.to_yaml.gsub(/^---\n/,'') + "\n"
- count += 1
+ namespace :db do
+ task :create => :environment do
+ backup_path_db = File.join(Gitlab.config.backup.path, "db")
+ FileUtils.mkdir_p(backup_path_db) unless Dir.exists?(backup_path_db)
+
+ puts "Dumping database tables:"
+ ActiveRecord::Base.connection.tables.each do |tbl|
+ print "- Dumping table #{tbl}... "
+ count = 1
+ File.open(File.join(backup_path_db, tbl + ".yml"), "w+") do |file|
+ ActiveRecord::Base.connection.select_all("SELECT * FROM `#{tbl}`").each do |line|
+ line.delete_if{|k,v| v.blank?}
+ output = {tbl + '_' + count.to_s => line}
+ file << output.to_yaml.gsub(/^---\n/,'') + "\n"
+ count += 1
+ end
+ puts "[DONE]".green
end
- puts "[DONE]".green
end
end
- end
- task :db_restore=> :environment do
- backup_path_db = File.join(Gitlab.config.backup.path, "db")
+ task :restore=> :environment do
+ backup_path_db = File.join(Gitlab.config.backup.path, "db")
- puts "Restoring database tables:"
- Rake::Task["db:reset"].invoke
+ puts "Restoring database tables:"
+ Rake::Task["db:reset"].invoke
- Dir.glob(File.join(backup_path_db, "*.yml") ).each do |dir|
- fixture_file = File.basename(dir, ".*" )
- print "- Loading fixture #{fixture_file}..."
- if File.size(dir) > 0
- ActiveRecord::Fixtures.create_fixtures(backup_path_db, fixture_file)
- puts "[DONE]".green
- else
- puts "[SKIPPING]".yellow
+ Dir.glob(File.join(backup_path_db, "*.yml") ).each do |dir|
+ fixture_file = File.basename(dir, ".*" )
+ print "- Loading fixture #{fixture_file}..."
+ if File.size(dir) > 0
+ ActiveRecord::Fixtures.create_fixtures(backup_path_db, fixture_file)
+ puts "[DONE]".green
+ else
+ puts "[SKIPPING]".yellow
+ end
end
end
end
- end # namespace end: app
+ end # namespace end: backup
end # namespace end: gitlab
diff --git a/lib/tasks/gitlab/bulk_add_permission.rake b/lib/tasks/gitlab/bulk_add_permission.rake
new file mode 100644
index 00000000000..36c51d060bc
--- /dev/null
+++ b/lib/tasks/gitlab/bulk_add_permission.rake
@@ -0,0 +1,24 @@
+namespace :gitlab do
+ namespace :import do
+ desc "GITLAB | Add all users to all projects (admin users are added as masters)"
+ task :all_users_to_all_projects => :environment do |t, args|
+ user_ids = User.where(:admin => false).pluck(:id)
+ admin_ids = User.where(:admin => true).pluck(:id)
+
+ Project.find_each do |project|
+ puts "Importing #{user_ids.size} users into #{project.code}"
+ UsersProject.bulk_import(project, user_ids, UsersProject::DEVELOPER)
+ puts "Importing #{admin_ids.size} admins into #{project.code}"
+ UsersProject.bulk_import(project, admin_ids, UsersProject::MASTER)
+ end
+ end
+
+ desc "GITLAB | Add a specific user to all projects (as a developer)"
+ task :user_to_projects, [:email] => :environment do |t, args|
+ user = User.find_by_email args.email
+ project_ids = Project.pluck(:id)
+
+ UsersProject.user_bulk_import(user, project_ids, UsersProject::DEVELOPER)
+ end
+ end
+end \ No newline at end of file
diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake
index d1f814080b5..baa706d2bee 100644
--- a/lib/tasks/gitlab/check.rake
+++ b/lib/tasks/gitlab/check.rake
@@ -192,7 +192,9 @@ namespace :gitlab do
else
puts "no".red
try_fixing_it(
- "sudo -u gitlab -H bundle exec rake gitlab:app:enable_automerge"
+ "sudo -u gitlab -H bundle exec rake gitlab:satellites:create",
+ "If necessary, remove the tmp/repo_satellites directory ...",
+ "... and rerun the above command"
)
for_more_information(
"doc/raketasks/maintenance.md "
diff --git a/lib/tasks/gitlab/enable_automerge.rake b/lib/tasks/gitlab/enable_automerge.rake
index 13b4bab6edc..ed3d6368a99 100644
--- a/lib/tasks/gitlab/enable_automerge.rake
+++ b/lib/tasks/gitlab/enable_automerge.rake
@@ -1,17 +1,20 @@
namespace :gitlab do
- namespace :app do
- desc "GITLAB | Enable auto merge"
- task :enable_automerge => :environment do
- Gitlab::Gitolite.new.enable_automerge
+ desc "GITLAB | Enable auto merge"
+ task :enable_automerge => :environment do
+ Gitlab::Gitolite.new.enable_automerge
- Project.find_each do |project|
- if project.repo_exists? && !project.satellite.exists?
- puts "Creating satellite for #{project.name}...".green
- project.satellite.create
- end
+ Project.find_each do |project|
+ if project.repo_exists? && !project.satellite.exists?
+ puts "Creating satellite for #{project.name}...".green
+ project.satellite.create
end
-
- puts "Done!".green
end
+
+ puts "Done!".green
+ end
+
+ namespace :satellites do
+ desc "GITLAB | Create satellite repos"
+ task create: 'gitlab:enable_automerge'
end
end
diff --git a/lib/tasks/gitlab/activate_namespaces.rake b/lib/tasks/gitlab/enable_namespaces.rake
index 70ec88d0b3f..1be9ba6469d 100644
--- a/lib/tasks/gitlab/activate_namespaces.rake
+++ b/lib/tasks/gitlab/enable_namespaces.rake
@@ -1,6 +1,6 @@
namespace :gitlab do
desc "GITLAB | Enable usernames and namespaces for user projects"
- task activate_namespaces: :environment do
+ task enable_namespaces: :environment do
print "\nUsernames for users:".yellow
User.find_each(batch_size: 500) do |user|
diff --git a/lib/tasks/gitlab/setup.rake b/lib/tasks/gitlab/setup.rake
index 08f35c7e3f0..572a22aa1f6 100644
--- a/lib/tasks/gitlab/setup.rake
+++ b/lib/tasks/gitlab/setup.rake
@@ -4,7 +4,7 @@ namespace :gitlab do
task :setup => [
'db:setup',
'db:seed_fu',
- 'gitlab:app:enable_automerge'
+ 'gitlab:enable_automerge'
]
end
end