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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
2ec12c9b
Commit
2ec12c9b
authored
Mar 16, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Impoved merge requests show page. Minor style improvements across project
parent
e2b39517
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
101 additions
and
70 deletions
+101
-70
app/assets/stylesheets/common.scss
app/assets/stylesheets/common.scss
+19
-1
app/controllers/merge_requests_controller.rb
app/controllers/merge_requests_controller.rb
+2
-5
app/models/merge_request.rb
app/models/merge_request.rb
+29
-0
app/models/project.rb
app/models/project.rb
+7
-24
app/views/events/_event_changed_issue.html.haml
app/views/events/_event_changed_issue.html.haml
+6
-5
app/views/events/_event_changed_merge_request.html.haml
app/views/events/_event_changed_merge_request.html.haml
+6
-6
app/views/events/_event_new_issue.html.haml
app/views/events/_event_new_issue.html.haml
+2
-1
app/views/events/_event_new_merge_request.html.haml
app/views/events/_event_new_merge_request.html.haml
+2
-2
app/views/events/_event_push.html.haml
app/views/events/_event_push.html.haml
+8
-6
app/views/issues/_show.html.haml
app/views/issues/_show.html.haml
+1
-1
app/views/merge_requests/_how_to_merge.html.haml
app/views/merge_requests/_how_to_merge.html.haml
+1
-1
app/views/merge_requests/_merge_request.html.haml
app/views/merge_requests/_merge_request.html.haml
+1
-1
app/views/merge_requests/show.html.haml
app/views/merge_requests/show.html.haml
+17
-17
No files found.
app/assets/stylesheets/common.scss
View file @
2ec12c9b
...
@@ -41,6 +41,10 @@ a:focus {
...
@@ -41,6 +41,10 @@ a:focus {
.label
{
.label
{
background-color
:
#474D57
;
background-color
:
#474D57
;
&
.pushed
{
background-color
:
$link_color
;
}
}
}
.pretty_label
{
.pretty_label
{
...
@@ -865,7 +869,7 @@ p.time {
...
@@ -865,7 +869,7 @@ p.time {
}
}
}
}
padding
:
1
0
px
5px
;
padding
:
1
5
px
5px
;
border-bottom
:
1px
solid
#eee
;
border-bottom
:
1px
solid
#eee
;
border-bottom
:
1px
solid
rgba
(
0
,
0
,
0
,
0
.05
);
border-bottom
:
1px
solid
rgba
(
0
,
0
,
0
,
0
.05
);
&
:last-child
{
border
:none
}
&
:last-child
{
border
:none
}
...
@@ -963,3 +967,17 @@ p.time {
...
@@ -963,3 +967,17 @@ p.time {
.highlight_word
{
.highlight_word
{
background
:
#EEDC94
;
background
:
#EEDC94
;
}
}
.status_info
{
font-size
:
14px
;
padding
:
5px
15px
;
line-height
:
24px
;
width
:
60px
;
text-align
:center
;
float
:left
;
margin-right
:
20px
;
}
.merge_request_status_holder
{
margin-bottom
:
20px
;
}
app/controllers/merge_requests_controller.rb
View file @
2ec12c9b
...
@@ -45,9 +45,6 @@ class MergeRequestsController < ApplicationController
...
@@ -45,9 +45,6 @@ class MergeRequestsController < ApplicationController
# or from cache if already merged
# or from cache if already merged
@commits
=
@merge_request
.
commits
@commits
=
@merge_request
.
commits
# Close MR if nothing to merge
#@merge_request.mark_as_merged! if @merge_request.probably_merged?
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
format
.
html
format
.
js
format
.
js
...
@@ -75,8 +72,7 @@ class MergeRequestsController < ApplicationController
...
@@ -75,8 +72,7 @@ class MergeRequestsController < ApplicationController
respond_to
do
|
format
|
respond_to
do
|
format
|
if
@merge_request
.
save
if
@merge_request
.
save
@merge_request
.
reloaded_commits
@merge_request
.
reload_code
@merge_request
.
reloaded_diffs
format
.
html
{
redirect_to
[
@project
,
@merge_request
],
notice:
'Merge request was successfully created.'
}
format
.
html
{
redirect_to
[
@project
,
@merge_request
],
notice:
'Merge request was successfully created.'
}
format
.
json
{
render
json:
@merge_request
,
status: :created
,
location:
@merge_request
}
format
.
json
{
render
json:
@merge_request
,
status: :created
,
location:
@merge_request
}
else
else
...
@@ -89,6 +85,7 @@ class MergeRequestsController < ApplicationController
...
@@ -89,6 +85,7 @@ class MergeRequestsController < ApplicationController
def
update
def
update
respond_to
do
|
format
|
respond_to
do
|
format
|
if
@merge_request
.
update_attributes
(
params
[
:merge_request
].
merge
(
:author_id_of_changes
=>
current_user
.
id
))
if
@merge_request
.
update_attributes
(
params
[
:merge_request
].
merge
(
:author_id_of_changes
=>
current_user
.
id
))
@merge_request
.
reload_code
format
.
html
{
redirect_to
[
@project
,
@merge_request
],
notice:
'Merge request was successfully updated.'
}
format
.
html
{
redirect_to
[
@project
,
@merge_request
],
notice:
'Merge request was successfully updated.'
}
format
.
json
{
head
:ok
}
format
.
json
{
head
:ok
}
else
else
...
...
app/models/merge_request.rb
View file @
2ec12c9b
...
@@ -41,12 +41,21 @@ class MergeRequest < ActiveRecord::Base
...
@@ -41,12 +41,21 @@ class MergeRequest < ActiveRecord::Base
where
(
"title like :query"
,
:query
=>
"%
#{
query
}
%"
)
where
(
"title like :query"
,
:query
=>
"%
#{
query
}
%"
)
end
end
def
self
.
find_all_by_branch
(
branch_name
)
where
(
"source_branch like :branch or target_branch like :branch"
,
:branch
=>
branch_name
)
end
def
validate_branches
def
validate_branches
if
target_branch
==
source_branch
if
target_branch
==
source_branch
errors
.
add
:base
,
"You can not use same branch for source and target branches"
errors
.
add
:base
,
"You can not use same branch for source and target branches"
end
end
end
end
def
reload_code
self
.
reloaded_commits
self
.
reloaded_diffs
end
def
new?
def
new?
today?
&&
created_at
==
updated_at
today?
&&
created_at
==
updated_at
end
end
...
@@ -72,10 +81,19 @@ class MergeRequest < ActiveRecord::Base
...
@@ -72,10 +81,19 @@ class MergeRequest < ActiveRecord::Base
commits
.
first
commits
.
first
end
end
def
merged?
merged
&&
merge_event
end
def
merge_event
def
merge_event
self
.
project
.
events
.
where
(
:target_id
=>
self
.
id
,
:target_type
=>
"MergeRequest"
,
:action
=>
Event
::
Merged
).
last
self
.
project
.
events
.
where
(
:target_id
=>
self
.
id
,
:target_type
=>
"MergeRequest"
,
:action
=>
Event
::
Merged
).
last
end
end
def
closed_event
self
.
project
.
events
.
where
(
:target_id
=>
self
.
id
,
:target_type
=>
"MergeRequest"
,
:action
=>
Event
::
Closed
).
last
end
# Return the number of +1 comments (upvotes)
# Return the number of +1 comments (upvotes)
def
upvotes
def
upvotes
notes
.
select
(
&
:
upvote?
).
size
notes
.
select
(
&
:
upvote?
).
size
...
@@ -115,6 +133,17 @@ class MergeRequest < ActiveRecord::Base
...
@@ -115,6 +133,17 @@ class MergeRequest < ActiveRecord::Base
sort_by
(
&
:
created_at
).
sort_by
(
&
:
created_at
).
reverse
reverse
end
end
def
merge!
(
user_id
)
self
.
mark_as_merged!
Event
.
create
(
:
project
=>
self
.
project
,
:action
=>
Event
::
Merged
,
:target_id
=>
self
.
id
,
:target_type
=>
"MergeRequest"
,
:author_id
=>
user_id
)
end
end
end
# == Schema Information
# == Schema Information
#
#
...
...
app/models/project.rb
View file @
2ec12c9b
...
@@ -80,35 +80,18 @@ class Project < ActiveRecord::Base
...
@@ -80,35 +80,18 @@ class Project < ActiveRecord::Base
def
update_merge_requests
(
oldrev
,
newrev
,
ref
,
author_key_id
)
def
update_merge_requests
(
oldrev
,
newrev
,
ref
,
author_key_id
)
return
true
unless
ref
=~
/heads/
return
true
unless
ref
=~
/heads/
branch_name
=
ref
.
gsub
(
"refs/heads/"
,
""
)
branch_name
=
ref
.
gsub
(
"refs/heads/"
,
""
)
user
=
Key
.
find_by_identifier
(
author_key_id
).
user
key
=
Key
.
find_by_identifier
(
author_key_id
)
user
=
key
.
user
c_ids
=
self
.
commits_between
(
oldrev
,
newrev
).
map
(
&
:id
)
c_ids
=
self
.
commits_between
(
oldrev
,
newrev
).
map
(
&
:id
)
# update commits & diffs for existing MR
# Update code for merge requests
mrs
=
self
.
merge_requests
.
opened
.
where
(
:source_branch
=>
branch_name
).
all
mrs
=
self
.
merge_requests
.
opened
.
find_all_by_branch
(
branch_name
).
all
mrs
.
each
do
|
merge_request
|
mrs
.
each
{
|
merge_request
|
merge_request
.
reload_code
}
merge_request
.
reloaded_commits
merge_request
.
reloaded_diffs
end
# Close merge requests
# Close merge requests
mrs
=
self
.
merge_requests
.
opened
.
where
(
:target_branch
=>
branch_name
).
all
mrs
=
self
.
merge_requests
.
opened
.
where
(
:target_branch
=>
branch_name
).
all
mrs
.
each
do
|
merge_request
|
mrs
=
mrs
.
select
(
&
:last_commit
).
select
{
|
mr
|
c_ids
.
include?
(
mr
.
last_commit
.
id
)
}
next
unless
merge_request
.
last_commit
mrs
.
each
{
|
merge_request
|
merge_request
.
merge!
(
user
.
id
)
}
# Mark as merged & create event if merged
if
c_ids
.
include?
(
merge_request
.
last_commit
.
id
)
merge_request
.
mark_as_merged!
Event
.
create
(
:project
=>
self
,
:action
=>
Event
::
Merged
,
:target_id
=>
merge_request
.
id
,
:target_type
=>
"MergeRequest"
,
:author_id
=>
user
.
id
)
end
end
true
true
end
end
...
...
app/views/events/_event_changed_issue.html.haml
View file @
2ec12c9b
=
image_tag
gravatar_icon
(
event
.
author_email
),
:class
=>
"avatar"
=
image_tag
gravatar_icon
(
event
.
author_email
),
:class
=>
"avatar"
%strong
#{
event
.
author_name
}
%strong
#{
event
.
author_name
}
-
if
event
.
closed?
%span
.label.important
-
if
event
.
closed?
closed
closed
-
else
-
else
reopened
reopened
issue
issue
=
link_to
project_issue_path
(
event
.
project
,
event
.
issue
)
do
=
link_to
project_issue_path
(
event
.
project
,
event
.
issue
)
do
%strong
=
truncate
event
.
issue_title
%strong
=
truncate
event
.
issue_title
at
at
...
...
app/views/events/_event_changed_merge_request.html.haml
View file @
2ec12c9b
=
image_tag
gravatar_icon
(
event
.
author_email
),
:class
=>
"avatar"
=
image_tag
gravatar_icon
(
event
.
author_email
),
:class
=>
"avatar"
%strong
#{
event
.
author_name
}
%strong
#{
event
.
author_name
}
-
if
event
.
closed?
%span
.label.important
-
if
event
.
closed?
closed
closed
-
else
-
else
reopened
reopened
merge request
merge request
=
link_to
project_merge_request_path
(
event
.
project
,
event
.
merge_request
)
do
=
link_to
project_merge_request_path
(
event
.
project
,
event
.
merge_request
)
do
%strong
=
truncate
event
.
merge_request_title
%strong
=
truncate
event
.
merge_request_title
at
at
...
@@ -12,7 +13,6 @@ at
...
@@ -12,7 +13,6 @@ at
%span
.cgray
%span
.cgray
=
time_ago_in_words
(
event
.
created_at
)
=
time_ago_in_words
(
event
.
created_at
)
ago.
ago.
%br
%span
.label
=
event
.
merge_request
.
source_branch
%span
.label
=
event
.
merge_request
.
source_branch
→
→
%span
.label
=
event
.
merge_request
.
target_branch
%span
.label
=
event
.
merge_request
.
target_branch
...
...
app/views/events/_event_new_issue.html.haml
View file @
2ec12c9b
=
image_tag
gravatar_icon
(
event
.
author_email
),
:class
=>
"avatar"
=
image_tag
gravatar_icon
(
event
.
author_email
),
:class
=>
"avatar"
%strong
#{
event
.
author_name
}
%strong
#{
event
.
author_name
}
created new issue
%span
.label.success
created
new issue
=
link_to
project_issue_path
(
event
.
project
,
event
.
issue
)
do
=
link_to
project_issue_path
(
event
.
project
,
event
.
issue
)
do
%strong
=
truncate
event
.
issue_title
%strong
=
truncate
event
.
issue_title
at
at
...
...
app/views/events/_event_new_merge_request.html.haml
View file @
2ec12c9b
=
image_tag
gravatar_icon
(
event
.
author_email
),
:class
=>
"avatar"
=
image_tag
gravatar_icon
(
event
.
author_email
),
:class
=>
"avatar"
%strong
#{
event
.
author_name
}
%strong
#{
event
.
author_name
}
requested merge
%span
.label.success
requested
merge
=
link_to
project_merge_request_path
(
event
.
project
,
event
.
merge_request
)
do
=
link_to
project_merge_request_path
(
event
.
project
,
event
.
merge_request
)
do
%strong
=
truncate
event
.
merge_request_title
%strong
=
truncate
event
.
merge_request_title
at
at
...
@@ -8,7 +9,6 @@ at
...
@@ -8,7 +9,6 @@ at
%span
.cgray
%span
.cgray
=
time_ago_in_words
(
event
.
created_at
)
=
time_ago_in_words
(
event
.
created_at
)
ago.
ago.
%br
%span
.label
=
event
.
merge_request
.
source_branch
%span
.label
=
event
.
merge_request
.
source_branch
→
→
%span
.label
=
event
.
merge_request
.
target_branch
%span
.label
=
event
.
merge_request
.
target_branch
...
...
app/views/events/_event_push.html.haml
View file @
2ec12c9b
-
if
event
.
new_branch?
||
event
.
new_tag?
-
if
event
.
new_branch?
||
event
.
new_tag?
=
image_tag
gravatar_icon
(
event
.
author_email
),
:class
=>
"avatar"
=
image_tag
gravatar_icon
(
event
.
author_email
),
:class
=>
"avatar"
%strong
#{
event
.
author_name
}
%strong
#{
event
.
author_name
}
pushed new
%span
.label.pushed
pushed
new
-
if
event
.
new_tag?
-
if
event
.
new_tag?
tag
tag
=
link_to
project_commits_path
(
event
.
project
,
:ref
=>
event
.
tag_name
)
do
=
link_to
project_commits_path
(
event
.
project
,
:ref
=>
event
.
tag_name
)
do
...
@@ -18,7 +19,8 @@
...
@@ -18,7 +19,8 @@
-
else
-
else
=
image_tag
gravatar_icon
(
event
.
author_email
),
:class
=>
"avatar"
=
image_tag
gravatar_icon
(
event
.
author_email
),
:class
=>
"avatar"
%strong
#{
event
.
author_name
}
%strong
#{
event
.
author_name
}
pushed to
%span
.label.pushed
pushed
to
=
link_to
project_commits_path
(
event
.
project
,
:ref
=>
event
.
branch_name
)
do
=
link_to
project_commits_path
(
event
.
project
,
:ref
=>
event
.
branch_name
)
do
%strong
=
event
.
branch_name
%strong
=
event
.
branch_name
at
at
...
@@ -30,10 +32,10 @@
...
@@ -30,10 +32,10 @@
=
link_to
compare_project_commits_path
(
event
.
project
,
:from
=>
event
.
commits
.
first
.
prev_commit_id
,
:to
=>
event
.
commits
.
last
.
id
)
do
=
link_to
compare_project_commits_path
(
event
.
project
,
:from
=>
event
.
commits
.
first
.
prev_commit_id
,
:to
=>
event
.
commits
.
last
.
id
)
do
Compare
#{
event
.
commits
.
first
.
commit
.
id
[
0
..
8
]
}
...
#{
event
.
commits
.
last
.
id
[
0
..
8
]
}
Compare
#{
event
.
commits
.
first
.
commit
.
id
[
0
..
8
]
}
...
#{
event
.
commits
.
last
.
id
[
0
..
8
]
}
-
@project
=
event
.
project
-
@project
=
event
.
project
%ul
.unstyled
%ul
.unstyled
.event_commits
-
if
event
.
commits
.
size
>
4
-
if
event
.
commits
.
size
>
3
=
render
event
.
commits
[
0
..
2
]
=
render
event
.
commits
[
0
..
.
2
]
%li
... and
#{
event
.
commits
.
size
-
3
}
more commits
%li
... and
#{
event
.
commits
.
size
-
2
}
more commits
-
else
-
else
=
render
event
.
commits
=
render
event
.
commits
...
...
app/views/issues/_show.html.haml
View file @
2ec12c9b
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
-
if
issue
.
today?
-
if
issue
.
today?
%span
.label.success
today
%span
.label.success
today
-
if
issue
.
notes
.
any?
-
if
issue
.
notes
.
any?
%span
.label
=
pluralize
issue
.
notes
.
count
,
'note'
%span
.
pretty_
label
=
pluralize
issue
.
notes
.
count
,
'note'
-
if
issue
.
upvotes
>
0
-
if
issue
.
upvotes
>
0
%span
.label.success
=
"+
#{
issue
.
upvotes
}
"
%span
.label.success
=
"+
#{
issue
.
upvotes
}
"
...
...
app/views/merge_requests/_how_to_merge.html.haml
View file @
2ec12c9b
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
:javascript
:javascript
$
(
function
(){
$
(
function
(){
var
modal
=
$
(
'
#modal_merge_info
'
).
modal
({
modal
:
true
});
var
modal
=
$
(
'
#modal_merge_info
'
).
modal
({
modal
:
true
});
$
(
'
.
info
_link
'
).
bind
(
"
click
"
,
function
(){
$
(
'
.
how_to_merge
_link
'
).
bind
(
"
click
"
,
function
(){
modal
.
show
();
modal
.
show
();
});
});
$
(
'
.modal-header .close
'
).
bind
(
"
click
"
,
function
(){
$
(
'
.modal-header .close
'
).
bind
(
"
click
"
,
function
(){
...
...
app/views/merge_requests/_merge_request.html.haml
View file @
2ec12c9b
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
=
time_ago_in_words
(
merge_request
.
created_at
)
=
time_ago_in_words
(
merge_request
.
created_at
)
ago
ago
-
if
merge_request
.
notes
.
any?
-
if
merge_request
.
notes
.
any?
%span
.label
=
pluralize
merge_request
.
notes
.
count
,
'note'
%span
.
pretty_
label
=
pluralize
merge_request
.
notes
.
count
,
'note'
-
if
merge_request
.
upvotes
>
0
-
if
merge_request
.
upvotes
>
0
%span
.label.success
=
"+
#{
merge_request
.
upvotes
}
"
%span
.label.success
=
"+
#{
merge_request
.
upvotes
}
"
.right
.right
...
...
app/views/merge_requests/show.html.haml
View file @
2ec12c9b
...
@@ -26,23 +26,23 @@
...
@@ -26,23 +26,23 @@
%hr
%hr
-
if
@merge_request
.
closed
.merge_request_status_holder
.alert-message.error
Closed
-
if
@merge_request
.
closed
-
if
@merge_request
.
merged
%h5
-
event
=
@merge_request
.
merge_event
.alert-message.error.status_info
Closed
%div
-
if
@merge_request
.
merged?
%p
%span
%strong
#{
event
.
author_name
}
Merged by
#{
@merge_request
.
merge_event
.
author_name
}
merged this request
%small
#{
time_ago_in_words
(
@merge_request
.
merge_event
.
created_at
)
}
ago.
%span
.cgray
-
elsif
@merge_request
.
closed_event
=
time_ago_in_words
(
event
.
created_at
)
%span
ago.
Closed by
#{
@merge_request
.
closed_event
.
author_name
}
%small
#{
time_ago_in_words
(
@merge_request
.
closed_event
.
created_at
)
}
ago.
%br
%br
-
else
-
else
.alert-message.success
%h5
=
link_to
"#"
,
:class
=>
"info_link"
,
:title
=>
"How To Merge"
do
.alert-message.success.status_info
Open
=
image_tag
"Info-UI.PNG"
=
link_to
"How to merge"
,
"#"
,
:class
=>
"vlink how_to_merge_link"
,
:title
=>
"How To Merge"
Open
=
render
"merge_requests/how_to_merge"
=
render
"merge_requests/how_to_merge"
...
...
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