Commit 43f5df21a39e0b9b16738bbd9e4047507bbcc9ef

Authored by Dmitriy Zaporozhets
1 parent c40c627a

gitlab rake tasks refactored

@@ -17,4 +17,5 @@ Vagrantfile @@ -17,4 +17,5 @@ Vagrantfile
17 config/gitlab.yml 17 config/gitlab.yml
18 config/database.yml 18 config/database.yml
19 config/initializers/omniauth.rb 19 config/initializers/omniauth.rb
  20 +config/unicorn.rb
20 db/data.yml 21 db/data.yml
  1 +v 2.4.0
  2 + - Accept merge request
  3 +
  4 +v 2.3.1
  5 + - Issues pagination
  6 + - ssl fixes
  7 + - Merge Request pagination
  8 +
1 v 2.3.0 9 v 2.3.0
2 - Dashboard r1 10 - Dashboard r1
3 - Search r1 11 - Search r1
@@ -12,7 +12,7 @@ GitLab is a free project and repository management application @@ -12,7 +12,7 @@ GitLab is a free project and repository management application
12 ## Requirements 12 ## Requirements
13 13
14 * Ubuntu/Debian 14 * Ubuntu/Debian
15 -* ruby 1.9.2 15 +* ruby 1.9.2+
16 * mysql or sqlite 16 * mysql or sqlite
17 * git 17 * git
18 * gitolite 18 * gitolite
1 -2.3.0 1 +2.4.0pre
doc/installation.md
@@ -159,12 +159,11 @@ Permissions: @@ -159,12 +159,11 @@ Permissions:
159 159
160 #### Setup DB 160 #### Setup DB
161 161
162 - sudo -u gitlab bundle exec rake db:setup RAILS_ENV=production  
163 - sudo -u gitlab bundle exec rake db:seed_fu RAILS_ENV=production 162 + sudo -u gitlab bundle exec rake gitlab:app:setup RAILS_ENV=production
164 163
165 Checking status: 164 Checking status:
166 165
167 - sudo -u gitlab bundle exec rake gitlab_status RAILS_ENV=production 166 + sudo -u gitlab bundle exec rake gitlab:app:status RAILS_ENV=production
168 167
169 168
170 # OUTPUT EXAMPLE 169 # OUTPUT EXAMPLE
lib/tasks/dev/repo.rake 0 → 100644
@@ -0,0 +1,26 @@ @@ -0,0 +1,26 @@
  1 +namespace :dev do
  2 + desc "Prepare for development (run dev_user.sh first)"
  3 + task :repos => :environment do
  4 + key = `sudo -u gitlabdev -H cat /home/gitlabdev/.ssh/id_rsa.pub`
  5 + raise "\n *** Run ./lib/tasks/dev/user.sh first *** \n" if key.empty?
  6 + Key.create(:user_id => User.first, :key => key, :title => "gitlabdev")
  7 +
  8 + puts "\n *** Clone diaspora from github"
  9 + `sudo -u gitlabdev -H sh -c "cd /home/gitlabdev; git clone git://github.com/diaspora/diaspora.git /home/gitlabdev/diaspora"`
  10 +
  11 + puts "\n *** Push diaspora source to gitlab"
  12 + `sudo -u gitlabdev -H sh -c "cd /home/gitlabdev/diaspora; git remote add local git@localhost:diaspora.git; git push local master; git push local --tags; git checkout -b api origin/api; git push local api; git checkout -b heroku origin/heroku; git push local heroku"`
  13 +
  14 + puts "\n *** Clone rails from github"
  15 + `sudo -u gitlabdev -H sh -c "cd /home/gitlabdev; git clone git://github.com/rails/rails.git /home/gitlabdev/rails"`
  16 +
  17 + puts "\n *** Push rails source to gitlab"
  18 + `sudo -u gitlabdev -H sh -c "cd /home/gitlabdev/rails; git remote add local git@localhost:ruby_on_rails.git; git push local master; git push local --tags"`
  19 +
  20 + puts "\n *** Clone rubinius from github"
  21 + `sudo -u gitlabdev -H sh -c "cd /home/gitlabdev; git clone git://github.com/rubinius/rubinius.git /home/gitlabdev/rubinius"`
  22 +
  23 + puts "\n *** Push rubinius source to gitlab"
  24 + `sudo -u gitlabdev -H sh -c "cd /home/gitlabdev/rubinius; git remote add local git@localhost:rubinius.git; git push local master; git push local --tags"`
  25 + end
  26 +end
lib/tasks/dev/user.sh 0 → 100755
@@ -0,0 +1,7 @@ @@ -0,0 +1,7 @@
  1 +sudo adduser \
  2 + --gecos 'gitlab dev user' \
  3 + --disabled-password \
  4 + --home /home/gitlabdev \
  5 + gitlabdev
  6 +
  7 +sudo -i -u gitlabdev -H sh -c "ssh-keygen -t rsa"
