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
Léo-Paul Géneau
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
Hide 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 {
.label
{
background-color
:
#474D57
;
&
.pushed
{
background-color
:
$link_color
;
}
}
.pretty_label
{
...
...
@@ -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
rgba
(
0
,
0
,
0
,
0
.05
);
&
:last-child
{
border
:none
}
...
...
@@ -963,3 +967,17 @@ p.time {
.highlight_word
{
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
# or from cache if already merged
@commits
=
@merge_request
.
commits
# Close MR if nothing to merge
#@merge_request.mark_as_merged! if @merge_request.probably_merged?
respond_to
do
|
format
|
format
.
html
format
.
js
...
...
@@ -75,8 +72,7 @@ class MergeRequestsController < ApplicationController
respond_to
do
|
format
|
if
@merge_request
.
save
@merge_request
.
reloaded_commits
@merge_request
.
reloaded_diffs
@merge_request
.
reload_code
format
.
html
{
redirect_to
[
@project
,
@merge_request
],
notice:
'Merge request was successfully created.'
}
format
.
json
{
render
json:
@merge_request
,
status: :created
,
location:
@merge_request
}
else
...
...
@@ -89,6 +85,7 @@ class MergeRequestsController < ApplicationController
def
update
respond_to
do
|
format
|
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
.
json
{
head
:ok
}
else
...
...
app/models/merge_request.rb
View file @
2ec12c9b
...
...
@@ -41,12 +41,21 @@ class MergeRequest < ActiveRecord::Base
where
(
"title like :query"
,
:query
=>
"%
#{
query
}
%"
)
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
if
target_branch
==
source_branch
errors
.
add
:base
,
"You can not use same branch for source and target branches"
end
end
def
reload_code
self
.
reloaded_commits
self
.
reloaded_diffs
end
def
new?
today?
&&
created_at
==
updated_at
end
...
...
@@ -72,10 +81,19 @@ class MergeRequest < ActiveRecord::Base
commits
.
first
end
def
merged?
merged
&&
merge_event
end
def
merge_event
self
.
project
.
events
.
where
(
:target_id
=>
self
.
id
,
:target_type
=>
"MergeRequest"
,
:action
=>
Event
::
Merged
).
last
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)
def
upvotes
notes
.
select
(
&
:
upvote?
).
size
...
...
@@ -115,6 +133,17 @@ class MergeRequest < ActiveRecord::Base
sort_by
(
&
:
created_at
).
reverse
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
# == Schema Information
#
...
...
app/models/project.rb
View file @
2ec12c9b
...
...
@@ -80,35 +80,18 @@ class Project < ActiveRecord::Base
def
update_merge_requests
(
oldrev
,
newrev
,
ref
,
author_key_id
)
return
true
unless
ref
=~
/heads/
branch_name
=
ref
.
gsub
(
"refs/heads/"
,
""
)
key
=
Key
.
find_by_identifier
(
author_key_id
)
user
=
key
.
user
user
=
Key
.
find_by_identifier
(
author_key_id
).
user
c_ids
=
self
.
commits_between
(
oldrev
,
newrev
).
map
(
&
:id
)
# update commits & diffs for existing MR
mrs
=
self
.
merge_requests
.
opened
.
where
(
:source_branch
=>
branch_name
).
all
mrs
.
each
do
|
merge_request
|
merge_request
.
reloaded_commits
merge_request
.
reloaded_diffs
end
# Update code for merge requests
mrs
=
self
.
merge_requests
.
opened
.
find_all_by_branch
(
branch_name
).
all
mrs
.
each
{
|
merge_request
|
merge_request
.
reload_code
}
# Close merge requests
mrs
=
self
.
merge_requests
.
opened
.
where
(
:target_branch
=>
branch_name
).
all
mrs
.
each
do
|
merge_request
|
next
unless
merge_request
.
last_commit
# 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
mrs
=
mrs
.
select
(
&
:last_commit
).
select
{
|
mr
|
c_ids
.
include?
(
mr
.
last_commit
.
id
)
}
mrs
.
each
{
|
merge_request
|
merge_request
.
merge!
(
user
.
id
)
}
true
end
...
...
app/views/events/_event_changed_issue.html.haml
View file @
2ec12c9b
=
image_tag
gravatar_icon
(
event
.
author_email
),
:class
=>
"avatar"
%strong
#{
event
.
author_name
}
-
if
event
.
closed?
closed
-
else
reopened
issue
%span
.label.important
-
if
event
.
closed?
closed
-
else
reopened
issue
=
link_to
project_issue_path
(
event
.
project
,
event
.
issue
)
do
%strong
=
truncate
event
.
issue_title
at
...
...
app/views/events/_event_changed_merge_request.html.haml
View file @
2ec12c9b
=
image_tag
gravatar_icon
(
event
.
author_email
),
:class
=>
"avatar"
%strong
#{
event
.
author_name
}
-
if
event
.
closed?
closed
-
else
reopened
merge request
%span
.label.important
-
if
event
.
closed?
closed
-
else
reopened
merge request
=
link_to
project_merge_request_path
(
event
.
project
,
event
.
merge_request
)
do
%strong
=
truncate
event
.
merge_request_title
at
...
...
@@ -12,7 +13,6 @@ at
%span
.cgray
=
time_ago_in_words
(
event
.
created_at
)
ago.
%br
%span
.label
=
event
.
merge_request
.
source_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"
%strong
#{
event
.
author_name
}
created new issue
%span
.label.success
created
new issue
=
link_to
project_issue_path
(
event
.
project
,
event
.
issue
)
do
%strong
=
truncate
event
.
issue_title
at
...
...
app/views/events/_event_new_merge_request.html.haml
View file @
2ec12c9b
=
image_tag
gravatar_icon
(
event
.
author_email
),
:class
=>
"avatar"
%strong
#{
event
.
author_name
}
requested merge
%span
.label.success
requested
merge
=
link_to
project_merge_request_path
(
event
.
project
,
event
.
merge_request
)
do
%strong
=
truncate
event
.
merge_request_title
at
...
...
@@ -8,7 +9,6 @@ at
%span
.cgray
=
time_ago_in_words
(
event
.
created_at
)
ago.
%br
%span
.label
=
event
.
merge_request
.
source_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?
=
image_tag
gravatar_icon
(
event
.
author_email
),
:class
=>
"avatar"
%strong
#{
event
.
author_name
}
pushed new
%span
.label.pushed
pushed
new
-
if
event
.
new_tag?
tag
=
link_to
project_commits_path
(
event
.
project
,
:ref
=>
event
.
tag_name
)
do
...
...
@@ -18,7 +19,8 @@
-
else
=
image_tag
gravatar_icon
(
event
.
author_email
),
:class
=>
"avatar"
%strong
#{
event
.
author_name
}
pushed to
%span
.label.pushed
pushed
to
=
link_to
project_commits_path
(
event
.
project
,
:ref
=>
event
.
branch_name
)
do
%strong
=
event
.
branch_name
at
...
...
@@ -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
Compare
#{
event
.
commits
.
first
.
commit
.
id
[
0
..
8
]
}
...
#{
event
.
commits
.
last
.
id
[
0
..
8
]
}
-
@project
=
event
.
project
%ul
.unstyled
-
if
event
.
commits
.
size
>
4
=
render
event
.
commits
[
0
..
2
]
%li
... and
#{
event
.
commits
.
size
-
3
}
more commits
%ul
.unstyled
.event_commits
-
if
event
.
commits
.
size
>
3
=
render
event
.
commits
[
0
..
.
2
]
%li
... and
#{
event
.
commits
.
size
-
2
}
more commits
-
else
=
render
event
.
commits
...
...
app/views/issues/_show.html.haml
View file @
2ec12c9b
...
...
@@ -15,7 +15,7 @@
-
if
issue
.
today?
%span
.label.success
today
-
if
issue
.
notes
.
any?
%span
.label
=
pluralize
issue
.
notes
.
count
,
'note'
%span
.
pretty_
label
=
pluralize
issue
.
notes
.
count
,
'note'
-
if
issue
.
upvotes
>
0
%span
.label.success
=
"+
#{
issue
.
upvotes
}
"
...
...
app/views/merge_requests/_how_to_merge.html.haml
View file @
2ec12c9b
...
...
@@ -15,7 +15,7 @@
:javascript
$
(
function
(){
var
modal
=
$
(
'
#modal_merge_info
'
).
modal
({
modal
:
true
});
$
(
'
.
info
_link
'
).
bind
(
"
click
"
,
function
(){
$
(
'
.
how_to_merge
_link
'
).
bind
(
"
click
"
,
function
(){
modal
.
show
();
});
$
(
'
.modal-header .close
'
).
bind
(
"
click
"
,
function
(){
...
...
app/views/merge_requests/_merge_request.html.haml
View file @
2ec12c9b
...
...
@@ -6,7 +6,7 @@
=
time_ago_in_words
(
merge_request
.
created_at
)
ago
-
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
%span
.label.success
=
"+
#{
merge_request
.
upvotes
}
"
.right
...
...
app/views/merge_requests/show.html.haml
View file @
2ec12c9b
...
...
@@ -26,23 +26,23 @@
%hr
-
if
@merge_request
.
closed
.alert-message.error
C
losed
-
if
@merge_request
.
merged
-
event
=
@merge_request
.
merge_event
%div
%p
%strong
#{
event
.
author_name
}
merged this request
%span
.cgray
=
time_ago_in_words
(
event
.
created_at
)
ago.
%br
-
else
.alert-message.success
=
link_to
"#"
,
:class
=>
"info_link"
,
:title
=>
"How To Merge"
do
=
image_tag
"Info-UI.PNG"
Open
.merge_request_status_holder
-
if
@merge_request
.
c
losed
%h5
.alert-message.error.status_info
Closed
-
if
@merge_request
.
merged?
%span
Merged by
#{
@merge_request
.
merge_
event
.
author_name
}
%small
#{
time_ago_in_words
(
@merge_request
.
merge_event
.
created_at
)
}
ago.
-
elsif
@merge_request
.
closed_event
%span
Closed by
#{
@merge_request
.
closed_event
.
author_name
}
%small
#{
time_ago_in_words
(
@merge_request
.
closed_event
.
created_at
)
}
ago.
%br
-
else
%h5
.alert-message.success.status_info
Open
=
link_to
"How to merge"
,
"#"
,
:class
=>
"vlink how_to_merge_link"
,
:title
=>
"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