Commit a85e11fa51497888684f247bc09450cbcc67a058
1 parent
f0a6fbaa
Exists in
master
and in
4 other branches
Improved seeds for development env
Showing
7 changed files
with
107 additions
and
79 deletions
Show diff stats
db/fixtures/development/002_project.rb
1 | 1 | Project.seed(:id, [ |
2 | - { :id => 1, :name => "Rubinius", :path => "rubinius", :code => "rubinius", :owner_id => 1 }, | |
3 | - { :id => 2, :name => "Diaspora", :path => "diaspora", :code => "diaspora", :owner_id => 1 }, | |
4 | - { :id => 3, :name => "Ruby on Rails", :path => "ruby_on_rails", :code => "ruby_on_rails", :owner_id => 1 } | |
2 | + { id: 1, name: "Underscore.js", path: "underscore", code: "underscore", owner_id: 1 }, | |
3 | + { id: 2, name: "Diaspora", path: "diaspora", code: "diaspora", owner_id: 1 }, | |
4 | + { id: 3, name: "Ruby on Rails", path: "rails", code: "rails", owner_id: 1 } | |
5 | 5 | ]) | ... | ... |
db/fixtures/development/004_teams.rb
1 | +UsersProject.skip_callback(:save, :after, :update_repository) | |
2 | + | |
1 | 3 | UsersProject.seed(:id, [ |
2 | 4 | { :id => 1, :project_id => 1, :user_id => 1, :project_access => UsersProject::MASTER }, |
3 | 5 | { :id => 2, :project_id => 1, :user_id => 2, :project_access => UsersProject::REPORTER}, |
... | ... | @@ -18,4 +20,8 @@ UsersProject.seed(:id, [ |
18 | 20 | { :id => 16, :project_id => 3, :user_id => 5, :project_access => UsersProject::MASTER} |
19 | 21 | ]) |
20 | 22 | |
23 | +UsersProject.set_callback(:save, :after, :update_repository) | |
21 | 24 | |
25 | +puts "\nRebuild gitolite\n".yellow | |
26 | +Project.all.each(&:update_repository) | |
27 | +puts "OK".green | ... | ... |
db/fixtures/development/006_wall.rb
1 | -Note.seed(:id, [ | |
2 | - { :id => 1, :project_id => 1, :author_id => 1, :note => Faker::Lorem.sentence(6) }, | |
3 | - { :id => 2, :project_id => 1, :author_id => 2, :note => Faker::Lorem.sentence(6) }, | |
4 | - { :id => 3, :project_id => 1, :author_id => 3, :note => Faker::Lorem.sentence(6) }, | |
5 | - { :id => 4, :project_id => 1, :author_id => 4, :note => Faker::Lorem.sentence(6) }, | |
6 | - { :id => 5, :project_id => 1, :author_id => 5, :note => Faker::Lorem.sentence(6) }, | |
7 | - | |
8 | - { :id => 6, :project_id => 2, :author_id => 1, :note => Faker::Lorem.sentence(6) }, | |
9 | - { :id => 7, :project_id => 2, :author_id => 2, :note => Faker::Lorem.sentence(6) }, | |
10 | - { :id => 8, :project_id => 2, :author_id => 3, :note => Faker::Lorem.sentence(6) }, | |
11 | - { :id => 9, :project_id => 2, :author_id => 4, :note => Faker::Lorem.sentence(6) }, | |
12 | - { :id => 11, :project_id => 2, :author_id => 5, :note => Faker::Lorem.sentence(6) }, | |
13 | - | |
14 | - { :id => 12, :project_id => 3, :author_id => 1, :note => Faker::Lorem.sentence(6)}, | |
15 | - { :id => 13, :project_id => 3, :author_id => 2, :note => Faker::Lorem.sentence(6)}, | |
16 | - { :id => 14, :project_id => 3, :author_id => 3, :note => Faker::Lorem.sentence(6)}, | |
17 | - { :id => 15, :project_id => 3, :author_id => 4, :note => Faker::Lorem.sentence(6)}, | |
18 | - { :id => 16, :project_id => 3, :author_id => 5, :note => Faker::Lorem.sentence(6)}, | |
19 | - | |
20 | - { :id => 21, :project_id => 1, :author_id => 1, :note => Faker::Lorem.sentence(6) }, | |
21 | - { :id => 22, :project_id => 1, :author_id => 2, :note => Faker::Lorem.sentence(6) }, | |
22 | - { :id => 23, :project_id => 1, :author_id => 3, :note => Faker::Lorem.sentence(6) }, | |
23 | - { :id => 24, :project_id => 1, :author_id => 4, :note => Faker::Lorem.sentence(6) }, | |
24 | - { :id => 25, :project_id => 1, :author_id => 5, :note => Faker::Lorem.sentence(6) }, | |
25 | - | |
26 | - { :id => 26, :project_id => 2, :author_id => 1, :note => Faker::Lorem.sentence(6) }, | |
27 | - { :id => 27, :project_id => 2, :author_id => 2, :note => Faker::Lorem.sentence(6) }, | |
28 | - { :id => 28, :project_id => 2, :author_id => 3, :note => Faker::Lorem.sentence(6) }, | |
29 | - { :id => 29, :project_id => 2, :author_id => 4, :note => Faker::Lorem.sentence(6) }, | |
30 | - { :id => 30, :project_id => 2, :author_id => 5, :note => Faker::Lorem.sentence(6) }, | |
31 | - | |
32 | - { :id => 32, :project_id => 3, :author_id => 1, :note => Faker::Lorem.sentence(6)}, | |
33 | - { :id => 33, :project_id => 3, :author_id => 2, :note => Faker::Lorem.sentence(6)}, | |
34 | - { :id => 34, :project_id => 3, :author_id => 3, :note => Faker::Lorem.sentence(6)}, | |
35 | - { :id => 35, :project_id => 3, :author_id => 4, :note => Faker::Lorem.sentence(6)}, | |
36 | - { :id => 36, :project_id => 3, :author_id => 5, :note => Faker::Lorem.sentence(6)} | |
37 | -]) | |
38 | - | |
39 | - | |
40 | - | |
1 | +Gitlab::Seeder.quiet do | |
2 | + (1..300).each do |i| | |
3 | + # Random Project | |
4 | + project_id = rand(2) + 1 | |
5 | + project = Project.find(project_id) | |
6 | + | |
7 | + # Random user | |
8 | + user = project.users.sample | |
9 | + user_id = user.id | |
10 | + | |
11 | + Note.seed(:id, [{ | |
12 | + id: i, | |
13 | + project_id: project_id, | |
14 | + author_id: user_id, | |
15 | + note: Faker::Lorem.sentence(6) | |
16 | + }]) | |
17 | + print('.') | |
18 | + end | |
19 | +end | ... | ... |
db/fixtures/development/007_issues.rb
1 | -(1..300).each do |i| | |
2 | - # Random Project | |
3 | - project_id = rand(2) + 1 | |
4 | - project = Project.find(project_id) | |
1 | +Gitlab::Seeder.quiet do | |
2 | + (1..300).each do |i| | |
3 | + # Random Project | |
4 | + project_id = rand(2) + 1 | |
5 | + project = Project.find(project_id) | |
5 | 6 | |
6 | - # Random user | |
7 | - user = project.users.sample | |
8 | - user_id = user.id | |
9 | - IssueObserver.current_user = user | |
7 | + # Random user | |
8 | + user = project.users.sample | |
9 | + user_id = user.id | |
10 | + IssueObserver.current_user = user | |
10 | 11 | |
11 | - Issue.seed(:id, [{ | |
12 | - id: i, | |
13 | - project_id: project_id, | |
14 | - author_id: user_id, | |
15 | - assignee_id: user_id, | |
16 | - closed: [true, false].sample, | |
17 | - milestone: project.milestones.sample, | |
18 | - title: Faker::Lorem.sentence(6) | |
19 | - }]) | |
12 | + Issue.seed(:id, [{ | |
13 | + id: i, | |
14 | + project_id: project_id, | |
15 | + author_id: user_id, | |
16 | + assignee_id: user_id, | |
17 | + closed: [true, false].sample, | |
18 | + milestone: project.milestones.sample, | |
19 | + title: Faker::Lorem.sentence(6) | |
20 | + }]) | |
21 | + print('.') | |
22 | + end | |
20 | 23 | end | ... | ... |
db/fixtures/development/008_merge_requests.rb
1 | -(1..300).each do |i| | |
2 | - # Random Project | |
3 | - project_id = rand(2) + 1 | |
4 | - project = Project.find(project_id) | |
1 | +Gitlab::Seeder.quiet do | |
2 | + (1..300).each do |i| | |
3 | + # Random Project | |
4 | + project_id = rand(2) + 1 | |
5 | + project = Project.find(project_id) | |
5 | 6 | |
6 | - # Random user | |
7 | - user = project.users.sample | |
8 | - user_id = user.id | |
9 | - MergeRequestObserver.current_user = user | |
7 | + # Random user | |
8 | + user = project.users.sample | |
9 | + user_id = user.id | |
10 | + MergeRequestObserver.current_user = user | |
10 | 11 | |
11 | - MergeRequest.seed(:id, [{ | |
12 | - id: i, | |
13 | - source_branch: 'master', | |
14 | - target_branch: 'feature', | |
15 | - project_id: project_id, | |
16 | - author_id: user_id, | |
17 | - assignee_id: user_id, | |
18 | - closed: [true, false].sample, | |
19 | - milestone: project.milestones.sample, | |
20 | - title: Faker::Lorem.sentence(6) | |
21 | - }]) | |
12 | + MergeRequest.seed(:id, [{ | |
13 | + id: i, | |
14 | + source_branch: 'master', | |
15 | + target_branch: 'feature', | |
16 | + project_id: project_id, | |
17 | + author_id: user_id, | |
18 | + assignee_id: user_id, | |
19 | + closed: [true, false].sample, | |
20 | + milestone: project.milestones.sample, | |
21 | + title: Faker::Lorem.sentence(6) | |
22 | + }]) | |
23 | + print('.') | |
24 | + end | |
22 | 25 | end | ... | ... |
... | ... | @@ -0,0 +1,27 @@ |
1 | +root = Gitlab.config.git_base_path | |
2 | + | |
3 | +projects = [ | |
4 | + { path: 'underscore.git', git: 'https://github.com/documentcloud/underscore.git' }, | |
5 | + { path: 'diaspora.git', git: 'https://github.com/diaspora/diaspora.git' }, | |
6 | + { path: 'rails.git', git: 'https://github.com/rails/rails.git' }, | |
7 | +] | |
8 | + | |
9 | +projects.each do |project| | |
10 | + project_path = File.join(root, project[:path]) | |
11 | + | |
12 | + | |
13 | + next if File.exists?(project_path) | |
14 | + | |
15 | + cmds = [ | |
16 | + "cd #{root} && sudo -u git -H git clone --bare #{project[:git]}", | |
17 | + "sudo cp ./lib/hooks/post-receive #{project_path}/hooks/post-receive", | |
18 | + "sudo chown git:git #{project_path}/hooks/post-receive" | |
19 | + ] | |
20 | + | |
21 | + cmds.each do |cmd| | |
22 | + puts cmd.yellow | |
23 | + `#{cmd}` | |
24 | + end | |
25 | +end | |
26 | + | |
27 | +puts "OK".green | ... | ... |