dev seeds & dev scripts

This commit is contained in:
Dmitriy Zaporozhets 2011-12-15 23:04:59 +02:00
parent f94d51d765
commit d9cfb7985e
5 changed files with 75 additions and 4 deletions

View file

@ -1,5 +1,5 @@
Project.seed(:id, [
{ :id => 1, :name => "Gitlab HQ", :path => "gitlabhq", :code => "gitlabhq", :owner_id => 1 },
{ :id => 1, :name => "Rubinius", :path => "rubinius", :code => "rubinius", :owner_id => 1 },
{ :id => 2, :name => "Diaspora", :path => "diaspora", :code => "diaspora", :owner_id => 1 },
{ :id => 3, :name => "Ruby on Rails", :path => "ruby_on_rails", :code => "ruby_on_rails", :owner_id => 1 }
])

View file

@ -1,17 +1,17 @@
UsersProject.seed(:id, [
{ :id => 1, :project_id => 1, :user_id => 1, :project_access => Project::PROJECT_RWA, :repo_access => Repository::REPO_N },
{ :id => 1, :project_id => 1, :user_id => 1, :project_access => Project::PROJECT_RWA, :repo_access => Repository::REPO_RW },
{ :id => 2, :project_id => 1, :user_id => 2, :project_access => Project::PROJECT_RW, :repo_access => Repository::REPO_N },
{ :id => 3, :project_id => 1, :user_id => 3, :project_access => Project::PROJECT_RW, :repo_access => Repository::REPO_N },
{ :id => 4, :project_id => 1, :user_id => 4, :project_access => Project::PROJECT_R, :repo_access => Repository::REPO_N },
{ :id => 5, :project_id => 1, :user_id => 5, :project_access => Project::PROJECT_R, :repo_access => Repository::REPO_N },
{ :id => 6, :project_id => 2, :user_id => 1, :project_access => Project::PROJECT_RWA, :repo_access => Repository::REPO_N },
{ :id => 6, :project_id => 2, :user_id => 1, :project_access => Project::PROJECT_RWA, :repo_access => Repository::REPO_RW },
{ :id => 7, :project_id => 2, :user_id => 2, :project_access => Project::PROJECT_R, :repo_access => Repository::REPO_N },
{ :id => 8, :project_id => 2, :user_id => 3, :project_access => Project::PROJECT_R, :repo_access => Repository::REPO_N },
{ :id => 9, :project_id => 2, :user_id => 4, :project_access => Project::PROJECT_RWA, :repo_access => Repository::REPO_N },
{ :id => 11, :project_id => 2, :user_id => 5, :project_access => Project::PROJECT_RWA, :repo_access => Repository::REPO_N },
{ :id => 12, :project_id => 3, :user_id => 1, :project_access => Project::PROJECT_RWA, :repo_access => Repository::REPO_N },
{ :id => 12, :project_id => 3, :user_id => 1, :project_access => Project::PROJECT_RWA, :repo_access => Repository::REPO_RW },
{ :id => 13, :project_id => 3, :user_id => 2, :project_access => Project::PROJECT_R, :repo_access => Repository::REPO_N },
{ :id => 14, :project_id => 3, :user_id => 3, :project_access => Project::PROJECT_RWA, :repo_access => Repository::REPO_N },
{ :id => 15, :project_id => 3, :user_id => 4, :project_access => Project::PROJECT_R, :repo_access => Repository::REPO_N },

View file

@ -0,0 +1,40 @@
Note.seed(:id, [
{ :id => 1, :project_id => 1, :author_id => 1, :note => Faker::Lorem.sentence(6) },
{ :id => 2, :project_id => 1, :author_id => 2, :note => Faker::Lorem.sentence(6) },
{ :id => 3, :project_id => 1, :author_id => 3, :note => Faker::Lorem.sentence(6) },
{ :id => 4, :project_id => 1, :author_id => 4, :note => Faker::Lorem.sentence(6) },
{ :id => 5, :project_id => 1, :author_id => 5, :note => Faker::Lorem.sentence(6) },
{ :id => 6, :project_id => 2, :author_id => 1, :note => Faker::Lorem.sentence(6) },
{ :id => 7, :project_id => 2, :author_id => 2, :note => Faker::Lorem.sentence(6) },
{ :id => 8, :project_id => 2, :author_id => 3, :note => Faker::Lorem.sentence(6) },
{ :id => 9, :project_id => 2, :author_id => 4, :note => Faker::Lorem.sentence(6) },
{ :id => 11, :project_id => 2, :author_id => 5, :note => Faker::Lorem.sentence(6) },
{ :id => 12, :project_id => 3, :author_id => 1, :note => Faker::Lorem.sentence(6)},
{ :id => 13, :project_id => 3, :author_id => 2, :note => Faker::Lorem.sentence(6)},
{ :id => 14, :project_id => 3, :author_id => 3, :note => Faker::Lorem.sentence(6)},
{ :id => 15, :project_id => 3, :author_id => 4, :note => Faker::Lorem.sentence(6)},
{ :id => 16, :project_id => 3, :author_id => 5, :note => Faker::Lorem.sentence(6)},
{ :id => 21, :project_id => 1, :author_id => 1, :note => Faker::Lorem.sentence(6) },
{ :id => 22, :project_id => 1, :author_id => 2, :note => Faker::Lorem.sentence(6) },
{ :id => 23, :project_id => 1, :author_id => 3, :note => Faker::Lorem.sentence(6) },
{ :id => 24, :project_id => 1, :author_id => 4, :note => Faker::Lorem.sentence(6) },
{ :id => 25, :project_id => 1, :author_id => 5, :note => Faker::Lorem.sentence(6) },
{ :id => 26, :project_id => 2, :author_id => 1, :note => Faker::Lorem.sentence(6) },
{ :id => 27, :project_id => 2, :author_id => 2, :note => Faker::Lorem.sentence(6) },
{ :id => 28, :project_id => 2, :author_id => 3, :note => Faker::Lorem.sentence(6) },
{ :id => 29, :project_id => 2, :author_id => 4, :note => Faker::Lorem.sentence(6) },
{ :id => 30, :project_id => 2, :author_id => 5, :note => Faker::Lorem.sentence(6) },
{ :id => 32, :project_id => 3, :author_id => 1, :note => Faker::Lorem.sentence(6)},
{ :id => 33, :project_id => 3, :author_id => 2, :note => Faker::Lorem.sentence(6)},
{ :id => 34, :project_id => 3, :author_id => 3, :note => Faker::Lorem.sentence(6)},
{ :id => 35, :project_id => 3, :author_id => 4, :note => Faker::Lorem.sentence(6)},
{ :id => 36, :project_id => 3, :author_id => 5, :note => Faker::Lorem.sentence(6)}
])

24
lib/tasks/dev_repo.rake Normal file
View file

@ -0,0 +1,24 @@
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 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 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 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

7
lib/tasks/dev_user.sh Executable file
View file

@ -0,0 +1,7 @@
sudo adduser \
--gecos 'gitlab dev user' \
--disabled-password \
--home /home/gitlabdev \
gitlabdev
sudo -i -u gitlabdev -H sh -c "ssh-keygen -t rsa"