Commit 83696b127b7822482957a894816b0e3c2daea0b5
1 parent
30ee5362
Exists in
master
and in
4 other branches
cleanup rake tasks
Showing
8 changed files
with
77 additions
and
120 deletions
Show diff stats
lib/tasks/bulk_add_permission.rake
1 | -desc "Add all users to all projects, system administratos are added as masters" | 1 | +desc "Add all users to all projects (admin users are added as masters)" |
2 | task :add_users_to_project_teams => :environment do |t, args| | 2 | task :add_users_to_project_teams => :environment do |t, args| |
3 | - users = User.find_all_by_admin(false, :select => 'id').map(&:id) | ||
4 | - admins = User.find_all_by_admin(true, :select => 'id').map(&:id) | 3 | + user_ids = User.where(:admin => false).pluck(:id) |
4 | + admin_ids = User.where(:admin => true).pluck(:id) | ||
5 | 5 | ||
6 | - users.each do |user| | ||
7 | - puts "#{user}" | ||
8 | - end | ||
9 | - | ||
10 | - Project.all.each do |project| | ||
11 | - puts "Importing #{users.length} users into #{project.path}" | ||
12 | - UsersProject.bulk_import(project, users, UsersProject::DEVELOPER) | ||
13 | - puts "Importing #{admins.length} admins into #{project.path}" | ||
14 | - UsersProject.bulk_import(project, admins, UsersProject::MASTER) | 6 | + Project.find_each do |project| |
7 | + puts "Importing #{user_ids.size} users into #{project.code}" | ||
8 | + UsersProject.bulk_import(project, user_ids, UsersProject::DEVELOPER) | ||
9 | + puts "Importing #{admin_ids.size} admins into #{project.code}" | ||
10 | + UsersProject.bulk_import(project, admin_ids, UsersProject::MASTER) | ||
15 | end | 11 | end |
16 | end | 12 | end |
17 | 13 | ||
18 | desc "Add user to as a developer to all projects" | 14 | desc "Add user to as a developer to all projects" |
19 | task :add_user_to_project_teams, [:email] => :environment do |t, args| | 15 | task :add_user_to_project_teams, [:email] => :environment do |t, args| |
20 | - user_email = args.email | ||
21 | - user = User.find_by_email(user_email) | ||
22 | - | ||
23 | - project_ids = Project.all.map(&:id) | 16 | + user = User.find_by_email args.email |
17 | + project_ids = Project.pluck(:id) | ||
24 | 18 | ||
25 | - UsersProject.user_bulk_import(user,project_ids,UsersProject::DEVELOPER) | 19 | + UsersProject.user_bulk_import(user, project_ids, UsersProject::DEVELOPER) |
26 | end | 20 | end |
lib/tasks/bulk_import.rake
1 | - | ||
2 | desc "Imports existing Git repos from a directory into new projects in git_base_path" | 1 | desc "Imports existing Git repos from a directory into new projects in git_base_path" |
3 | task :import_projects, [:directory,:email] => :environment do |t, args| | 2 | task :import_projects, [:directory,:email] => :environment do |t, args| |
4 | - user_email = args.email | ||
5 | - import_directory = args.directory | 3 | + user_email, import_directory = args.email, args.directory |
6 | repos_to_import = Dir.glob("#{import_directory}/*") | 4 | repos_to_import = Dir.glob("#{import_directory}/*") |
7 | git_base_path = Gitlab.config.git_base_path | 5 | git_base_path = Gitlab.config.git_base_path |
8 | - puts "Found #{repos_to_import.length} repos to import" | 6 | + imported_count, skipped_count, failed_count = 0 |
7 | + | ||
8 | + puts "Found #{repos_to_import.size} repos to import" | ||
9 | 9 | ||
10 | - imported_count = 0 | ||
11 | - skipped_count = 0 | ||
12 | - failed_count = 0 | ||
13 | repos_to_import.each do |repo_path| | 10 | repos_to_import.each do |repo_path| |
14 | repo_name = File.basename repo_path | 11 | repo_name = File.basename repo_path |
12 | + clone_path = "#{git_base_path}#{repo_name}.git" | ||
15 | 13 | ||
16 | puts " Processing #{repo_name}" | 14 | puts " Processing #{repo_name}" |
17 | - clone_path = "#{git_base_path}#{repo_name}.git" | ||
18 | 15 | ||
19 | if Dir.exists? clone_path | 16 | if Dir.exists? clone_path |
20 | if Project.find_by_code(repo_name) | 17 | if Project.find_by_code(repo_name) |
@@ -38,7 +35,6 @@ task :import_projects, [:directory,:email] => :environment do |t, args| | @@ -38,7 +35,6 @@ task :import_projects, [:directory,:email] => :environment do |t, args| | ||
38 | else | 35 | else |
39 | failed_count += 1 | 36 | failed_count += 1 |
40 | end | 37 | end |
41 | - | ||
42 | end | 38 | end |
43 | 39 | ||
44 | puts "Finished importing #{imported_count} projects (skipped #{skipped_count}, failed #{failed_count})." | 40 | puts "Finished importing #{imported_count} projects (skipped #{skipped_count}, failed #{failed_count})." |
@@ -49,63 +45,39 @@ def clone_bare_repo_as_git(existing_path, new_path) | @@ -49,63 +45,39 @@ def clone_bare_repo_as_git(existing_path, new_path) | ||
49 | git_user = Gitlab.config.ssh_user | 45 | git_user = Gitlab.config.ssh_user |
50 | begin | 46 | begin |
51 | sh "sudo -u #{git_user} -i git clone --bare '#{existing_path}' #{new_path}" | 47 | sh "sudo -u #{git_user} -i git clone --bare '#{existing_path}' #{new_path}" |
52 | - true | ||
53 | - rescue Exception=> msg | ||
54 | - puts " ERROR: Faild to clone #{existing_path} to #{new_path}" | ||
55 | - puts " Make sure #{git_user} can reach #{existing_path}" | ||
56 | - puts " Exception-MSG: #{msg}" | ||
57 | - false | 48 | + rescue Exception => msg |
49 | + puts " ERROR: Failed to clone #{existing_path} to #{new_path}" | ||
50 | + puts " Make sure #{git_user} can reach #{existing_path}" | ||
51 | + puts " Exception-MSG: #{msg}" | ||
58 | end | 52 | end |
59 | end | 53 | end |
60 | 54 | ||
61 | -# Creats a project in Gitlag given a @project_name@ to use (for name, web url, and code | ||
62 | -# url) and a @user_email@ that will be assigned as the owner of the project. | 55 | +# Creates a project in GitLab given a `project_name` to use |
56 | +# (for name, web url, and code url) and a `user_email` that will be | ||
57 | +# assigned as the owner of the project. | ||
63 | def create_repo_project(project_name, user_email) | 58 | def create_repo_project(project_name, user_email) |
64 | - user = User.find_by_email(user_email) | ||
65 | - if user | 59 | + if user = User.find_by_email(user_email) |
66 | # Using find_by_code since that's the most important identifer to be unique | 60 | # Using find_by_code since that's the most important identifer to be unique |
67 | if Project.find_by_code(project_name) | 61 | if Project.find_by_code(project_name) |
68 | puts " INFO: Project #{project_name} already exists in Gitlab, skipping." | 62 | puts " INFO: Project #{project_name} already exists in Gitlab, skipping." |
69 | - false | ||
70 | else | 63 | else |
71 | - project = nil | ||
72 | - if Project.find_by_code(project_name) | ||
73 | - puts " ERROR: Project already exists #{project_name}" | ||
74 | - return false | ||
75 | - project = Project.find_by_code(project_name) | ||
76 | - else | ||
77 | - project = Project.create( | ||
78 | - name: project_name, | ||
79 | - code: project_name, | ||
80 | - path: project_name, | ||
81 | - owner: user, | ||
82 | - description: "Automatically created from Rake on #{Time.now.to_s}" | ||
83 | - ) | ||
84 | - end | ||
85 | - | ||
86 | - unless project.valid? | ||
87 | - puts " ERROR: Failed to create project #{project} because #{project.errors.first}" | ||
88 | - return false | ||
89 | - end | ||
90 | - | ||
91 | - # Add user as admin for project | ||
92 | - project.users_projects.create!( | ||
93 | - :project_access => UsersProject::MASTER, | ||
94 | - :user => user | 64 | + project = Project.create( |
65 | + name: project_name, | ||
66 | + code: project_name, | ||
67 | + path: project_name, | ||
68 | + owner: user, | ||
69 | + description: "Automatically created from 'import_projects' rake task on #{Time.now}" | ||
95 | ) | 70 | ) |
96 | 71 | ||
97 | - # Per projects_controller.rb#37 | ||
98 | - project.update_repository | ||
99 | - | ||
100 | if project.valid? | 72 | if project.valid? |
101 | - true | 73 | + # Add user as admin for project |
74 | + project.users_projects.create!(:project_access => UsersProject::MASTER, :user => user) | ||
75 | + project.update_repository | ||
102 | else | 76 | else |
103 | puts " ERROR: Failed to create project #{project} because #{project.errors.first}" | 77 | puts " ERROR: Failed to create project #{project} because #{project.errors.first}" |
104 | - false | ||
105 | end | 78 | end |
106 | end | 79 | end |
107 | else | 80 | else |
108 | - puts " ERROR: #{user_email} not found, skipping" | ||
109 | - false | 81 | + puts " ERROR: user with #{user_email} not found, skipping" |
110 | end | 82 | end |
111 | end | 83 | end |
lib/tasks/gitlab/backup.rake
@@ -2,22 +2,20 @@ require 'active_record/fixtures' | @@ -2,22 +2,20 @@ require 'active_record/fixtures' | ||
2 | 2 | ||
3 | namespace :gitlab do | 3 | namespace :gitlab do |
4 | namespace :app do | 4 | namespace :app do |
5 | - | ||
6 | - # Create backup of gitlab system | ||
7 | - desc "GITLAB | Create a backup of the gitlab system" | 5 | + # Create backup of GitLab system |
6 | + desc "GITLAB | Create a backup of the GitLab system" | ||
8 | task :backup_create => :environment do | 7 | task :backup_create => :environment do |
9 | - | ||
10 | Rake::Task["gitlab:app:db_dump"].invoke | 8 | Rake::Task["gitlab:app:db_dump"].invoke |
11 | Rake::Task["gitlab:app:repo_dump"].invoke | 9 | Rake::Task["gitlab:app:repo_dump"].invoke |
12 | 10 | ||
13 | Dir.chdir(Gitlab.config.backup_path) | 11 | Dir.chdir(Gitlab.config.backup_path) |
14 | 12 | ||
15 | # saving additional informations | 13 | # saving additional informations |
16 | - s = Hash.new | ||
17 | - s["db_version"] = "#{ActiveRecord::Migrator.current_version}" | ||
18 | - s["backup_created_at"] = "#{Time.now}" | ||
19 | - s["gitlab_version"] = %x{git rev-parse HEAD}.gsub(/\n/,"") | ||
20 | - s["tar_version"] = %x{tar --version | head -1}.gsub(/\n/,"") | 14 | + s = {} |
15 | + s[:db_version] = "#{ActiveRecord::Migrator.current_version}" | ||
16 | + s[:backup_created_at] = "#{Time.now}" | ||
17 | + s[:gitlab_version] = %x{git rev-parse HEAD}.gsub(/\n/,"") | ||
18 | + s[:tar_version] = %x{tar --version | head -1}.gsub(/\n/,"") | ||
21 | 19 | ||
22 | File.open("#{Gitlab.config.backup_path}/backup_information.yml", "w+") do |file| | 20 | File.open("#{Gitlab.config.backup_path}/backup_information.yml", "w+") do |file| |
23 | file << s.to_yaml.gsub(/^---\n/,'') | 21 | file << s.to_yaml.gsub(/^---\n/,'') |
@@ -32,7 +30,7 @@ namespace :gitlab do | @@ -32,7 +30,7 @@ namespace :gitlab do | ||
32 | end | 30 | end |
33 | 31 | ||
34 | # cleanup: remove tmp files | 32 | # cleanup: remove tmp files |
35 | - print "Deletion of tmp directories..." | 33 | + print "Deleting tmp directories..." |
36 | if Kernel.system("rm -rf repositories/ db/ backup_information.yml") | 34 | if Kernel.system("rm -rf repositories/ db/ backup_information.yml") |
37 | puts "[DONE]".green | 35 | puts "[DONE]".green |
38 | else | 36 | else |
@@ -52,26 +50,23 @@ namespace :gitlab do | @@ -52,26 +50,23 @@ namespace :gitlab do | ||
52 | else | 50 | else |
53 | puts "[SKIPPING]".yellow | 51 | puts "[SKIPPING]".yellow |
54 | end | 52 | end |
55 | - | ||
56 | end | 53 | end |
57 | 54 | ||
58 | - | ||
59 | - # Restore backup of gitlab system | 55 | + # Restore backup of GitLab system |
60 | desc "GITLAB | Restore a previously created backup" | 56 | desc "GITLAB | Restore a previously created backup" |
61 | task :backup_restore => :environment do | 57 | task :backup_restore => :environment do |
62 | - | ||
63 | Dir.chdir(Gitlab.config.backup_path) | 58 | Dir.chdir(Gitlab.config.backup_path) |
64 | 59 | ||
65 | # check for existing backups in the backup dir | 60 | # check for existing backups in the backup dir |
66 | file_list = Dir.glob("*_gitlab_backup.tar").each.map { |f| f.split(/_/).first.to_i } | 61 | file_list = Dir.glob("*_gitlab_backup.tar").each.map { |f| f.split(/_/).first.to_i } |
67 | - puts "no backup found" if file_list.count == 0 | 62 | + puts "no backups found" if file_list.count == 0 |
68 | if file_list.count > 1 && ENV["BACKUP"].nil? | 63 | if file_list.count > 1 && ENV["BACKUP"].nil? |
69 | puts "Found more than one backup, please specify which one you want to restore:" | 64 | puts "Found more than one backup, please specify which one you want to restore:" |
70 | puts "rake gitlab:app:backup_restore BACKUP=timestamp_of_backup" | 65 | puts "rake gitlab:app:backup_restore BACKUP=timestamp_of_backup" |
71 | exit 1; | 66 | exit 1; |
72 | end | 67 | end |
73 | 68 | ||
74 | - tar_file = ENV["BACKUP"].nil? ? File.join(file_list.first.to_s + "_gitlab_backup.tar") : File.join(ENV["BACKUP"] + "_gitlab_backup.tar") | 69 | + tar_file = ENV["BACKUP"].nil? ? File.join("#{file_list.first}_gitlab_backup.tar") : File.join(ENV["BACKUP"] + "_gitlab_backup.tar") |
75 | 70 | ||
76 | unless File.exists?(tar_file) | 71 | unless File.exists?(tar_file) |
77 | puts "The specified backup doesn't exist!" | 72 | puts "The specified backup doesn't exist!" |
@@ -102,16 +97,14 @@ namespace :gitlab do | @@ -102,16 +97,14 @@ namespace :gitlab do | ||
102 | Rake::Task["gitlab:app:repo_restore"].invoke | 97 | Rake::Task["gitlab:app:repo_restore"].invoke |
103 | 98 | ||
104 | # cleanup: remove tmp files | 99 | # cleanup: remove tmp files |
105 | - print "Deletion of tmp directories..." | 100 | + print "Deleting tmp directories..." |
106 | if Kernel.system("rm -rf repositories/ db/ backup_information.yml") | 101 | if Kernel.system("rm -rf repositories/ db/ backup_information.yml") |
107 | puts "[DONE]".green | 102 | puts "[DONE]".green |
108 | else | 103 | else |
109 | puts "[FAILED]".red | 104 | puts "[FAILED]".red |
110 | end | 105 | end |
111 | - | ||
112 | end | 106 | end |
113 | 107 | ||
114 | - | ||
115 | ################################################################################ | 108 | ################################################################################ |
116 | ################################# invoked tasks ################################ | 109 | ################################# invoked tasks ################################ |
117 | 110 | ||
@@ -121,7 +114,7 @@ namespace :gitlab do | @@ -121,7 +114,7 @@ namespace :gitlab do | ||
121 | backup_path_repo = File.join(Gitlab.config.backup_path, "repositories") | 114 | backup_path_repo = File.join(Gitlab.config.backup_path, "repositories") |
122 | FileUtils.mkdir_p(backup_path_repo) until Dir.exists?(backup_path_repo) | 115 | FileUtils.mkdir_p(backup_path_repo) until Dir.exists?(backup_path_repo) |
123 | puts "Dumping repositories:" | 116 | puts "Dumping repositories:" |
124 | - project = Project.all.map { |n| [n.path,n.path_to_repo] } | 117 | + project = Project.all.map { |n| [n.path, n.path_to_repo] } |
125 | project << ["gitolite-admin.git", File.join(File.dirname(project.first.second), "gitolite-admin.git")] | 118 | project << ["gitolite-admin.git", File.join(File.dirname(project.first.second), "gitolite-admin.git")] |
126 | project.each do |project| | 119 | project.each do |project| |
127 | print "- Dumping repository #{project.first}... " | 120 | print "- Dumping repository #{project.first}... " |
@@ -136,11 +129,11 @@ namespace :gitlab do | @@ -136,11 +129,11 @@ namespace :gitlab do | ||
136 | task :repo_restore => :environment do | 129 | task :repo_restore => :environment do |
137 | backup_path_repo = File.join(Gitlab.config.backup_path, "repositories") | 130 | backup_path_repo = File.join(Gitlab.config.backup_path, "repositories") |
138 | puts "Restoring repositories:" | 131 | puts "Restoring repositories:" |
139 | - project = Project.all.map { |n| [n.path,n.path_to_repo] } | 132 | + project = Project.all.map { |n| [n.path, n.path_to_repo] } |
140 | project << ["gitolite-admin.git", File.join(File.dirname(project.first.second), "gitolite-admin.git")] | 133 | project << ["gitolite-admin.git", File.join(File.dirname(project.first.second), "gitolite-admin.git")] |
141 | project.each do |project| | 134 | project.each do |project| |
142 | print "- Restoring repository #{project.first}... " | 135 | print "- Restoring repository #{project.first}... " |
143 | - FileUtils.rm_rf(project.second) if File.dirname(project.second) # delet old stuff | 136 | + FileUtils.rm_rf(project.second) if File.dirname(project.second) # delete old stuff |
144 | 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") | 137 | 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") |
145 | permission_commands = [ | 138 | permission_commands = [ |
146 | "sudo chmod -R g+rwX #{Gitlab.config.git_base_path}", | 139 | "sudo chmod -R g+rwX #{Gitlab.config.git_base_path}", |
@@ -157,8 +150,9 @@ namespace :gitlab do | @@ -157,8 +150,9 @@ namespace :gitlab do | ||
157 | ###################################### DB ###################################### | 150 | ###################################### DB ###################################### |
158 | 151 | ||
159 | task :db_dump => :environment do | 152 | task :db_dump => :environment do |
160 | - backup_path_db = File.join(Gitlab.config.backup_path, "db") | ||
161 | - FileUtils.mkdir_p(backup_path_db) until Dir.exists?(backup_path_db) | 153 | + backup_path_db = File.join(Gitlab.config.backup_path, "db") |
154 | + FileUtils.mkdir_p(backup_path_db) unless Dir.exists?(backup_path_db) | ||
155 | + | ||
162 | puts "Dumping database tables:" | 156 | puts "Dumping database tables:" |
163 | ActiveRecord::Base.connection.tables.each do |tbl| | 157 | ActiveRecord::Base.connection.tables.each do |tbl| |
164 | print "- Dumping table #{tbl}... " | 158 | print "- Dumping table #{tbl}... " |
@@ -176,9 +170,11 @@ namespace :gitlab do | @@ -176,9 +170,11 @@ namespace :gitlab do | ||
176 | end | 170 | end |
177 | 171 | ||
178 | task :db_restore=> :environment do | 172 | task :db_restore=> :environment do |
179 | - backup_path_db = File.join(Gitlab.config.backup_path, "db") | 173 | + backup_path_db = File.join(Gitlab.config.backup_path, "db") |
174 | + | ||
180 | puts "Restoring database tables:" | 175 | puts "Restoring database tables:" |
181 | Rake::Task["db:reset"].invoke | 176 | Rake::Task["db:reset"].invoke |
177 | + | ||
182 | Dir.glob(File.join(backup_path_db, "*.yml") ).each do |dir| | 178 | Dir.glob(File.join(backup_path_db, "*.yml") ).each do |dir| |
183 | fixture_file = File.basename(dir, ".*" ) | 179 | fixture_file = File.basename(dir, ".*" ) |
184 | print "- Loading fixture #{fixture_file}..." | 180 | print "- Loading fixture #{fixture_file}..." |
lib/tasks/gitlab/enable_automerge.rake
1 | namespace :gitlab do | 1 | namespace :gitlab do |
2 | namespace :app do | 2 | namespace :app do |
3 | desc "GITLAB | Enable auto merge" | 3 | desc "GITLAB | Enable auto merge" |
4 | - task :enable_automerge => :environment do | 4 | + task :enable_automerge => :environment do |
5 | Gitlab::Gitolite.new.enable_automerge | 5 | Gitlab::Gitolite.new.enable_automerge |
6 | 6 | ||
7 | Project.find_each do |project| | 7 | Project.find_each do |project| |
lib/tasks/gitlab/gitolite_rebuild.rake
1 | namespace :gitlab do | 1 | namespace :gitlab do |
2 | namespace :gitolite do | 2 | namespace :gitolite do |
3 | desc "GITLAB | Rebuild each project at gitolite config" | 3 | desc "GITLAB | Rebuild each project at gitolite config" |
4 | - task :update_repos => :environment do | 4 | + task :update_repos => :environment do |
5 | puts "Starting Projects" | 5 | puts "Starting Projects" |
6 | Project.find_each(:batch_size => 100) do |project| | 6 | Project.find_each(:batch_size => 100) do |project| |
7 | - puts | ||
8 | - puts "=== #{project.name}" | 7 | + puts "\n=== #{project.name}" |
9 | project.update_repository | 8 | project.update_repository |
10 | puts | 9 | puts |
11 | end | 10 | end |
lib/tasks/gitlab/setup.rake
lib/tasks/gitlab/status.rake
1 | namespace :gitlab do | 1 | namespace :gitlab do |
2 | namespace :app do | 2 | namespace :app do |
3 | - desc "GITLAB | Check gitlab installation status" | 3 | + desc "GITLAB | Check GitLab installation status" |
4 | task :status => :environment do | 4 | task :status => :environment do |
5 | - puts "Starting diagnostic".yellow | 5 | + puts "Starting diagnostics".yellow |
6 | git_base_path = Gitlab.config.git_base_path | 6 | git_base_path = Gitlab.config.git_base_path |
7 | 7 | ||
8 | print "config/database.yml............" | 8 | print "config/database.yml............" |
9 | - if File.exists?(File.join Rails.root, "config", "database.yml") | 9 | + if File.exists?(Rails.root.join "config", "database.yml") |
10 | puts "exists".green | 10 | puts "exists".green |
11 | - else | 11 | + else |
12 | puts "missing".red | 12 | puts "missing".red |
13 | return | 13 | return |
14 | end | 14 | end |
15 | 15 | ||
16 | print "config/gitlab.yml............" | 16 | print "config/gitlab.yml............" |
17 | - if File.exists?(File.join Rails.root, "config", "gitlab.yml") | ||
18 | - puts "exists".green | 17 | + if File.exists?(Rails.root.join "config", "gitlab.yml") |
18 | + puts "exists".green | ||
19 | else | 19 | else |
20 | puts "missing".red | 20 | puts "missing".red |
21 | return | 21 | return |
22 | end | 22 | end |
23 | 23 | ||
24 | print "#{git_base_path}............" | 24 | print "#{git_base_path}............" |
25 | - if File.exists?(git_base_path) | ||
26 | - puts "exists".green | ||
27 | - else | 25 | + if File.exists?(git_base_path) |
26 | + puts "exists".green | ||
27 | + else | ||
28 | puts "missing".red | 28 | puts "missing".red |
29 | return | 29 | return |
30 | end | 30 | end |
31 | 31 | ||
32 | print "#{git_base_path} is writable?............" | 32 | print "#{git_base_path} is writable?............" |
33 | if File.stat(git_base_path).writable? | 33 | if File.stat(git_base_path).writable? |
34 | - puts "YES".green | 34 | + puts "YES".green |
35 | else | 35 | else |
36 | puts "NO".red | 36 | puts "NO".red |
37 | return | 37 | return |
@@ -41,16 +41,16 @@ namespace :gitlab do | @@ -41,16 +41,16 @@ namespace :gitlab do | ||
41 | `git clone #{Gitlab.config.gitolite_admin_uri} /tmp/gitolite_gitlab_test` | 41 | `git clone #{Gitlab.config.gitolite_admin_uri} /tmp/gitolite_gitlab_test` |
42 | FileUtils.rm_rf("/tmp/gitolite_gitlab_test") | 42 | FileUtils.rm_rf("/tmp/gitolite_gitlab_test") |
43 | print "Can clone gitolite-admin?............" | 43 | print "Can clone gitolite-admin?............" |
44 | - puts "YES".green | ||
45 | - rescue | 44 | + puts "YES".green |
45 | + rescue | ||
46 | print "Can clone gitolite-admin?............" | 46 | print "Can clone gitolite-admin?............" |
47 | puts "NO".red | 47 | puts "NO".red |
48 | return | 48 | return |
49 | end | 49 | end |
50 | 50 | ||
51 | print "UMASK for .gitolite.rc is 0007? ............" | 51 | print "UMASK for .gitolite.rc is 0007? ............" |
52 | - unless open("#{git_base_path}/../.gitolite.rc").grep(/UMASK([ \t]*)=([ \t>]*)0007/).empty? | ||
53 | - puts "YES".green | 52 | + if open("#{git_base_path}/../.gitolite.rc").grep(/UMASK([ \t]*)=([ \t>]*)0007/).any? |
53 | + puts "YES".green | ||
54 | else | 54 | else |
55 | puts "NO".red | 55 | puts "NO".red |
56 | return | 56 | return |
@@ -69,16 +69,15 @@ namespace :gitlab do | @@ -69,16 +69,15 @@ namespace :gitlab do | ||
69 | end | 69 | end |
70 | end | 70 | end |
71 | 71 | ||
72 | - | ||
73 | - if Project.count > 0 | 72 | + if Project.count > 0 |
74 | puts "Validating projects repositories:".yellow | 73 | puts "Validating projects repositories:".yellow |
75 | Project.find_each(:batch_size => 100) do |project| | 74 | Project.find_each(:batch_size => 100) do |project| |
76 | print "#{project.name}....." | 75 | print "#{project.name}....." |
77 | - hook_file = File.join(project.path_to_repo, 'hooks','post-receive') | 76 | + hook_file = File.join(project.path_to_repo, 'hooks', 'post-receive') |
78 | 77 | ||
79 | unless File.exists?(hook_file) | 78 | unless File.exists?(hook_file) |
80 | - puts "post-receive file missing".red | ||
81 | - next | 79 | + puts "post-receive file missing".red |
80 | + return | ||
82 | end | 81 | end |
83 | 82 | ||
84 | puts "post-receive file ok".green | 83 | puts "post-receive file ok".green |
lib/tasks/gitlab/write_hook.rake
@@ -4,7 +4,6 @@ namespace :gitlab do | @@ -4,7 +4,6 @@ namespace :gitlab do | ||
4 | task :write_hooks => :environment do | 4 | task :write_hooks => :environment do |
5 | gitolite_hooks_path = File.join(Gitlab.config.git_hooks_path, "common") | 5 | gitolite_hooks_path = File.join(Gitlab.config.git_hooks_path, "common") |
6 | gitlab_hooks_path = Rails.root.join("lib", "hooks") | 6 | gitlab_hooks_path = Rails.root.join("lib", "hooks") |
7 | - | ||
8 | gitlab_hook_files = ['post-receive'] | 7 | gitlab_hook_files = ['post-receive'] |
9 | 8 | ||
10 | gitlab_hook_files.each do |file_name| | 9 | gitlab_hook_files.each do |file_name| |
@@ -20,4 +19,3 @@ namespace :gitlab do | @@ -20,4 +19,3 @@ namespace :gitlab do | ||
20 | end | 19 | end |
21 | end | 20 | end |
22 | end | 21 | end |
23 | - |