diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2012-11-13 22:11:56 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2012-11-13 22:11:56 +0200 |
commit | a85e11fa51497888684f247bc09450cbcc67a058 (patch) | |
tree | 28f51a973614557362495cf80b1d3a6fc40b6872 /db/fixtures | |
parent | f0a6fbaae3b8d06c43eef6879afbcbbfdca52f1d (diff) | |
download | gitlab-ce-a85e11fa51497888684f247bc09450cbcc67a058.tar.gz |
Improved seeds for development env
Diffstat (limited to 'db/fixtures')
-rw-r--r-- | db/fixtures/development/002_project.rb | 6 | ||||
-rw-r--r-- | db/fixtures/development/004_teams.rb | 6 | ||||
-rw-r--r-- | db/fixtures/development/006_wall.rb | 59 | ||||
-rw-r--r-- | db/fixtures/development/007_issues.rb | 37 | ||||
-rw-r--r-- | db/fixtures/development/008_merge_requests.rb | 41 | ||||
-rw-r--r-- | db/fixtures/development/009_source_code.rb | 27 |
6 files changed, 97 insertions, 79 deletions
diff --git a/db/fixtures/development/002_project.rb b/db/fixtures/development/002_project.rb index eea987ffcc2..eb68b5fe93a 100644 --- a/db/fixtures/development/002_project.rb +++ b/db/fixtures/development/002_project.rb @@ -1,5 +1,5 @@ Project.seed(:id, [ - { :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 } + { id: 1, name: "Underscore.js", path: "underscore", code: "underscore", owner_id: 1 }, + { id: 2, name: "Diaspora", path: "diaspora", code: "diaspora", owner_id: 1 }, + { id: 3, name: "Ruby on Rails", path: "rails", code: "rails", owner_id: 1 } ]) diff --git a/db/fixtures/development/004_teams.rb b/db/fixtures/development/004_teams.rb index 5af98b92c02..2752cb44e1d 100644 --- a/db/fixtures/development/004_teams.rb +++ b/db/fixtures/development/004_teams.rb @@ -1,3 +1,5 @@ +UsersProject.skip_callback(:save, :after, :update_repository) + UsersProject.seed(:id, [ { :id => 1, :project_id => 1, :user_id => 1, :project_access => UsersProject::MASTER }, { :id => 2, :project_id => 1, :user_id => 2, :project_access => UsersProject::REPORTER}, @@ -18,4 +20,8 @@ UsersProject.seed(:id, [ { :id => 16, :project_id => 3, :user_id => 5, :project_access => UsersProject::MASTER} ]) +UsersProject.set_callback(:save, :after, :update_repository) +puts "\nRebuild gitolite\n".yellow +Project.all.each(&:update_repository) +puts "OK".green diff --git a/db/fixtures/development/006_wall.rb b/db/fixtures/development/006_wall.rb index 7c0d25d1000..a9fb66dda6b 100644 --- a/db/fixtures/development/006_wall.rb +++ b/db/fixtures/development/006_wall.rb @@ -1,40 +1,19 @@ -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)} -]) - - - +Gitlab::Seeder.quiet do + (1..300).each do |i| + # Random Project + project_id = rand(2) + 1 + project = Project.find(project_id) + + # Random user + user = project.users.sample + user_id = user.id + + Note.seed(:id, [{ + id: i, + project_id: project_id, + author_id: user_id, + note: Faker::Lorem.sentence(6) + }]) + print('.') + end +end diff --git a/db/fixtures/development/007_issues.rb b/db/fixtures/development/007_issues.rb index d60af71e6a2..98e32fccc3d 100644 --- a/db/fixtures/development/007_issues.rb +++ b/db/fixtures/development/007_issues.rb @@ -1,20 +1,23 @@ -(1..300).each do |i| - # Random Project - project_id = rand(2) + 1 - project = Project.find(project_id) +Gitlab::Seeder.quiet do + (1..300).each do |i| + # Random Project + project_id = rand(2) + 1 + project = Project.find(project_id) - # Random user - user = project.users.sample - user_id = user.id - IssueObserver.current_user = user + # Random user + user = project.users.sample + user_id = user.id + IssueObserver.current_user = user - Issue.seed(:id, [{ - id: i, - project_id: project_id, - author_id: user_id, - assignee_id: user_id, - closed: [true, false].sample, - milestone: project.milestones.sample, - title: Faker::Lorem.sentence(6) - }]) + Issue.seed(:id, [{ + id: i, + project_id: project_id, + author_id: user_id, + assignee_id: user_id, + closed: [true, false].sample, + milestone: project.milestones.sample, + title: Faker::Lorem.sentence(6) + }]) + print('.') + end end diff --git a/db/fixtures/development/008_merge_requests.rb b/db/fixtures/development/008_merge_requests.rb index 8d20e628113..698c55ad95f 100644 --- a/db/fixtures/development/008_merge_requests.rb +++ b/db/fixtures/development/008_merge_requests.rb @@ -1,22 +1,25 @@ -(1..300).each do |i| - # Random Project - project_id = rand(2) + 1 - project = Project.find(project_id) +Gitlab::Seeder.quiet do + (1..300).each do |i| + # Random Project + project_id = rand(2) + 1 + project = Project.find(project_id) - # Random user - user = project.users.sample - user_id = user.id - MergeRequestObserver.current_user = user + # Random user + user = project.users.sample + user_id = user.id + MergeRequestObserver.current_user = user - MergeRequest.seed(:id, [{ - id: i, - source_branch: 'master', - target_branch: 'feature', - project_id: project_id, - author_id: user_id, - assignee_id: user_id, - closed: [true, false].sample, - milestone: project.milestones.sample, - title: Faker::Lorem.sentence(6) - }]) + MergeRequest.seed(:id, [{ + id: i, + source_branch: 'master', + target_branch: 'feature', + project_id: project_id, + author_id: user_id, + assignee_id: user_id, + closed: [true, false].sample, + milestone: project.milestones.sample, + title: Faker::Lorem.sentence(6) + }]) + print('.') + end end diff --git a/db/fixtures/development/009_source_code.rb b/db/fixtures/development/009_source_code.rb new file mode 100644 index 00000000000..489bd02ea32 --- /dev/null +++ b/db/fixtures/development/009_source_code.rb @@ -0,0 +1,27 @@ +root = Gitlab.config.git_base_path + +projects = [ + { path: 'underscore.git', git: 'https://github.com/documentcloud/underscore.git' }, + { path: 'diaspora.git', git: 'https://github.com/diaspora/diaspora.git' }, + { path: 'rails.git', git: 'https://github.com/rails/rails.git' }, +] + +projects.each do |project| + project_path = File.join(root, project[:path]) + + + next if File.exists?(project_path) + + cmds = [ + "cd #{root} && sudo -u git -H git clone --bare #{project[:git]}", + "sudo cp ./lib/hooks/post-receive #{project_path}/hooks/post-receive", + "sudo chown git:git #{project_path}/hooks/post-receive" + ] + + cmds.each do |cmd| + puts cmd.yellow + `#{cmd}` + end +end + +puts "OK".green |