diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2012-04-04 02:02:54 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2012-04-04 02:02:54 +0400 |
commit | 43f5df21a39e0b9b16738bbd9e4047507bbcc9ef (patch) | |
tree | 24c17c9e6341a46a3092fd65371fbdc310ee1d9c /lib | |
parent | c40c627a3ba4b282bf42e247dff5eb13aa6ca790 (diff) |
gitlab rake tasks refactored
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tasks/dev/repo.rake | 26 | ||||
-rwxr-xr-x | lib/tasks/dev/user.sh (renamed from lib/tasks/dev_user.sh) | 0 | ||||
-rw-r--r-- | lib/tasks/dev_repo.rake | 24 | ||||
-rw-r--r-- | lib/tasks/gitlab/gitolite_rebuild.rake | 25 | ||||
-rw-r--r-- | lib/tasks/gitlab/setup.rake | 7 | ||||
-rw-r--r-- | lib/tasks/gitlab/status.rake | 62 | ||||
-rw-r--r-- | lib/tasks/gitlab/update_hooks.rake | 19 | ||||
-rw-r--r-- | lib/tasks/gitlab_status.rake | 58 | ||||
-rw-r--r-- | lib/tasks/gitolite_rebuild.rake | 18 | ||||
-rw-r--r-- | lib/tasks/update_hooks.rake | 15 |
10 files changed, 139 insertions, 115 deletions
diff --git a/lib/tasks/dev/repo.rake b/lib/tasks/dev/repo.rake new file mode 100644 index 00000000000..7b389a5535b --- /dev/null +++ b/lib/tasks/dev/repo.rake @@ -0,0 +1,26 @@ +namespace :dev do + desc "Prepare for development (run dev_user.sh first)" + task :repos => :environment do + key = `sudo -u gitlabdev -H cat /home/gitlabdev/.ssh/id_rsa.pub` + raise "\n *** Run ./lib/tasks/dev/user.sh first *** \n" if key.empty? + Key.create(:user_id => User.first, :key => key, :title => "gitlabdev") + + puts "\n *** Clone diaspora from github" + `sudo -u gitlabdev -H sh -c "cd /home/gitlabdev; git clone git://github.com/diaspora/diaspora.git /home/gitlabdev/diaspora"` + + puts "\n *** Push diaspora source to gitlab" + `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"` + + puts "\n *** Clone rails from github" + `sudo -u gitlabdev -H sh -c "cd /home/gitlabdev; git clone git://github.com/rails/rails.git /home/gitlabdev/rails"` + + puts "\n *** Push rails source to gitlab" + `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"` + + puts "\n *** Clone rubinius from github" + `sudo -u gitlabdev -H sh -c "cd /home/gitlabdev; git clone git://github.com/rubinius/rubinius.git /home/gitlabdev/rubinius"` + + puts "\n *** Push rubinius source to gitlab" + `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"` + end +end diff --git a/lib/tasks/dev_user.sh b/lib/tasks/dev/user.sh index d6b20df2ef2..d6b20df2ef2 100755 --- a/lib/tasks/dev_user.sh +++ b/lib/tasks/dev/user.sh diff --git a/lib/tasks/dev_repo.rake b/lib/tasks/dev_repo.rake deleted file mode 100644 index 4ae06bb936e..00000000000 --- a/lib/tasks/dev_repo.rake +++ /dev/null @@ -1,24 +0,0 @@ -desc "Prepare for development" -task :dev_repo => :environment do -key = `sudo -u gitlabdev -H cat /home/gitlabdev/.ssh/id_rsa.pub` -raise "\n *** Run ./lib/tasks/dev_user.sh first *** \n" if key.empty? -Key.create(:user_id => User.first, :key => key, :title => "gitlabdev") - -puts "\n *** Clone diaspora from github" -`sudo -u gitlabdev -H sh -c "cd /home/gitlabdev; git clone git://github.com/diaspora/diaspora.git /home/gitlabdev/diaspora"` - -puts "\n *** Push diaspora source to gitlab" -`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"` - -puts "\n *** Clone rails from github" -`sudo -u gitlabdev -H sh -c "cd /home/gitlabdev; git clone git://github.com/rails/rails.git /home/gitlabdev/rails"` - -puts "\n *** Push rails source to gitlab" -`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"` - -puts "\n *** Clone rubinius from github" -`sudo -u gitlabdev -H sh -c "cd /home/gitlabdev; git clone git://github.com/rubinius/rubinius.git /home/gitlabdev/rubinius"` - -puts "\n *** Push rubinius source to gitlab" -`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"` -end diff --git a/lib/tasks/gitlab/gitolite_rebuild.rake b/lib/tasks/gitlab/gitolite_rebuild.rake new file mode 100644 index 00000000000..5ab176060fb --- /dev/null +++ b/lib/tasks/gitlab/gitolite_rebuild.rake @@ -0,0 +1,25 @@ +namespace :gitlab do + namespace :gitolite do + desc "GITLAB | Rebuild each project at gitolite config" + task :update_repos => :environment do + puts "Starting Projects" + Project.find_each(:batch_size => 100) do |project| + puts + puts "=== #{project.name}" + project.update_repository + puts + end + puts "Done with projects" + end + + desc "GITLAB | Rebuild each key at gitolite config" + task :update_keys => :environment do + puts "Starting Key" + Key.find_each(:batch_size => 100) do |key| + key.update_repository + print '.' + end + puts "Done with keys" + end + end +end diff --git a/lib/tasks/gitlab/setup.rake b/lib/tasks/gitlab/setup.rake new file mode 100644 index 00000000000..ca0f064baff --- /dev/null +++ b/lib/tasks/gitlab/setup.rake @@ -0,0 +1,7 @@ +namespace :gitlab do + namespace :app do + desc "GITLAB | Setup production application" + task :setup => ['db:setup', 'db:seed_fu'] + end +end + diff --git a/lib/tasks/gitlab/status.rake b/lib/tasks/gitlab/status.rake new file mode 100644 index 00000000000..0393e7f41d1 --- /dev/null +++ b/lib/tasks/gitlab/status.rake @@ -0,0 +1,62 @@ +namespace :gitlab do + namespace :app do + desc "GITLAB | Check gitlab installation status" + task :status => :environment do + puts "Starting diagnostic" + + print "config/database.yml............" + if File.exists?(File.join Rails.root, "config", "database.yml") + puts "exists".green + else + puts "missing".red + return + end + + print "config/gitlab.yml............" + if File.exists?(File.join Rails.root, "config", "gitlab.yml") + puts "exists".green + else + puts "missing".red + return + end + + GIT_HOST = YAML.load_file("#{Rails.root}/config/gitlab.yml")["git_host"] + print "/home/git/repositories/............" + if File.exists?(GIT_HOST['base_path']) + puts "exists".green + else + puts "missing".red + return + end + + print "/home/git/repositories/ is writable?............" + if File.stat(GIT_HOST['base_path']).writable? + puts "YES".green + else + puts "NO".red + return + end + + begin + `git clone #{GIT_HOST["admin_uri"]} /tmp/gitolite_gitlab_test` + FileUtils.rm_rf("/tmp/gitolite_gitlab_test") + print "Can clone gitolite-admin?............" + puts "YES".green + rescue + print "Can clone gitolite-admin?............" + puts "NO".red + return + end + + print "UMASK for .gitolite.rc is 0007? ............" + unless open("#{GIT_HOST['base_path']}/../.gitolite.rc").grep(/REPO_UMASK = 0007/).empty? + puts "YES".green + else + puts "NO".red + return + end + + puts "\nFinished" + end + end +end diff --git a/lib/tasks/gitlab/update_hooks.rake b/lib/tasks/gitlab/update_hooks.rake new file mode 100644 index 00000000000..44e1617e58f --- /dev/null +++ b/lib/tasks/gitlab/update_hooks.rake @@ -0,0 +1,19 @@ +namespace :gitlab do + namespace :gitolite do + desc "GITLAB | Rewrite hooks for repos" + task :update_hooks => :environment do + puts "Starting Projects" + Project.find_each(:batch_size => 100) do |project| + begin + if project.commit + project.write_hooks + print ".".green + end + rescue Exception => e + print e.message.red + end + end + puts "\nDone with projects" + end + end +end diff --git a/lib/tasks/gitlab_status.rake b/lib/tasks/gitlab_status.rake deleted file mode 100644 index db4d1d36e7a..00000000000 --- a/lib/tasks/gitlab_status.rake +++ /dev/null @@ -1,58 +0,0 @@ -desc "Check gitlab installation status" -task :gitlab_status => :environment do - puts "Starting diagnostic" - - print "config/database.yml............" - if File.exists?(File.join Rails.root, "config", "database.yml") - puts "exists".green - else - puts "missing".red - return - end - - print "config/gitlab.yml............" - if File.exists?(File.join Rails.root, "config", "gitlab.yml") - puts "exists".green - else - puts "missing".red - return - end - - GIT_HOST = YAML.load_file("#{Rails.root}/config/gitlab.yml")["git_host"] - print "/home/git/repositories/............" - if File.exists?(GIT_HOST['base_path']) - puts "exists".green - else - puts "missing".red - return - end - - print "/home/git/repositories/ is writable?............" - if File.stat(GIT_HOST['base_path']).writable? - puts "YES".green - else - puts "NO".red - return - end - - begin - `git clone #{GIT_HOST["admin_uri"]} /tmp/gitolite_gitlab_test` - FileUtils.rm_rf("/tmp/gitolite_gitlab_test") - print "Can clone gitolite-admin?............" - puts "YES".green - rescue - print "Can clone gitolite-admin?............" - puts "NO".red - return - end - - print "UMASK for .gitolite.rc is 0007? ............" - unless open("#{GIT_HOST['base_path']}/../.gitolite.rc").grep(/REPO_UMASK = 0007/).empty? - puts "YES".green - else - puts "NO".red - return - end - - puts "\nFinished" -end diff --git a/lib/tasks/gitolite_rebuild.rake b/lib/tasks/gitolite_rebuild.rake deleted file mode 100644 index 558d4660ba8..00000000000 --- a/lib/tasks/gitolite_rebuild.rake +++ /dev/null @@ -1,18 +0,0 @@ -desc "Rebuild each project at gitolite config" -task :gitolite_rebuild => :environment do - puts "Starting Projects" - Project.find_each(:batch_size => 100) do |project| - puts - puts "=== #{project.name}" - project.update_repository - puts - end - puts "Done with projects" - - puts "Starting Key" - Key.find_each(:batch_size => 100) do |project| - project.update_repository - print '.' - end - puts "Done with keys" -end diff --git a/lib/tasks/update_hooks.rake b/lib/tasks/update_hooks.rake deleted file mode 100644 index 8deaf9586e2..00000000000 --- a/lib/tasks/update_hooks.rake +++ /dev/null @@ -1,15 +0,0 @@ -desc "Rewrite hooks for repos" -task :update_hooks => :environment do - puts "Starting Projects" - Project.find_each(:batch_size => 100) do |project| - begin - if project.commit - project.write_hooks - print ".".green - end - rescue Exception => e - print e.message.red - end - end - puts "\nDone with projects" -end |