Commit 38985390b061a0d1d0d91d5574f612b4710768b6
1 parent
152f8786
Exists in
master
and in
4 other branches
Refactored and fixed seeds to work with gitlab-shell
Showing
21 changed files
with
201 additions
and
211 deletions
Show diff stats
db/fixtures/development/001_admin.rb
db/fixtures/development/002_project.rb
@@ -1,26 +0,0 @@ | @@ -1,26 +0,0 @@ | ||
1 | -Group.seed(:id, [ | ||
2 | - { id: 99, name: "GitLab", path: 'gitlab', owner_id: 1 }, | ||
3 | - { id: 100, name: "Brightbox", path: 'brightbox', owner_id: 1 }, | ||
4 | - { id: 101, name: "KDE", path: 'kde', owner_id: 1 }, | ||
5 | -]) | ||
6 | - | ||
7 | -Project.seed(:id, [ | ||
8 | - | ||
9 | - # Global | ||
10 | - { id: 1, name: "Underscore.js", path: "underscore", creator_id: 1 }, | ||
11 | - { id: 2, name: "Diaspora", path: "diaspora", creator_id: 1 }, | ||
12 | - | ||
13 | - # Brightbox | ||
14 | - { id: 3, namespace_id: 100, name: "Brightbox CLI", path: "brightbox-cli", creator_id: 1 }, | ||
15 | - { id: 4, namespace_id: 100, name: "Puppet", path: "puppet", creator_id: 1 }, | ||
16 | - | ||
17 | - # KDE | ||
18 | - { id: 5, namespace_id: 101, name: "kdebase", path: "kdebase", creator_id: 1}, | ||
19 | - { id: 6, namespace_id: 101, name: "kdelibs", path: "kdelibs", creator_id: 1}, | ||
20 | - { id: 7, namespace_id: 101, name: "amarok", path: "amarok", creator_id: 1}, | ||
21 | - | ||
22 | - # GitLab | ||
23 | - { id: 8, namespace_id: 99, name: "gitlabhq", path: "gitlabhq", creator_id: 1}, | ||
24 | - { id: 9, namespace_id: 99, name: "gitlab-ci", path: "gitlab-ci", creator_id: 1}, | ||
25 | - { id: 10, namespace_id: 99, name: "gitlab-recipes", path: "gitlab-recipes", creator_id: 1}, | ||
26 | -]) |
db/fixtures/development/003_users.rb
@@ -1,15 +0,0 @@ | @@ -1,15 +0,0 @@ | ||
1 | -Gitlab::Seeder.quiet do | ||
2 | - (2..300).each do |i| | ||
3 | - begin | ||
4 | - User.seed(:id, [{ | ||
5 | - id: i, | ||
6 | - username: Faker::Internet.user_name, | ||
7 | - name: Faker::Name.name, | ||
8 | - email: Faker::Internet.email, | ||
9 | - }]) | ||
10 | - print '.' | ||
11 | - rescue ActiveRecord::RecordNotSaved | ||
12 | - print 'F' | ||
13 | - end | ||
14 | - end | ||
15 | -end |
db/fixtures/development/004_teams.rb
@@ -1,29 +0,0 @@ | @@ -1,29 +0,0 @@ | ||
1 | -UsersProject.skip_callback(:save, :after, :update_repository) | ||
2 | - | ||
3 | -Gitlab::Seeder.quiet do | ||
4 | - | ||
5 | - (1..300).each do |i| | ||
6 | - # Random Project | ||
7 | - project = Project.scoped.sample | ||
8 | - | ||
9 | - # Random user | ||
10 | - user = User.not_in_project(project).sample | ||
11 | - | ||
12 | - next unless user | ||
13 | - | ||
14 | - UsersProject.seed(:id, [{ | ||
15 | - id: i, | ||
16 | - project_id: project.id, | ||
17 | - user_id: user.id, | ||
18 | - project_access: UsersProject.access_roles.values.sample | ||
19 | - }]) | ||
20 | - | ||
21 | - print('.') | ||
22 | - end | ||
23 | -end | ||
24 | - | ||
25 | -UsersProject.set_callback(:save, :after, :update_repository) | ||
26 | - | ||
27 | -puts "\nRebuild gitolite\n".yellow | ||
28 | -Project.all.each(&:update_repository) | ||
29 | -puts "OK".green |
db/fixtures/development/005_milestones.rb
@@ -1,13 +0,0 @@ | @@ -1,13 +0,0 @@ | ||
1 | -Milestone.seed(:id, [ | ||
2 | - { :id => 1, :project_id => 1, :title => 'v' + Faker::Address.zip_code }, | ||
3 | - { :id => 2, :project_id => 1, :title => 'v' + Faker::Address.zip_code }, | ||
4 | - { :id => 3, :project_id => 1, :title => 'v' + Faker::Address.zip_code }, | ||
5 | - { :id => 4, :project_id => 2, :title => 'v' + Faker::Address.zip_code }, | ||
6 | - { :id => 5, :project_id => 2, :title => 'v' + Faker::Address.zip_code }, | ||
7 | - | ||
8 | - { :id => 6, :project_id => 2, :title => 'v' + Faker::Address.zip_code }, | ||
9 | - { :id => 7, :project_id => 2, :title => 'v' + Faker::Address.zip_code }, | ||
10 | - { :id => 8, :project_id => 3, :title => 'v' + Faker::Address.zip_code }, | ||
11 | - { :id => 9, :project_id => 3, :title => 'v' + Faker::Address.zip_code }, | ||
12 | - { :id => 11, :project_id => 3, :title => 'v' + Faker::Address.zip_code }, | ||
13 | -]) |
db/fixtures/development/006_wall.rb
@@ -1,21 +0,0 @@ | @@ -1,21 +0,0 @@ | ||
1 | -Gitlab::Seeder.quiet do | ||
2 | - (1..300).each do |i| | ||
3 | - # Random Project | ||
4 | - project = Project.all.sample | ||
5 | - | ||
6 | - # Random user | ||
7 | - user = project.users.sample | ||
8 | - | ||
9 | - next unless user | ||
10 | - | ||
11 | - user_id = user.id | ||
12 | - | ||
13 | - Note.seed(:id, [{ | ||
14 | - id: i, | ||
15 | - project_id: project.id, | ||
16 | - author_id: user_id, | ||
17 | - note: Faker::Lorem.sentence(6) | ||
18 | - }]) | ||
19 | - print('.') | ||
20 | - end | ||
21 | -end |
db/fixtures/development/007_issues.rb
@@ -1,25 +0,0 @@ | @@ -1,25 +0,0 @@ | ||
1 | -Gitlab::Seeder.quiet do | ||
2 | - (1..300).each do |i| | ||
3 | - # Random Project | ||
4 | - project = Project.all.sample | ||
5 | - | ||
6 | - # Random user | ||
7 | - user = project.users.sample | ||
8 | - | ||
9 | - next unless user | ||
10 | - | ||
11 | - user_id = user.id | ||
12 | - IssueObserver.current_user = user | ||
13 | - | ||
14 | - Issue.seed(:id, [{ | ||
15 | - id: i, | ||
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 | ||
25 | -end |
db/fixtures/development/008_merge_requests.rb
@@ -1,26 +0,0 @@ | @@ -1,26 +0,0 @@ | ||
1 | -Gitlab::Seeder.quiet do | ||
2 | - (1..300).each do |i| | ||
3 | - # Random Project | ||
4 | - project = Project.all.sample | ||
5 | - | ||
6 | - # Random user | ||
7 | - user = project.users.sample | ||
8 | - | ||
9 | - next unless user | ||
10 | - | ||
11 | - user_id = user.id | ||
12 | - MergeRequestObserver.current_user = user | ||
13 | - MergeRequest.seed(:id, [{ | ||
14 | - id: i, | ||
15 | - source_branch: 'master', | ||
16 | - target_branch: 'feature', | ||
17 | - project_id: project.id, | ||
18 | - author_id: user_id, | ||
19 | - assignee_id: user_id, | ||
20 | - closed: [true, false].sample, | ||
21 | - milestone: project.milestones.sample, | ||
22 | - title: Faker::Lorem.sentence(6) | ||
23 | - }]) | ||
24 | - print('.') | ||
25 | - end | ||
26 | -end |
db/fixtures/development/009_source_code.rb
@@ -1,31 +0,0 @@ | @@ -1,31 +0,0 @@ | ||
1 | -root = Gitlab.config.gitolite.repos_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: 'brightbox/brightbox-cli.git', git: 'https://github.com/brightbox/brightbox-cli.git' }, | ||
7 | - { path: 'brightbox/puppet.git', git: 'https://github.com/brightbox/puppet.git' }, | ||
8 | - { path: 'gitlab/gitlabhq.git', git: 'https://github.com/gitlabhq/gitlabhq.git' }, | ||
9 | - { path: 'gitlab/gitlab-ci.git', git: 'https://github.com/gitlabhq/gitlab-ci.git' }, | ||
10 | - { path: 'gitlab/gitlab-recipes.git', git: 'https://github.com/gitlabhq/gitlab-recipes.git' }, | ||
11 | -] | ||
12 | - | ||
13 | -projects.each do |project| | ||
14 | - project_path = File.join(root, project[:path]) | ||
15 | - | ||
16 | - next if File.exists?(project_path) | ||
17 | - | ||
18 | - cmds = [ | ||
19 | - "cd #{root} && sudo -u git -H git clone --bare #{project[:git]} ./#{project[:path]}", | ||
20 | - "sudo ln -s ./lib/hooks/post-receive #{project_path}/hooks/post-receive", | ||
21 | - "sudo chown git:git -R #{project_path}", | ||
22 | - "sudo chmod 770 -R #{project_path}", | ||
23 | - ] | ||
24 | - | ||
25 | - cmds.each do |cmd| | ||
26 | - puts cmd.yellow | ||
27 | - `#{cmd}` | ||
28 | - end | ||
29 | -end | ||
30 | - | ||
31 | -puts "OK".green |
db/fixtures/development/010_keys.rb
@@ -1,14 +0,0 @@ | @@ -1,14 +0,0 @@ | ||
1 | - | ||
2 | -Gitlab::Seeder.quiet do | ||
3 | - User.first(30).each_with_index do |user, i| | ||
4 | - Key.seed(:id, [ | ||
5 | - { | ||
6 | - id: i, | ||
7 | - title: "Sample key #{i}", | ||
8 | - key: "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt#{i + 100}6k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=", | ||
9 | - user_id: user.id, | ||
10 | - } | ||
11 | - ]) | ||
12 | - puts "SSH KEY ##{i} added.".green | ||
13 | - end | ||
14 | -end |
@@ -0,0 +1,29 @@ | @@ -0,0 +1,29 @@ | ||
1 | +root = Gitlab.config.gitolite.repos_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: 'brightbox/brightbox-cli.git', git: 'https://github.com/brightbox/brightbox-cli.git' }, | ||
7 | + { path: 'brightbox/puppet.git', git: 'https://github.com/brightbox/puppet.git' }, | ||
8 | + { path: 'gitlab/gitlabhq.git', git: 'https://github.com/gitlabhq/gitlabhq.git' }, | ||
9 | + { path: 'gitlab/gitlab-ci.git', git: 'https://github.com/gitlabhq/gitlab-ci.git' }, | ||
10 | + { path: 'gitlab/gitlab-recipes.git', git: 'https://github.com/gitlabhq/gitlab-recipes.git' }, | ||
11 | +] | ||
12 | + | ||
13 | +projects.each do |project| | ||
14 | + project_path = File.join(root, project[:path]) | ||
15 | + | ||
16 | + if File.exists?(project_path) | ||
17 | + print '-' | ||
18 | + next | ||
19 | + end | ||
20 | + | ||
21 | + if system("/home/git/gitlab-shell/bin/gitlab-projects import-project #{project[:path]} #{project[:git]}") | ||
22 | + print '.' | ||
23 | + else | ||
24 | + print 'F' | ||
25 | + end | ||
26 | +end | ||
27 | + | ||
28 | +puts "OK".green | ||
29 | + |
@@ -0,0 +1,20 @@ | @@ -0,0 +1,20 @@ | ||
1 | +Project.seed(:id, [ | ||
2 | + | ||
3 | + # Global | ||
4 | + { id: 1, name: "Underscore.js", path: "underscore", creator_id: 1 }, | ||
5 | + { id: 2, name: "Diaspora", path: "diaspora", creator_id: 1 }, | ||
6 | + | ||
7 | + # Brightbox | ||
8 | + { id: 3, namespace_id: 100, name: "Brightbox CLI", path: "brightbox-cli", creator_id: 1 }, | ||
9 | + { id: 4, namespace_id: 100, name: "Puppet", path: "puppet", creator_id: 1 }, | ||
10 | + | ||
11 | + # KDE | ||
12 | + { id: 5, namespace_id: 101, name: "kdebase", path: "kdebase", creator_id: 1}, | ||
13 | + { id: 6, namespace_id: 101, name: "kdelibs", path: "kdelibs", creator_id: 1}, | ||
14 | + { id: 7, namespace_id: 101, name: "amarok", path: "amarok", creator_id: 1}, | ||
15 | + | ||
16 | + # GitLab | ||
17 | + { id: 8, namespace_id: 99, name: "gitlabhq", path: "gitlabhq", creator_id: 1}, | ||
18 | + { id: 9, namespace_id: 99, name: "gitlab-ci", path: "gitlab-ci", creator_id: 1}, | ||
19 | + { id: 10, namespace_id: 99, name: "gitlab-recipes", path: "gitlab-recipes", creator_id: 1}, | ||
20 | +]) |
@@ -0,0 +1,15 @@ | @@ -0,0 +1,15 @@ | ||
1 | +Gitlab::Seeder.quiet do | ||
2 | + (2..300).each do |i| | ||
3 | + begin | ||
4 | + User.seed(:id, [{ | ||
5 | + id: i, | ||
6 | + username: Faker::Internet.user_name, | ||
7 | + name: Faker::Name.name, | ||
8 | + email: Faker::Internet.email, | ||
9 | + }]) | ||
10 | + print '.' | ||
11 | + rescue ActiveRecord::RecordNotSaved | ||
12 | + print 'F' | ||
13 | + end | ||
14 | + end | ||
15 | +end |
@@ -0,0 +1,22 @@ | @@ -0,0 +1,22 @@ | ||
1 | +Gitlab::Seeder.quiet do | ||
2 | + | ||
3 | + (1..300).each do |i| | ||
4 | + # Random Project | ||
5 | + project = Project.scoped.sample | ||
6 | + | ||
7 | + # Random user | ||
8 | + user = User.not_in_project(project).sample | ||
9 | + | ||
10 | + next unless user | ||
11 | + | ||
12 | + UsersProject.seed(:id, [{ | ||
13 | + id: i, | ||
14 | + project_id: project.id, | ||
15 | + user_id: user.id, | ||
16 | + project_access: UsersProject.access_roles.values.sample | ||
17 | + }]) | ||
18 | + | ||
19 | + print('.') | ||
20 | + end | ||
21 | +end | ||
22 | +puts "OK".green |
@@ -0,0 +1,13 @@ | @@ -0,0 +1,13 @@ | ||
1 | +Milestone.seed(:id, [ | ||
2 | + { :id => 1, :project_id => 1, :title => 'v' + Faker::Address.zip_code }, | ||
3 | + { :id => 2, :project_id => 1, :title => 'v' + Faker::Address.zip_code }, | ||
4 | + { :id => 3, :project_id => 1, :title => 'v' + Faker::Address.zip_code }, | ||
5 | + { :id => 4, :project_id => 2, :title => 'v' + Faker::Address.zip_code }, | ||
6 | + { :id => 5, :project_id => 2, :title => 'v' + Faker::Address.zip_code }, | ||
7 | + | ||
8 | + { :id => 6, :project_id => 2, :title => 'v' + Faker::Address.zip_code }, | ||
9 | + { :id => 7, :project_id => 2, :title => 'v' + Faker::Address.zip_code }, | ||
10 | + { :id => 8, :project_id => 3, :title => 'v' + Faker::Address.zip_code }, | ||
11 | + { :id => 9, :project_id => 3, :title => 'v' + Faker::Address.zip_code }, | ||
12 | + { :id => 11, :project_id => 3, :title => 'v' + Faker::Address.zip_code }, | ||
13 | +]) |
@@ -0,0 +1,21 @@ | @@ -0,0 +1,21 @@ | ||
1 | +Gitlab::Seeder.quiet do | ||
2 | + (1..300).each do |i| | ||
3 | + # Random Project | ||
4 | + project = Project.all.sample | ||
5 | + | ||
6 | + # Random user | ||
7 | + user = project.users.sample | ||
8 | + | ||
9 | + next unless user | ||
10 | + | ||
11 | + user_id = user.id | ||
12 | + | ||
13 | + Note.seed(:id, [{ | ||
14 | + id: i, | ||
15 | + project_id: project.id, | ||
16 | + author_id: user_id, | ||
17 | + note: Faker::Lorem.sentence(6) | ||
18 | + }]) | ||
19 | + print('.') | ||
20 | + end | ||
21 | +end |
@@ -0,0 +1,25 @@ | @@ -0,0 +1,25 @@ | ||
1 | +Gitlab::Seeder.quiet do | ||
2 | + (1..300).each do |i| | ||
3 | + # Random Project | ||
4 | + project = Project.all.sample | ||
5 | + | ||
6 | + # Random user | ||
7 | + user = project.users.sample | ||
8 | + | ||
9 | + next unless user | ||
10 | + | ||
11 | + user_id = user.id | ||
12 | + IssueObserver.current_user = user | ||
13 | + | ||
14 | + Issue.seed(:id, [{ | ||
15 | + id: i, | ||
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 | ||
25 | +end |
@@ -0,0 +1,26 @@ | @@ -0,0 +1,26 @@ | ||
1 | +Gitlab::Seeder.quiet do | ||
2 | + (1..300).each do |i| | ||
3 | + # Random Project | ||
4 | + project = Project.all.sample | ||
5 | + | ||
6 | + # Random user | ||
7 | + user = project.users.sample | ||
8 | + | ||
9 | + next unless user | ||
10 | + | ||
11 | + user_id = user.id | ||
12 | + MergeRequestObserver.current_user = user | ||
13 | + MergeRequest.seed(:id, [{ | ||
14 | + id: i, | ||
15 | + source_branch: 'master', | ||
16 | + target_branch: 'feature', | ||
17 | + project_id: project.id, | ||
18 | + author_id: user_id, | ||
19 | + assignee_id: user_id, | ||
20 | + closed: [true, false].sample, | ||
21 | + milestone: project.milestones.sample, | ||
22 | + title: Faker::Lorem.sentence(6) | ||
23 | + }]) | ||
24 | + print('.') | ||
25 | + end | ||
26 | +end |
@@ -0,0 +1,14 @@ | @@ -0,0 +1,14 @@ | ||
1 | + | ||
2 | +Gitlab::Seeder.quiet do | ||
3 | + User.first(30).each_with_index do |user, i| | ||
4 | + Key.seed(:id, [ | ||
5 | + { | ||
6 | + id: i, | ||
7 | + title: "Sample key #{i}", | ||
8 | + key: "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt#{i + 100}6k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=", | ||
9 | + user_id: user.id, | ||
10 | + } | ||
11 | + ]) | ||
12 | + puts "SSH KEY ##{i} added.".green | ||
13 | + end | ||
14 | +end |