Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
f3220aba
Commit
f3220aba
authored
Mar 16, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev-seeds' into 'master'
Improve developer seeds
parents
6e73b208
39f80884
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
96 additions
and
86 deletions
+96
-86
db/fixtures/development/01_admin.rb
db/fixtures/development/01_admin.rb
+2
-3
db/fixtures/development/04_project.rb
db/fixtures/development/04_project.rb
+53
-51
db/fixtures/development/05_users.rb
db/fixtures/development/05_users.rb
+1
-0
db/fixtures/development/06_teams.rb
db/fixtures/development/06_teams.rb
+0
-2
db/fixtures/development/09_issues.rb
db/fixtures/development/09_issues.rb
+1
-7
db/fixtures/development/10_merge_requests.rb
db/fixtures/development/10_merge_requests.rb
+1
-6
db/fixtures/development/11_keys.rb
db/fixtures/development/11_keys.rb
+0
-2
db/fixtures/development/12_snippets.rb
db/fixtures/development/12_snippets.rb
+0
-2
db/fixtures/development/13_comments.rb
db/fixtures/development/13_comments.rb
+16
-10
lib/gitlab/seeder.rb
lib/gitlab/seeder.rb
+19
-0
lib/tasks/dev.rake
lib/tasks/dev.rake
+3
-3
No files found.
db/fixtures/development/01_admin.rb
View file @
f3220aba
...
@@ -8,8 +8,7 @@ User.seed(:id, [
...
@@ -8,8 +8,7 @@ User.seed(:id, [
password_confirmation:
"5iveL!fe"
,
password_confirmation:
"5iveL!fe"
,
admin:
true
,
admin:
true
,
projects_limit:
100
,
projects_limit:
100
,
theme_id:
Gitlab
::
Theme
::
MARS
theme_id:
Gitlab
::
Theme
::
MARS
,
confirmed_at:
DateTime
.
now
}
}
])
])
User
.
find
(
1
).
confirm!
db/fixtures/development/04_project.rb
View file @
f3220aba
project_urls
=
[
Gitlab
::
Seeder
.
quiet
do
project_urls
=
[
'https://github.com/documentcloud/underscore.git'
,
'https://github.com/documentcloud/underscore.git'
,
'https://github.com/diaspora/diaspora.git'
,
'https://github.com/diaspora/diaspora.git'
,
'https://github.com/diaspora/diaspora-project-site.git'
,
'https://github.com/diaspora/diaspora-project-site.git'
,
...
@@ -15,9 +16,9 @@ project_urls = [
...
@@ -15,9 +16,9 @@ project_urls = [
'https://github.com/twitter/typeahead.js.git'
,
'https://github.com/twitter/typeahead.js.git'
,
'https://github.com/h5bp/html5-boilerplate.git'
,
'https://github.com/h5bp/html5-boilerplate.git'
,
'https://github.com/h5bp/mobile-boilerplate.git'
,
'https://github.com/h5bp/mobile-boilerplate.git'
,
]
]
project_urls
.
each_with_index
do
|
url
,
i
|
project_urls
.
each_with_index
do
|
url
,
i
|
group_path
,
project_path
=
url
.
split
(
'/'
)[
-
2
..-
1
]
group_path
,
project_path
=
url
.
split
(
'/'
)[
-
2
..-
1
]
group
=
Group
.
find_by
(
path:
group_path
)
group
=
Group
.
find_by
(
path:
group_path
)
...
@@ -50,4 +51,5 @@ project_urls.each_with_index do |url, i|
...
@@ -50,4 +51,5 @@ project_urls.each_with_index do |url, i|
puts
project
.
errors
.
full_messages
puts
project
.
errors
.
full_messages
print
'F'
print
'F'
end
end
end
end
end
db/fixtures/development/05_users.rb
View file @
f3220aba
...
@@ -6,6 +6,7 @@ Gitlab::Seeder.quiet do
...
@@ -6,6 +6,7 @@ Gitlab::Seeder.quiet do
username:
Faker
::
Internet
.
user_name
,
username:
Faker
::
Internet
.
user_name
,
name:
Faker
::
Name
.
name
,
name:
Faker
::
Name
.
name
,
email:
Faker
::
Internet
.
email
,
email:
Faker
::
Internet
.
email
,
confirmed_at:
DateTime
.
now
}])
}])
print
'.'
print
'.'
rescue
ActiveRecord
::
RecordNotSaved
rescue
ActiveRecord
::
RecordNotSaved
...
...
db/fixtures/development/06_teams.rb
View file @
f3220aba
ActiveRecord
::
Base
.
observers
.
disable
:all
Gitlab
::
Seeder
.
quiet
do
Gitlab
::
Seeder
.
quiet
do
Group
.
all
.
each
do
|
group
|
Group
.
all
.
each
do
|
group
|
User
.
all
.
sample
(
4
).
each
do
|
user
|
User
.
all
.
sample
(
4
).
each
do
|
user
|
...
...
db/fixtures/development/09_issues.rb
View file @
f3220aba
ActiveRecord
::
Base
.
observers
.
disable
:all
Gitlab
::
Seeder
.
quiet
do
Gitlab
::
Seeder
.
quiet
do
(
1
..
300
).
each
do
|
i
|
(
1
..
300
).
each
do
|
i
|
# Random Project
# Random Project
...
@@ -12,9 +10,7 @@ Gitlab::Seeder.quiet do
...
@@ -12,9 +10,7 @@ Gitlab::Seeder.quiet do
user_id
=
user
.
id
user_id
=
user
.
id
begin
Gitlab
::
Seeder
.
by_user
(
user
)
do
Thread
.
current
[
:current_user
]
=
user
Issue
.
seed
(
:id
,
[{
Issue
.
seed
(
:id
,
[{
id:
i
,
id:
i
,
project_id:
project
.
id
,
project_id:
project
.
id
,
...
@@ -25,8 +21,6 @@ Gitlab::Seeder.quiet do
...
@@ -25,8 +21,6 @@ Gitlab::Seeder.quiet do
title:
Faker
::
Lorem
.
sentence
(
6
),
title:
Faker
::
Lorem
.
sentence
(
6
),
description:
Faker
::
Lorem
.
sentence
description:
Faker
::
Lorem
.
sentence
}])
}])
ensure
Thread
.
current
[
:current_user
]
=
nil
end
end
print
(
'.'
)
print
(
'.'
)
end
end
...
...
db/fixtures/development/10_merge_requests.rb
View file @
f3220aba
ActiveRecord
::
Base
.
observers
.
disable
:all
Gitlab
::
Seeder
.
quiet
do
Gitlab
::
Seeder
.
quiet
do
(
1
..
100
).
each
do
|
i
|
(
1
..
100
).
each
do
|
i
|
# Random Project
# Random Project
...
@@ -17,9 +15,8 @@ Gitlab::Seeder.quiet do
...
@@ -17,9 +15,8 @@ Gitlab::Seeder.quiet do
next
if
branches
.
uniq
.
size
<
2
next
if
branches
.
uniq
.
size
<
2
user_id
=
user
.
id
user_id
=
user
.
id
begin
Thread
.
current
[
:current_user
]
=
user
Gitlab
::
Seeder
.
by_user
(
user
)
do
MergeRequest
.
seed
(
:id
,
[{
MergeRequest
.
seed
(
:id
,
[{
id:
i
,
id:
i
,
source_branch:
branches
.
first
,
source_branch:
branches
.
first
,
...
@@ -31,8 +28,6 @@ Gitlab::Seeder.quiet do
...
@@ -31,8 +28,6 @@ Gitlab::Seeder.quiet do
milestone:
project
.
milestones
.
sample
,
milestone:
project
.
milestones
.
sample
,
title:
Faker
::
Lorem
.
sentence
(
6
)
title:
Faker
::
Lorem
.
sentence
(
6
)
}])
}])
ensure
Thread
.
current
[
:current_user
]
=
nil
end
end
print
(
'.'
)
print
(
'.'
)
end
end
...
...
db/fixtures/development/11_keys.rb
View file @
f3220aba
ActiveRecord
::
Base
.
observers
.
enable
:all
Gitlab
::
Seeder
.
quiet
do
Gitlab
::
Seeder
.
quiet
do
User
.
first
(
30
).
each_with_index
do
|
user
,
i
|
User
.
first
(
30
).
each_with_index
do
|
user
,
i
|
Key
.
seed
(
:id
,
[
Key
.
seed
(
:id
,
[
...
...
db/fixtures/development/12_snippets.rb
View file @
f3220aba
ActiveRecord
::
Base
.
observers
.
disable
:all
Gitlab
::
Seeder
.
quiet
do
Gitlab
::
Seeder
.
quiet
do
contents
=
[
contents
=
[
`curl https://gist.github.com/randx/4275756/raw/da2f262920c96d1a970d48bf2e99147954b1f4bd/glus1204.sh`
,
`curl https://gist.github.com/randx/4275756/raw/da2f262920c96d1a970d48bf2e99147954b1f4bd/glus1204.sh`
,
...
...
db/fixtures/development/13_comments.rb
View file @
f3220aba
ActiveRecord
::
Base
.
observers
.
disable
:all
Gitlab
::
Seeder
.
quiet
do
Issue
.
all
.
limit
(
10
).
each_with_index
do
|
issue
,
i
|
Issue
.
all
.
limit
(
10
).
each_with_index
do
|
issue
,
i
|
5
.
times
do
5
.
times
do
user
=
issue
.
project
.
team
.
users
.
sample
Gitlab
::
Seeder
.
by_user
(
user
)
do
Note
.
seed
(
:id
,
[{
Note
.
seed
(
:id
,
[{
project_id:
issue
.
project
.
id
,
project_id:
issue
.
project
.
id
,
author_id:
issue
.
project
.
team
.
users
.
sample
.
id
,
author_id:
user
.
id
,
note:
Faker
::
Lorem
.
sentence
,
note:
Faker
::
Lorem
.
sentence
,
noteable_id:
issue
.
id
,
noteable_id:
issue
.
id
,
noteable_type:
'Issue'
noteable_type:
'Issue'
}])
}])
print
'.'
end
end
end
end
end
end
lib/gitlab/seeder.rb
View file @
f3220aba
module
Gitlab
module
Gitlab
class
Seeder
class
Seeder
def
self
.
quiet
def
self
.
quiet
mute_mailer
SeedFu
.
quiet
=
true
SeedFu
.
quiet
=
true
yield
yield
SeedFu
.
quiet
=
false
SeedFu
.
quiet
=
false
puts
"
\n
OK"
.
green
puts
"
\n
OK"
.
green
end
end
def
self
.
by_user
(
user
)
begin
Thread
.
current
[
:current_user
]
=
user
yield
ensure
Thread
.
current
[
:current_user
]
=
nil
end
end
def
self
.
mute_mailer
code
=
<<-
eos
def Notify.delay
self
end
eos
eval
(
code
)
end
end
end
end
end
lib/tasks/dev.rake
View file @
f3220aba
task
dev:
[
"dev:setup"
]
namespace
:dev
do
namespace
:dev
do
desc
"GITLAB | Setup developer environment (db, fixtures)"
desc
"GITLAB | Setup developer environment (db, fixtures)"
task
:setup
=>
:environment
do
task
:setup
=>
:environment
do
ENV
[
'force'
]
=
'yes'
ENV
[
'force'
]
=
'yes'
Rake
::
Task
[
"db:setup"
].
invoke
Rake
::
Task
[
"gitlab:setup"
].
invoke
Rake
::
Task
[
"db:seed_fu"
].
invoke
Rake
::
Task
[
"gitlab:shell:setup"
].
invoke
Rake
::
Task
[
"gitlab:shell:setup"
].
invoke
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment