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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
9b917b4a
Commit
9b917b4a
authored
Feb 13, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add "User created project Namespace / Project" event
parent
522efa43
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
10 deletions
+26
-10
app/models/event.rb
app/models/event.rb
+12
-0
app/models/members/project_member.rb
app/models/members/project_member.rb
+5
-3
app/services/event_create_service.rb
app/services/event_create_service.rb
+4
-0
app/services/projects/create_service.rb
app/services/projects/create_service.rb
+5
-7
No files found.
app/models/event.rb
View file @
9b917b4a
...
@@ -61,6 +61,8 @@ class Event < ActiveRecord::Base
...
@@ -61,6 +61,8 @@ class Event < ActiveRecord::Base
true
true
elsif
membership_changed?
elsif
membership_changed?
true
true
elsif
created_project?
true
else
else
(
issue?
||
merge_request?
||
note?
||
milestone?
)
&&
target
(
issue?
||
merge_request?
||
note?
||
milestone?
)
&&
target
end
end
...
@@ -114,6 +116,14 @@ class Event < ActiveRecord::Base
...
@@ -114,6 +116,14 @@ class Event < ActiveRecord::Base
joined?
||
left?
joined?
||
left?
end
end
def
created_project?
created?
&&
!
target
end
def
created_target?
created?
&&
target
end
def
milestone?
def
milestone?
target_type
==
"Milestone"
target_type
==
"Milestone"
end
end
...
@@ -165,6 +175,8 @@ class Event < ActiveRecord::Base
...
@@ -165,6 +175,8 @@ class Event < ActiveRecord::Base
'left'
'left'
elsif
commented?
elsif
commented?
"commented on"
"commented on"
elsif
created_project?
"created"
else
else
"opened"
"opened"
end
end
...
...
app/models/members/project_member.rb
View file @
9b917b4a
...
@@ -114,9 +114,11 @@ class ProjectMember < Member
...
@@ -114,9 +114,11 @@ class ProjectMember < Member
end
end
def
post_create_hook
def
post_create_hook
unless
owner?
event_service
.
join_project
(
self
.
project
,
self
.
user
)
event_service
.
join_project
(
self
.
project
,
self
.
user
)
notification_service
.
new_team_member
(
self
)
unless
owner?
notification_service
.
new_team_member
(
self
)
end
system_hook_service
.
execute_hooks_for
(
self
,
:create
)
system_hook_service
.
execute_hooks_for
(
self
,
:create
)
end
end
...
...
app/services/event_create_service.rb
View file @
9b917b4a
...
@@ -58,6 +58,10 @@ class EventCreateService
...
@@ -58,6 +58,10 @@ class EventCreateService
create_event
(
project
,
current_user
,
Event
::
LEFT
)
create_event
(
project
,
current_user
,
Event
::
LEFT
)
end
end
def
create_project
(
project
,
current_user
)
create_event
(
project
,
current_user
,
Event
::
CREATED
)
end
def
push_ref
(
project
,
current_user
,
ref
,
action
=
'add'
,
prefix
=
'refs/heads'
)
def
push_ref
(
project
,
current_user
,
ref
,
action
=
'add'
,
prefix
=
'refs/heads'
)
commit
=
project
.
repository
.
commit
(
ref
.
target
)
commit
=
project
.
repository
.
commit
(
ref
.
target
)
...
...
app/services/projects/create_service.rb
View file @
9b917b4a
...
@@ -52,13 +52,7 @@ module Projects
...
@@ -52,13 +52,7 @@ module Projects
end
end
end
end
if
@project
.
persisted?
after_create_actions
if
@project
.
persisted?
if
@project
.
wiki_enabled?
@project
.
create_wiki
end
after_create_actions
end
@project
@project
rescue
=>
ex
rescue
=>
ex
...
@@ -79,6 +73,10 @@ module Projects
...
@@ -79,6 +73,10 @@ module Projects
def
after_create_actions
def
after_create_actions
log_info
(
"
#{
@project
.
owner
.
name
}
created a new project
\"
#{
@project
.
name_with_namespace
}
\"
"
)
log_info
(
"
#{
@project
.
owner
.
name
}
created a new project
\"
#{
@project
.
name_with_namespace
}
\"
"
)
@project
.
create_wiki
if
@project
.
wiki_enabled?
event_service
.
create_project
(
@project
,
current_user
)
system_hook_service
.
execute_hooks_for
(
@project
,
:create
)
system_hook_service
.
execute_hooks_for
(
@project
,
:create
)
unless
@project
.
group
unless
@project
.
group
...
...
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