lib/tasks/dev_repo.rake
@@ -1,24 +0,0 @@ @@ -1,24 +0,0 @@
1 -desc "Prepare for development"  
2 -task :dev_repo => :environment do  
3 -key = `sudo -u gitlabdev -H cat /home/gitlabdev/.ssh/id_rsa.pub`  
4 -raise "\n *** Run ./lib/tasks/dev_user.sh first *** \n" if key.empty?  
5 -Key.create(:user_id => User.first, :key => key, :title => "gitlabdev")  
6 -  
7 -puts "\n *** Clone diaspora from github"  
8 -`sudo -u gitlabdev -H sh -c "cd /home/gitlabdev; git clone git://github.com/diaspora/diaspora.git /home/gitlabdev/diaspora"`  
9 -  
10 -puts "\n *** Push diaspora source to gitlab"  
11 -`sudo -u gitlabdev -H sh -c "cd /home/gitlabdev/diaspora; git remote add local git@localhost:diaspora.git; git push local master; git push local --tags; git checkout -b api origin/api; git push local api; git checkout -b heroku origin/heroku; git push local heroku"`  
12 -  
13 -puts "\n *** Clone rails from github"  
14 -`sudo -u gitlabdev -H sh -c "cd /home/gitlabdev; git clone git://github.com/rails/rails.git /home/gitlabdev/rails"`  
15 -  
16 -puts "\n *** Push rails source to gitlab"  
17 -`sudo -u gitlabdev -H sh -c "cd /home/gitlabdev/rails; git remote add local git@localhost:ruby_on_rails.git; git push local master; git push local --tags"`  
18 -  
19 -puts "\n *** Clone rubinius from github"  
20 -`sudo -u gitlabdev -H sh -c "cd /home/gitlabdev; git clone git://github.com/rubinius/rubinius.git /home/gitlabdev/rubinius"`  
21 -  
22 -puts "\n *** Push rubinius source to gitlab"  
23 -`sudo -u gitlabdev -H sh -c "cd /home/gitlabdev/rubinius; git remote add local git@localhost:rubinius.git; git push local master; git push local --tags"`  
24 -end  
lib/tasks/dev_user.sh
@@ -1,7 +0,0 @@ @@ -1,7 +0,0 @@
1 -sudo adduser \  
2 - --gecos 'gitlab dev user' \  
3 - --disabled-password \  
4 - --home /home/gitlabdev \  
5 - gitlabdev  
6 -  
7 -sudo -i -u gitlabdev -H sh -c "ssh-keygen -t rsa"  
lib/tasks/gitlab/gitolite_rebuild.rake 0 → 100644
@@ -0,0 +1,25 @@ @@ -0,0 +1,25 @@
  1 +namespace :gitlab do
  2 + namespace :gitolite do
  3 + desc "GITLAB | Rebuild each project at gitolite config"
  4 + task :update_repos => :environment do
  5 + puts "Starting Projects"
  6 + Project.find_each(:batch_size => 100) do |project|
  7 + puts
  8 + puts "=== #{project.name}"
  9 + project.update_repository
  10 + puts
  11 + end
  12 + puts "Done with projects"
  13 + end
  14 +
  15 + desc "GITLAB | Rebuild each key at gitolite config"
  16 + task :update_keys => :environment do
  17 + puts "Starting Key"
  18 + Key.find_each(:batch_size => 100) do |key|
  19 + key.update_repository
  20 + print '.'
  21 + end
  22 + puts "Done with keys"
  23 + end
  24 + end
  25 +end
lib/tasks/gitlab/setup.rake 0 → 100644
@@ -0,0 +1,7 @@ @@ -0,0 +1,7 @@
  1 +namespace :gitlab do
  2 + namespace :app do
  3 + desc "GITLAB | Setup production application"
  4 + task :setup => ['db:setup', 'db:seed_fu']
  5 + end
  6 +end
  7 +
lib/tasks/gitlab/status.rake 0 → 100644
@@ -0,0 +1,62 @@ @@ -0,0 +1,62 @@
  1 +namespace :gitlab do
  2 + namespace :app do
  3 + desc "GITLAB | Check gitlab installation status"
  4 + task :status => :environment do
  5 + puts "Starting diagnostic"
  6 +
  7 + print "config/database.yml............"
  8 + if File.exists?(File.join Rails.root, "config", "database.yml")
  9 + puts "exists".green
  10 + else
  11 + puts "missing".red
  12 + return
  13 + end
  14 +
  15 + print "config/gitlab.yml............"
  16 + if File.exists?(File.join Rails.root, "config", "gitlab.yml")
  17 + puts "exists".green
  18 + else
  19 + puts "missing".red
  20 + return
  21 + end
  22 +
  23 + GIT_HOST = YAML.load_file("#{Rails.root}/config/gitlab.yml")["git_host"]
  24 + print "/home/git/repositories/............"
  25 + if File.exists?(GIT_HOST['base_path'])
  26 + puts "exists".green
  27 + else
  28 + puts "missing".red
  29 + return
  30 + end
  31 +
  32 + print "/home/git/repositories/ is writable?............"
  33 + if File.stat(GIT_HOST['base_path']).writable?
  34 + puts "YES".green
  35 + else
  36 + puts "NO".red
  37 + return
  38 + end
  39 +
  40 + begin
  41 + `git clone #{GIT_HOST["admin_uri"]} /tmp/gitolite_gitlab_test`
  42 + FileUtils.rm_rf("/tmp/gitolite_gitlab_test")
  43 + print "Can clone gitolite-admin?............"
  44 + puts "YES".green
  45 + rescue
  46 + print "Can clone gitolite-admin?............"
  47 + puts "NO".red
  48 + return
  49 + end
  50 +
  51 + print "UMASK for .gitolite.rc is 0007? ............"
  52 + unless open("#{GIT_HOST['base_path']}/../.gitolite.rc").grep(/REPO_UMASK = 0007/).empty?
  53 + puts "YES".green
  54 + else
  55 + puts "NO".red
  56 + return
  57 + end
  58 +
  59 + puts "\nFinished"
  60 + end
  61 + end
  62 +end
