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
iv
gitlab-ce
Commits
2ad00f52
Commit
2ad00f52
authored
Feb 15, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'tweet-new-project'
Conflicts: db/schema.rb
parents
26d594f2
67afb5b1
Changes
27
Show whitespace changes
Inline
Side-by-side
Showing
27 changed files
with
236 additions
and
151 deletions
+236
-151
CHANGELOG
CHANGELOG
+1
-0
app/assets/stylesheets/sections/events.scss
app/assets/stylesheets/sections/events.scss
+4
-0
app/controllers/admin/application_settings_controller.rb
app/controllers/admin/application_settings_controller.rb
+1
-0
app/controllers/projects/tags_controller.rb
app/controllers/projects/tags_controller.rb
+1
-1
app/helpers/application_settings_helper.rb
app/helpers/application_settings_helper.rb
+4
-0
app/helpers/events_helper.rb
app/helpers/events_helper.rb
+32
-21
app/models/application_setting.rb
app/models/application_setting.rb
+2
-0
app/models/event.rb
app/models/event.rb
+53
-54
app/models/members/project_member.rb
app/models/members/project_member.rb
+10
-13
app/services/create_branch_service.rb
app/services/create_branch_service.rb
+1
-1
app/services/create_tag_service.rb
app/services/create_tag_service.rb
+1
-1
app/services/delete_branch_service.rb
app/services/delete_branch_service.rb
+1
-1
app/services/event_create_service.rb
app/services/event_create_service.rb
+56
-16
app/services/git_push_service.rb
app/services/git_push_service.rb
+1
-10
app/services/git_tag_push_service.rb
app/services/git_tag_push_service.rb
+1
-10
app/services/projects/create_service.rb
app/services/projects/create_service.rb
+5
-7
app/views/admin/application_settings/_form.html.haml
app/views/admin/application_settings/_form.html.haml
+5
-0
app/views/events/_event.html.haml
app/views/events/_event.html.haml
+4
-2
app/views/events/event/_common.html.haml
app/views/events/event/_common.html.haml
+6
-4
app/views/events/event/_created_project.html.haml
app/views/events/event/_created_project.html.haml
+27
-0
app/views/events/event/_note.html.haml
app/views/events/event/_note.html.haml
+5
-1
app/views/events/event/_push.html.haml
app/views/events/event/_push.html.haml
+1
-1
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+1
-0
db/migrate/20150213104043_add_twitter_sharing_enabled_to_application_settings.rb
...43_add_twitter_sharing_enabled_to_application_settings.rb
+5
-0
features/dashboard/dashboard.feature
features/dashboard/dashboard.feature
+2
-2
features/steps/dashboard/dashboard.rb
features/steps/dashboard/dashboard.rb
+4
-4
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+2
-2
No files found.
CHANGELOG
View file @
2ad00f52
...
@@ -53,6 +53,7 @@ v 7.8.0 (unreleased)
...
@@ -53,6 +53,7 @@ v 7.8.0 (unreleased)
- Show assignees in merge request index page (Kelvin Mutuma)
- Show assignees in merge request index page (Kelvin Mutuma)
- Link head panel titles to relevant root page.
- Link head panel titles to relevant root page.
- Allow users that signed up via OAuth to set their password in order to use Git over HTTP(S).
- Allow users that signed up via OAuth to set their password in order to use Git over HTTP(S).
- Show users button to share their newly created public or internal projects on twitter
v 7.7.2
v 7.7.2
- Update GitLab Shell to version 2.4.2 that fixes a bug when developers can push to protected branch
- Update GitLab Shell to version 2.4.2 that fixes a bug when developers can push to protected branch
...
...
app/assets/stylesheets/sections/events.scss
View file @
2ad00f52
...
@@ -64,6 +64,10 @@
...
@@ -64,6 +64,10 @@
.md
{
.md
{
font-size
:
13px
;
font-size
:
13px
;
iframe
.twitter-share-button
{
vertical-align
:
bottom
;
}
}
}
pre
{
pre
{
...
...
app/controllers/admin/application_settings_controller.rb
View file @
2ad00f52
...
@@ -26,6 +26,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
...
@@ -26,6 +26,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
:signup_enabled
,
:signup_enabled
,
:signin_enabled
,
:signin_enabled
,
:gravatar_enabled
,
:gravatar_enabled
,
:twitter_sharing_enabled
,
:sign_in_text
,
:sign_in_text
,
:home_page_url
:home_page_url
)
)
...
...
app/controllers/projects/tags_controller.rb
View file @
2ad00f52
...
@@ -27,7 +27,7 @@ class Projects::TagsController < Projects::ApplicationController
...
@@ -27,7 +27,7 @@ class Projects::TagsController < Projects::ApplicationController
tag
=
@repository
.
find_tag
(
params
[
:id
])
tag
=
@repository
.
find_tag
(
params
[
:id
])
if
tag
&&
@repository
.
rm_tag
(
tag
.
name
)
if
tag
&&
@repository
.
rm_tag
(
tag
.
name
)
Event
.
create_ref_event
(
@project
,
current_user
,
tag
,
'rm'
,
'refs/tags'
)
Event
CreateService
.
new
.
push_ref
(
@project
,
current_user
,
tag
,
'rm'
,
'refs/tags'
)
end
end
respond_to
do
|
format
|
respond_to
do
|
format
|
...
...
app/helpers/application_settings_helper.rb
View file @
2ad00f52
...
@@ -3,6 +3,10 @@ module ApplicationSettingsHelper
...
@@ -3,6 +3,10 @@ module ApplicationSettingsHelper
current_application_settings
.
gravatar_enabled?
current_application_settings
.
gravatar_enabled?
end
end
def
twitter_sharing_enabled?
current_application_settings
.
twitter_sharing_enabled?
end
def
signup_enabled?
def
signup_enabled?
current_application_settings
.
signup_enabled?
current_application_settings
.
signup_enabled?
end
end
...
...
app/helpers/events_helper.rb
View file @
2ad00f52
...
@@ -11,7 +11,11 @@ module EventsHelper
...
@@ -11,7 +11,11 @@ module EventsHelper
def
event_action_name
(
event
)
def
event_action_name
(
event
)
target
=
if
event
.
target_type
target
=
if
event
.
target_type
if
event
.
note?
event
.
note_target_type
else
event
.
target_type
.
titleize
.
downcase
event
.
target_type
.
titleize
.
downcase
end
else
else
'project'
'project'
end
end
...
@@ -42,21 +46,30 @@ module EventsHelper
...
@@ -42,21 +46,30 @@ module EventsHelper
end
end
def
event_feed_title
(
event
)
def
event_feed_title
(
event
)
if
event
.
issue?
words
=
[]
"
#{
event
.
author_name
}
#{
event
.
action_name
}
issue #
#{
event
.
target_iid
}
:
#{
event
.
issue_title
}
at
#{
event
.
project_name
}
"
words
<<
event
.
author_name
elsif
event
.
merge_request?
words
<<
event_action_name
(
event
)
"
#{
event
.
author_name
}
#{
event
.
action_name
}
MR #
#{
event
.
target_iid
}
:
#{
event
.
merge_request_title
}
at
#{
event
.
project_name
}
"
elsif
event
.
push?
if
event
.
push?
"
#{
event
.
author_name
}
#{
event
.
push_action_name
}
#{
event
.
ref_type
}
#{
event
.
ref_name
}
at
#{
event
.
project_name
}
"
words
<<
event
.
ref_type
elsif
event
.
membership_changed?
words
<<
event
.
ref_name
"
#{
event
.
author_name
}
#{
event
.
action_name
}
#{
event
.
project_name
}
"
words
<<
"at"
elsif
event
.
note?
&&
event
.
note_commit?
elsif
event
.
commented?
"
#{
event
.
author_name
}
commented on
#{
event
.
note_target_type
}
#{
event
.
note_short_commit_id
}
at
#{
event
.
project_name
}
"
if
event
.
note_commit?
elsif
event
.
note?
words
<<
event
.
note_short_commit_id
"
#{
event
.
author_name
}
commented on
#{
event
.
note_target_type
}
#
#{
truncate
event
.
note_target_iid
}
at
#{
event
.
project_name
}
"
else
else
""
words
<<
"#
#{
truncate
event
.
note_target_iid
}
"
end
words
<<
"at"
elsif
event
.
target
words
<<
"#
#{
event
.
target_iid
}
:"
words
<<
event
.
target
.
title
if
event
.
target
.
respond_to?
(
:title
)
words
<<
"at"
end
end
words
<<
event
.
project_name
words
.
join
(
" "
)
end
end
def
event_feed_url
(
event
)
def
event_feed_url
(
event
)
...
@@ -96,8 +109,6 @@ module EventsHelper
...
@@ -96,8 +109,6 @@ module EventsHelper
render
"events/event_push"
,
event:
event
render
"events/event_push"
,
event:
event
elsif
event
.
merge_request?
elsif
event
.
merge_request?
render
"events/event_merge_request"
,
merge_request:
event
.
merge_request
render
"events/event_merge_request"
,
merge_request:
event
.
merge_request
elsif
event
.
push?
render
"events/event_push"
,
event:
event
elsif
event
.
note?
elsif
event
.
note?
render
"events/event_note"
,
note:
event
.
note
render
"events/event_note"
,
note:
event
.
note
end
end
...
...
app/models/application_setting.rb
View file @
2ad00f52
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
# signup_enabled :boolean
# signup_enabled :boolean
# signin_enabled :boolean
# signin_enabled :boolean
# gravatar_enabled :boolean
# gravatar_enabled :boolean
# twitter_sharing_enabled :boolean
# sign_in_text :text
# sign_in_text :text
# created_at :datetime
# created_at :datetime
# updated_at :datetime
# updated_at :datetime
...
@@ -30,6 +31,7 @@ class ApplicationSetting < ActiveRecord::Base
...
@@ -30,6 +31,7 @@ class ApplicationSetting < ActiveRecord::Base
default_branch_protection:
Settings
.
gitlab
[
'default_branch_protection'
],
default_branch_protection:
Settings
.
gitlab
[
'default_branch_protection'
],
signup_enabled:
Settings
.
gitlab
[
'signup_enabled'
],
signup_enabled:
Settings
.
gitlab
[
'signup_enabled'
],
signin_enabled:
Settings
.
gitlab
[
'signin_enabled'
],
signin_enabled:
Settings
.
gitlab
[
'signin_enabled'
],
twitter_sharing_enabled:
Settings
.
gitlab
[
'twitter_sharing_enabled'
],
gravatar_enabled:
Settings
.
gravatar
[
'enabled'
],
gravatar_enabled:
Settings
.
gravatar
[
'enabled'
],
sign_in_text:
Settings
.
extra
[
'sign_in_text'
],
sign_in_text:
Settings
.
extra
[
'sign_in_text'
],
)
)
...
...
app/models/event.rb
View file @
2ad00f52
...
@@ -49,29 +49,6 @@ class Event < ActiveRecord::Base
...
@@ -49,29 +49,6 @@ class Event < ActiveRecord::Base
scope
:in_projects
,
->
(
project_ids
)
{
where
(
project_id:
project_ids
).
recent
}
scope
:in_projects
,
->
(
project_ids
)
{
where
(
project_id:
project_ids
).
recent
}
class
<<
self
class
<<
self
def
create_ref_event
(
project
,
user
,
ref
,
action
=
'add'
,
prefix
=
'refs/heads'
)
commit
=
project
.
repository
.
commit
(
ref
.
target
)
if
action
.
to_s
==
'add'
before
=
'00000000'
after
=
commit
.
id
else
before
=
commit
.
id
after
=
'00000000'
end
Event
.
create
(
project:
project
,
action:
Event
::
PUSHED
,
data:
{
ref:
"
#{
prefix
}
/
#{
ref
.
name
}
"
,
before:
before
,
after:
after
},
author_id:
user
.
id
)
end
def
reset_event_cache_for
(
target
)
def
reset_event_cache_for
(
target
)
Event
.
where
(
target_id:
target
.
id
,
target_type:
target
.
class
.
to_s
).
Event
.
where
(
target_id:
target
.
id
,
target_type:
target
.
class
.
to_s
).
order
(
'id DESC'
).
limit
(
100
).
order
(
'id DESC'
).
limit
(
100
).
...
@@ -84,6 +61,8 @@ class Event < ActiveRecord::Base
...
@@ -84,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
...
@@ -98,25 +77,51 @@ class Event < ActiveRecord::Base
...
@@ -98,25 +77,51 @@ class Event < ActiveRecord::Base
end
end
def
target_title
def
target_title
if
target
&&
target
.
respond_to?
(
:title
)
target
.
title
if
target
&&
target
.
respond_to?
(
:title
)
target
.
title
end
end
def
created?
action
==
CREATED
end
end
def
push?
def
push?
action
==
self
.
class
::
PUSHED
&&
valid_push?
action
==
PUSHED
&&
valid_push?
end
end
def
merged?
def
merged?
action
==
self
.
class
::
MERGED
action
==
MERGED
end
end
def
closed?
def
closed?
action
==
self
.
class
::
CLOSED
action
==
CLOSED
end
end
def
reopened?
def
reopened?
action
==
self
.
class
::
REOPENED
action
==
REOPENED
end
def
joined?
action
==
JOINED
end
def
left?
action
==
LEFT
end
def
commented?
action
==
COMMENTED
end
def
membership_changed?
joined?
||
left?
end
def
created_project?
created?
&&
!
target
end
def
created_target?
created?
&&
target
end
end
def
milestone?
def
milestone?
...
@@ -135,32 +140,32 @@ class Event < ActiveRecord::Base
...
@@ -135,32 +140,32 @@ class Event < ActiveRecord::Base
target_type
==
"MergeRequest"
target_type
==
"MergeRequest"
end
end
def
joined?
def
milestone
action
==
JOINED
target
if
milestone?
end
def
left?
action
==
LEFT
end
def
membership_changed?
joined?
||
left?
end
end
def
issue
def
issue
target
if
target_type
==
"Issue"
target
if
issue?
end
end
def
merge_request
def
merge_request
target
if
target_type
==
"MergeRequest"
target
if
merge_request?
end
end
def
note
def
note
target
if
target_type
==
"Note"
target
if
note?
end
end
def
action_name
def
action_name
if
closed?
if
push?
if
new_ref?
"pushed new"
elsif
rm_ref?
"deleted"
else
"pushed to"
end
elsif
closed?
"closed"
"closed"
elsif
merged?
elsif
merged?
"accepted"
"accepted"
...
@@ -168,6 +173,10 @@ class Event < ActiveRecord::Base
...
@@ -168,6 +173,10 @@ class Event < ActiveRecord::Base
'joined'
'joined'
elsif
left?
elsif
left?
'left'
'left'
elsif
commented?
"commented on"
elsif
created_project?
"created"
else
else
"opened"
"opened"
end
end
...
@@ -236,16 +245,6 @@ class Event < ActiveRecord::Base
...
@@ -236,16 +245,6 @@ class Event < ActiveRecord::Base
tag?
?
"tag"
:
"branch"
tag?
?
"tag"
:
"branch"
end
end
def
push_action_name
if
new_ref?
"pushed new"
elsif
rm_ref?
"deleted"
else
"pushed to"
end
end
def
push_with_commits?
def
push_with_commits?
md_ref?
&&
commits
.
any?
&&
commit_from
&&
commit_to
md_ref?
&&
commits
.
any?
&&
commit_from
&&
commit_to
end
end
...
...
app/models/members/project_member.rb
View file @
2ad00f52
...
@@ -114,13 +114,11 @@ class ProjectMember < Member
...
@@ -114,13 +114,11 @@ class ProjectMember < Member
end
end
def
post_create_hook
def
post_create_hook
Event
.
create
(
unless
owner?
project_id:
self
.
project
.
id
,
event_service
.
join_project
(
self
.
project
,
self
.
user
)
action:
Event
::
JOINED
,
notification_service
.
new_team_member
(
self
)
author_id:
self
.
user
.
id
end
)
notification_service
.
new_team_member
(
self
)
unless
owner?
system_hook_service
.
execute_hooks_for
(
self
,
:create
)
system_hook_service
.
execute_hooks_for
(
self
,
:create
)
end
end
...
@@ -129,15 +127,14 @@ class ProjectMember < Member
...
@@ -129,15 +127,14 @@ class ProjectMember < Member
end
end
def
post_destroy_hook
def
post_destroy_hook
Event
.
create
(
event_service
.
leave_project
(
self
.
project
,
self
.
user
)
project_id:
self
.
project
.
id
,
action:
Event
::
LEFT
,
author_id:
self
.
user
.
id
)
system_hook_service
.
execute_hooks_for
(
self
,
:destroy
)
system_hook_service
.
execute_hooks_for
(
self
,
:destroy
)
end
end
def
event_service
EventCreateService
.
new
end
def
notification_service
def
notification_service
NotificationService
.
new
NotificationService
.
new
end
end
...
...
app/services/create_branch_service.rb
View file @
2ad00f52
...
@@ -17,7 +17,7 @@ class CreateBranchService < BaseService
...
@@ -17,7 +17,7 @@ class CreateBranchService < BaseService
new_branch
=
repository
.
find_branch
(
branch_name
)
new_branch
=
repository
.
find_branch
(
branch_name
)
if
new_branch
if
new_branch
Event
.
create_ref_event
(
project
,
current_user
,
new_branch
,
'add'
)
Event
CreateService
.
new
.
push_ref
(
project
,
current_user
,
new_branch
,
'add'
)
return
success
(
new_branch
)
return
success
(
new_branch
)
else
else
return
error
(
'Invalid reference name'
)
return
error
(
'Invalid reference name'
)
...
...
app/services/create_tag_service.rb
View file @
2ad00f52
...
@@ -26,7 +26,7 @@ class CreateTagService < BaseService
...
@@ -26,7 +26,7 @@ class CreateTagService < BaseService
project
.
gitlab_ci_service
.
async_execute
(
push_data
)
project
.
gitlab_ci_service
.
async_execute
(
push_data
)
end
end
Event
.
create_ref_event
(
project
,
current_user
,
new_tag
,
'add'
,
'refs/tags'
)
Event
CreateService
.
new
.
push_ref
(
project
,
current_user
,
new_tag
,
'add'
,
'refs/tags'
)
success
(
new_tag
)
success
(
new_tag
)
else
else
error
(
'Invalid reference name'
)
error
(
'Invalid reference name'
)
...
...
app/services/delete_branch_service.rb
View file @
2ad00f52
...
@@ -25,7 +25,7 @@ class DeleteBranchService < BaseService
...
@@ -25,7 +25,7 @@ class DeleteBranchService < BaseService
end
end
if
repository
.
rm_branch
(
branch_name
)
if
repository
.
rm_branch
(
branch_name
)
Event
.
create_ref_event
(
project
,
current_user
,
branch
,
'rm'
)
Event
CreateService
.
new
.
push_ref
(
project
,
current_user
,
branch
,
'rm'
)
success
(
'Branch was removed'
)
success
(
'Branch was removed'
)
else
else
return
error
(
'Failed to remove branch'
)
return
error
(
'Failed to remove branch'
)
...
...
app/services/event_create_service.rb
View file @
2ad00f52
...
@@ -7,58 +7,98 @@
...
@@ -7,58 +7,98 @@
#
#
class
EventCreateService
class
EventCreateService
def
open_issue
(
issue
,
current_user
)
def
open_issue
(
issue
,
current_user
)
create_event
(
issue
,
current_user
,
Event
::
CREATED
)
create_
record_
event
(
issue
,
current_user
,
Event
::
CREATED
)
end
end
def
close_issue
(
issue
,
current_user
)
def
close_issue
(
issue
,
current_user
)
create_event
(
issue
,
current_user
,
Event
::
CLOSED
)
create_
record_
event
(
issue
,
current_user
,
Event
::
CLOSED
)
end
end
def
reopen_issue
(
issue
,
current_user
)
def
reopen_issue
(
issue
,
current_user
)
create_event
(
issue
,
current_user
,
Event
::
REOPENED
)
create_
record_
event
(
issue
,
current_user
,
Event
::
REOPENED
)
end
end
def
open_mr
(
merge_request
,
current_user
)
def
open_mr
(
merge_request
,
current_user
)
create_event
(
merge_request
,
current_user
,
Event
::
CREATED
)
create_
record_
event
(
merge_request
,
current_user
,
Event
::
CREATED
)
end
end
def
close_mr
(
merge_request
,
current_user
)
def
close_mr
(
merge_request
,
current_user
)
create_event
(
merge_request
,
current_user
,
Event
::
CLOSED
)
create_
record_
event
(
merge_request
,
current_user
,
Event
::
CLOSED
)
end
end
def
reopen_mr
(
merge_request
,
current_user
)
def
reopen_mr
(
merge_request
,
current_user
)
create_event
(
merge_request
,
current_user
,
Event
::
REOPENED
)
create_
record_
event
(
merge_request
,
current_user
,
Event
::
REOPENED
)
end
end
def
merge_mr
(
merge_request
,
current_user
)
def
merge_mr
(
merge_request
,
current_user
)
create_event
(
merge_request
,
current_user
,
Event
::
MERGED
)
create_
record_
event
(
merge_request
,
current_user
,
Event
::
MERGED
)
end
end
def
open_milestone
(
milestone
,
current_user
)
def
open_milestone
(
milestone
,
current_user
)
create_event
(
milestone
,
current_user
,
Event
::
CREATED
)
create_
record_
event
(
milestone
,
current_user
,
Event
::
CREATED
)
end
end
def
close_milestone
(
milestone
,
current_user
)
def
close_milestone
(
milestone
,
current_user
)
create_event
(
milestone
,
current_user
,
Event
::
CLOSED
)
create_
record_
event
(
milestone
,
current_user
,
Event
::
CLOSED
)
end
end
def
reopen_milestone
(
milestone
,
current_user
)
def
reopen_milestone
(
milestone
,
current_user
)
create_event
(
milestone
,
current_user
,
Event
::
REOPENED
)
create_
record_
event
(
milestone
,
current_user
,
Event
::
REOPENED
)
end
end
def
leave_note
(
note
,
current_user
)
def
leave_note
(
note
,
current_user
)
create_event
(
note
,
current_user
,
Event
::
COMMENTED
)
create_record_event
(
note
,
current_user
,
Event
::
COMMENTED
)
end
def
join_project
(
project
,
current_user
)
create_event
(
project
,
current_user
,
Event
::
JOINED
)
end
def
leave_project
(
project
,
current_user
)
create_event
(
project
,
current_user
,
Event
::
LEFT
)
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'
)
commit
=
project
.
repository
.
commit
(
ref
.
target
)
if
action
.
to_s
==
'add'
before
=
'00000000'
after
=
commit
.
id
else
before
=
commit
.
id
after
=
'00000000'
end
data
=
{
ref:
"
#{
prefix
}
/
#{
ref
.
name
}
"
,
before:
before
,
after:
after
}
push
(
project
,
current_user
,
data
)
end
def
push
(
project
,
current_user
,
push_data
)
create_event
(
project
,
current_user
,
Event
::
PUSHED
,
data:
push_data
)
end
end
private
private
def
create_event
(
record
,
current_user
,
status
)
def
create_record_event
(
record
,
current_user
,
status
)
Event
.
create
(
create_event
(
record
.
project
,
current_user
,
status
,
target_id:
record
.
id
,
target_type:
record
.
class
.
name
)
project:
record
.
project
,
end
target_id:
record
.
id
,
target_type:
record
.
class
.
name
,
def
create_event
(
project
,
current_user
,
status
,
attributes
=
{})
attributes
.
reverse_merge!
(
project:
project
,
action:
status
,
action:
status
,
author_id:
current_user
.
id
author_id:
current_user
.
id
)
)
Event
.
create
(
attributes
)
end
end
end
end
app/services/git_push_service.rb
View file @
2ad00f52
...
@@ -52,7 +52,7 @@ class GitPushService
...
@@ -52,7 +52,7 @@ class GitPushService
end
end
@push_data
=
post_receive_data
(
oldrev
,
newrev
,
ref
)
@push_data
=
post_receive_data
(
oldrev
,
newrev
,
ref
)
create_push_event
(
@push_data
)
EventCreateService
.
new
.
push
(
project
,
user
,
@push_data
)
project
.
execute_hooks
(
@push_data
.
dup
,
:push_hooks
)
project
.
execute_hooks
(
@push_data
.
dup
,
:push_hooks
)
project
.
execute_services
(
@push_data
.
dup
)
project
.
execute_services
(
@push_data
.
dup
)
end
end
...
@@ -60,15 +60,6 @@ class GitPushService
...
@@ -60,15 +60,6 @@ class GitPushService
protected
protected
def
create_push_event
(
push_data
)
Event
.
create!
(
project:
project
,
action:
Event
::
PUSHED
,
data:
push_data
,
author_id:
push_data
[
:user_id
]
)
end
# Extract any GFM references from the pushed commit messages. If the configured issue-closing regex is matched,
# Extract any GFM references from the pushed commit messages. If the configured issue-closing regex is matched,
# close the referenced Issue. Create cross-reference Notes corresponding to any other referenced Mentionables.
# close the referenced Issue. Create cross-reference Notes corresponding to any other referenced Mentionables.
def
process_commit_messages
(
ref
)
def
process_commit_messages
(
ref
)
...
...
app/services/git_tag_push_service.rb
View file @
2ad00f52
...
@@ -5,7 +5,7 @@ class GitTagPushService
...
@@ -5,7 +5,7 @@ class GitTagPushService
@project
,
@user
=
project
,
user
@project
,
@user
=
project
,
user
@push_data
=
create_push_data
(
oldrev
,
newrev
,
ref
)
@push_data
=
create_push_data
(
oldrev
,
newrev
,
ref
)
create_push_event
EventCreateService
.
new
.
push
(
project
,
user
,
@push_data
)
project
.
repository
.
expire_cache
project
.
repository
.
expire_cache
project
.
execute_hooks
(
@push_data
.
dup
,
:tag_push_hooks
)
project
.
execute_hooks
(
@push_data
.
dup
,
:tag_push_hooks
)
...
@@ -22,13 +22,4 @@ class GitTagPushService
...
@@ -22,13 +22,4 @@ class GitTagPushService
Gitlab
::
PushDataBuilder
.
Gitlab
::
PushDataBuilder
.
build
(
project
,
user
,
oldrev
,
newrev
,
ref
,
[])
build
(
project
,
user
,
oldrev
,
newrev
,
ref
,
[])
end
end
def
create_push_event
Event
.
create!
(
project:
project
,
action:
Event
::
PUSHED
,
data:
push_data
,
author_id:
push_data
[
:user_id
]
)
end
end
end
app/services/projects/create_service.rb
View file @
2ad00f52
...
@@ -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
...
...
app/views/admin/application_settings/_form.html.haml
View file @
2ad00f52
...
@@ -19,6 +19,11 @@
...
@@ -19,6 +19,11 @@
=
f
.
label
:gravatar_enabled
,
class:
'control-label'
=
f
.
label
:gravatar_enabled
,
class:
'control-label'
.col-sm-10
.col-sm-10
=
f
.
check_box
:gravatar_enabled
,
class:
'checkbox'
=
f
.
check_box
:gravatar_enabled
,
class:
'checkbox'
.form-group
=
f
.
label
:twitter_sharing_enabled
,
"Twitter enabled"
,
class:
'control-label'
.col-sm-10
=
f
.
check_box
:twitter_sharing_enabled
,
class:
'checkbox'
%span
.help-block
Show users button to share their newly created public or internal projects on twitter
%fieldset
%fieldset
%legend
Misc
%legend
Misc
.form-group
.form-group
...
...
app/views/events/_event.html.haml
View file @
2ad00f52
...
@@ -3,12 +3,14 @@
...
@@ -3,12 +3,14 @@
.event-item-timestamp
.event-item-timestamp
#{
time_ago_with_tooltip
(
event
.
created_at
)
}
#{
time_ago_with_tooltip
(
event
.
created_at
)
}
=
cache
event
do
=
cache
[
event
,
current_user
]
do
=
image_tag
avatar_icon
(
event
.
author_email
,
24
),
class:
"avatar s24"
,
alt
:''
=
image_tag
avatar_icon
(
event
.
author_email
,
24
),
class:
"avatar s24"
,
alt
:''
-
if
event
.
push?
-
if
event
.
push?
=
render
"events/event/push"
,
event:
event
=
render
"events/event/push"
,
event:
event
-
elsif
event
.
note
?
-
elsif
event
.
commented
?
=
render
"events/event/note"
,
event:
event
=
render
"events/event/note"
,
event:
event
-
elsif
event
.
created_project?
=
render
"events/event/created_project"
,
event:
event
-
else
-
else
=
render
"events/event/common"
,
event:
event
=
render
"events/event/common"
,
event:
event
\ No newline at end of file
app/views/events/event/_common.html.haml
View file @
2ad00f52
.event-title
.event-title
%span
.author_name
=
link_to_author
event
%span
.author_name
=
link_to_author
event
%span
.event_label
{
class:
event
.
action_name
}=
event_action_name
(
event
)
%span
.event_label
{
class:
event
.
action_name
}
=
event_action_name
(
event
)
-
if
event
.
target
-
if
event
.
target
%strong
=
link_to
"#
#{
event
.
target_iid
}
"
,
[
event
.
project
,
event
.
target
]
%strong
=
link_to
"#
#{
event
.
target_iid
}
"
,
[
event
.
project
,
event
.
target
]
-
else
%strong
=
gfm
event
.
target_title
at
at
-
if
event
.
project
-
if
event
.
project
=
link_to_project
event
.
project
=
link_to_project
event
.
project
-
else
-
else
=
event
.
project_name
=
event
.
project_name
-
if
event
.
target
.
respond_to?
(
:title
)
-
if
event
.
target
.
respond_to?
(
:title
)
.event-body
.event-body
.event-note
.event-note
...
...
app/views/events/event/_created_project.html.haml
0 → 100644
View file @
2ad00f52
.event-title
%span
.author_name
=
link_to_author
event
%span
.event_label
{
class:
event
.
action_name
}
=
event_action_name
(
event
)
-
if
event
.
project
=
link_to_project
event
.
project
-
else
=
event
.
project_name
-
if
current_user
==
event
.
author
&&
!
event
.
project
.
private?
&&
twitter_sharing_enabled?
.event-body
.event-note
.md
%p
Congratulations! Why not share your accomplishment with the world?
%a
.twitter-share-button
{
|
href:
"https://twitter.com/share"
,
|
"data-url"
=>
event
.
project
.
web_url
,
|
"data-text"
=>
"I just created a new project in GitLab! GitLab is version control on your server."
,
|
"data-size"
=>
"medium"
,
|
"data-related"
=>
"gitlab"
,
|
"data-hashtags"
=>
"gitlab"
,
|
"data-count"
=>
"none"
}
Tweet
%script
{
src:
"//platform.twitter.com/widgets.js"
}
\ No newline at end of file
app/views/events/event/_note.html.haml
View file @
2ad00f52
.event-title
.event-title
%span
.author_name
=
link_to_author
event
%span
.author_name
=
link_to_author
event
%span
.event_label
commented on
#{
event_note_title_html
(
event
)
}
at
%span
.event_label
=
event
.
action_name
=
event_note_title_html
(
event
)
at
-
if
event
.
project
-
if
event
.
project
=
link_to_project
event
.
project
=
link_to_project
event
.
project
-
else
-
else
...
...
app/views/events/event/_push.html.haml
View file @
2ad00f52
.event-title
.event-title
%span
.author_name
=
link_to_author
event
%span
.author_name
=
link_to_author
event
%span
.event_label.pushed
#{
event
.
push_
action_name
}
#{
event
.
ref_type
}
%span
.event_label.pushed
#{
event
.
action_name
}
#{
event
.
ref_type
}
-
if
event
.
rm_ref?
-
if
event
.
rm_ref?
%strong
=
event
.
ref_name
%strong
=
event
.
ref_name
-
else
-
else
...
...
config/initializers/1_settings.rb
View file @
2ad00f52
...
@@ -112,6 +112,7 @@ end
...
@@ -112,6 +112,7 @@ end
Settings
.
gitlab
[
'time_zone'
]
||=
nil
Settings
.
gitlab
[
'time_zone'
]
||=
nil
Settings
.
gitlab
[
'signup_enabled'
]
||=
true
if
Settings
.
gitlab
[
'signup_enabled'
].
nil?
Settings
.
gitlab
[
'signup_enabled'
]
||=
true
if
Settings
.
gitlab
[
'signup_enabled'
].
nil?
Settings
.
gitlab
[
'signin_enabled'
]
||=
true
if
Settings
.
gitlab
[
'signin_enabled'
].
nil?
Settings
.
gitlab
[
'signin_enabled'
]
||=
true
if
Settings
.
gitlab
[
'signin_enabled'
].
nil?
Settings
.
gitlab
[
'twitter_sharing_enabled'
]
||=
true
if
Settings
.
gitlab
[
'twitter_sharing_enabled'
].
nil?
Settings
.
gitlab
[
'restricted_visibility_levels'
]
=
Settings
.
send
(
:verify_constant_array
,
Gitlab
::
VisibilityLevel
,
Settings
.
gitlab
[
'restricted_visibility_levels'
],
[])
Settings
.
gitlab
[
'restricted_visibility_levels'
]
=
Settings
.
send
(
:verify_constant_array
,
Gitlab
::
VisibilityLevel
,
Settings
.
gitlab
[
'restricted_visibility_levels'
],
[])
Settings
.
gitlab
[
'username_changing_enabled'
]
=
true
if
Settings
.
gitlab
[
'username_changing_enabled'
].
nil?
Settings
.
gitlab
[
'username_changing_enabled'
]
=
true
if
Settings
.
gitlab
[
'username_changing_enabled'
].
nil?
Settings
.
gitlab
[
'issue_closing_pattern'
]
=
'((?:[Cc]los(?:e[sd]?|ing)|[Ff]ix(?:e[sd]|ing)?|[Rr]esolv(?:e[sd]?|ing)) +(?:(?:issues? +)?#\d+(?:(?:, *| +and +)?))+)'
if
Settings
.
gitlab
[
'issue_closing_pattern'
].
nil?
Settings
.
gitlab
[
'issue_closing_pattern'
]
=
'((?:[Cc]los(?:e[sd]?|ing)|[Ff]ix(?:e[sd]|ing)?|[Rr]esolv(?:e[sd]?|ing)) +(?:(?:issues? +)?#\d+(?:(?:, *| +and +)?))+)'
if
Settings
.
gitlab
[
'issue_closing_pattern'
].
nil?
...
...
db/migrate/20150213104043_add_twitter_sharing_enabled_to_application_settings.rb
0 → 100644
View file @
2ad00f52
class
AddTwitterSharingEnabledToApplicationSettings
<
ActiveRecord
::
Migration
def
change
add_column
:application_settings
,
:twitter_sharing_enabled
,
:boolean
,
default:
true
end
end
features/dashboard/dashboard.feature
View file @
2ad00f52
...
@@ -27,11 +27,11 @@ Feature: Dashboard
...
@@ -27,11 +27,11 @@ Feature: Dashboard
Scenario
:
I
should see User joined Project event
Scenario
:
I
should see User joined Project event
Given
user with name
"John Doe"
joined project
"Shop"
Given
user with name
"John Doe"
joined project
"Shop"
When
I visit dashboard page
When
I visit dashboard page
Then
I should see
"John Doe joined project
at
Shop"
event
Then
I should see
"John Doe joined project Shop"
event
@javascript
@javascript
Scenario
:
I
should see User left Project event
Scenario
:
I
should see User left Project event
Given
user with name
"John Doe"
joined project
"Shop"
Given
user with name
"John Doe"
joined project
"Shop"
And
user with name
"John Doe"
left project
"Shop"
And
user with name
"John Doe"
left project
"Shop"
When
I visit dashboard page
When
I visit dashboard page
Then
I should see
"John Doe left project
at
Shop"
event
Then
I should see
"John Doe left project Shop"
event
features/steps/dashboard/dashboard.rb
View file @
2ad00f52
...
@@ -37,8 +37,8 @@ class Spinach::Features::Dashboard < Spinach::FeatureSteps
...
@@ -37,8 +37,8 @@ class Spinach::Features::Dashboard < Spinach::FeatureSteps
)
)
end
end
step
'I should see "John Doe joined project
at
Shop" event'
do
step
'I should see "John Doe joined project Shop" event'
do
page
.
should
have_content
"John Doe joined project
at
#{
project
.
name_with_namespace
}
"
page
.
should
have_content
"John Doe joined project
#{
project
.
name_with_namespace
}
"
end
end
step
'user with name "John Doe" left project "Shop"'
do
step
'user with name "John Doe" left project "Shop"'
do
...
@@ -50,8 +50,8 @@ class Spinach::Features::Dashboard < Spinach::FeatureSteps
...
@@ -50,8 +50,8 @@ class Spinach::Features::Dashboard < Spinach::FeatureSteps
)
)
end
end
step
'I should see "John Doe left project
at
Shop" event'
do
step
'I should see "John Doe left project Shop" event'
do
page
.
should
have_content
"John Doe left project
at
#{
project
.
name_with_namespace
}
"
page
.
should
have_content
"John Doe left project
#{
project
.
name_with_namespace
}
"
end
end
step
'I have group with projects'
do
step
'I have group with projects'
do
...
...
spec/requests/api/projects_spec.rb
View file @
2ad00f52
...
@@ -347,7 +347,7 @@ describe API::API, api: true do
...
@@ -347,7 +347,7 @@ describe API::API, api: true do
end
end
describe
'GET /projects/:id/events'
do
describe
'GET /projects/:id/events'
do
before
{
project_member
}
before
{
project_member
2
}
it
'should return a project events'
do
it
'should return a project events'
do
get
api
(
"/projects/
#{
project
.
id
}
/events"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/events"
,
user
)
...
@@ -356,7 +356,7 @@ describe API::API, api: true do
...
@@ -356,7 +356,7 @@ describe API::API, api: true do
expect
(
json_event
[
'action_name'
]).
to
eq
(
'joined'
)
expect
(
json_event
[
'action_name'
]).
to
eq
(
'joined'
)
expect
(
json_event
[
'project_id'
].
to_i
).
to
eq
(
project
.
id
)
expect
(
json_event
[
'project_id'
].
to_i
).
to
eq
(
project
.
id
)
expect
(
json_event
[
'author_username'
]).
to
eq
(
user
.
username
)
expect
(
json_event
[
'author_username'
]).
to
eq
(
user
3
.
username
)
end
end
it
'should return a 404 error if not found'
do
it
'should return a 404 error if not found'
do
...
...
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