lib/tasks/gitlab/update_hooks.rake 0 → 100644
@@ -0,0 +1,19 @@ @@ -0,0 +1,19 @@
  1 +namespace :gitlab do
  2 + namespace :gitolite do
  3 + desc "GITLAB | Rewrite hooks for repos"
  4 + task :update_hooks => :environment do
  5 + puts "Starting Projects"
  6 + Project.find_each(:batch_size => 100) do |project|
  7 + begin
  8 + if project.commit
  9 + project.write_hooks
  10 + print ".".green
  11 + end
  12 + rescue Exception => e
  13 + print e.message.red
  14 + end
  15 + end
  16 + puts "\nDone with projects"
  17 + end
  18 + end
  19 +end
lib/tasks/gitlab_status.rake
@@ -1,58 +0,0 @@ @@ -1,58 +0,0 @@
1 -desc "Check gitlab installation status"  
2 -task :gitlab_status => :environment do  
3 - puts "Starting diagnostic"  
4 -  
5 - print "config/database.yml............"  
6 - if File.exists?(File.join Rails.root, "config", "database.yml")  
7 - puts "exists".green  
8 - else  
9 - puts "missing".red  
10 - return  
11 - end  
12 -  
13 - print "config/gitlab.yml............"  
14 - if File.exists?(File.join Rails.root, "config", "gitlab.yml")  
15 - puts "exists".green  
16 - else  
17 - puts "missing".red  
18 - return  
19 - end  
20 -  
21 - GIT_HOST = YAML.load_file("#{Rails.root}/config/gitlab.yml")["git_host"]  
22 - print "/home/git/repositories/............"  
23 - if File.exists?(GIT_HOST['base_path'])  
24 - puts "exists".green  
25 - else  
26 - puts "missing".red  
27 - return  
28 - end  
29 -  
30 - print "/home/git/repositories/ is writable?............"  
31 - if File.stat(GIT_HOST['base_path']).writable?  
32 - puts "YES".green  
33 - else  
34 - puts "NO".red  
35 - return  
36 - end  
37 -  
38 - begin  
39 - `git clone #{GIT_HOST["admin_uri"]} /tmp/gitolite_gitlab_test`  
40 - FileUtils.rm_rf("/tmp/gitolite_gitlab_test")  
41 - print "Can clone gitolite-admin?............"  
42 - puts "YES".green  
43 - rescue  
44 - print "Can clone gitolite-admin?............"  
45 - puts "NO".red  
46 - return  
47 - end  
48 -  
49 - print "UMASK for .gitolite.rc is 0007? ............"  
50 - unless open("#{GIT_HOST['base_path']}/../.gitolite.rc").grep(/REPO_UMASK = 0007/).empty?  
51 - puts "YES".green  
52 - else  
53 - puts "NO".red  
54 - return  
55 - end  
56 -  
57 - puts "\nFinished"  
58 -end  
lib/tasks/gitolite_rebuild.rake
@@ -1,18 +0,0 @@ @@ -1,18 +0,0 @@
1 -desc "Rebuild each project at gitolite config"  
2 -task :gitolite_rebuild => :environment do  
3 - puts "Starting Projects"  
4 - Project.find_each(:batch_size => 100) do |project|  
5 - puts  
6 - puts "=== #{project.name}"  
7 - project.update_repository  
8 - puts  
9 - end  
10 - puts "Done with projects"  
11 -  
12 - puts "Starting Key"  
13 - Key.find_each(:batch_size => 100) do |project|  
14 - project.update_repository  
15 - print '.'  
16 - end  
17 - puts "Done with keys"  
18 -end  
lib/tasks/update_hooks.rake
@@ -1,15 +0,0 @@ @@ -1,15 +0,0 @@
1 -desc "Rewrite hooks for repos"  
2 -task :update_hooks => :environment do  
3 - puts "Starting Projects"  
4 - Project.find_each(:batch_size => 100) do |project|  
5 - begin  
6 - if project.commit  
7 - project.write_hooks  
8 - print ".".green  
9 - end  
10 - rescue Exception => e  
11 - print e.message.red  
12 - end  
13 - end  
14 - puts "\nDone with projects"  
15 -end