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
1353cff5
Commit
1353cff5
authored
Feb 01, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replaces "Create merge request" link with one to the MR when one exists
parent
10aa99a3
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
122 additions
and
9 deletions
+122
-9
CHANGELOG
CHANGELOG
+1
-0
app/controllers/projects/commits_controller.rb
app/controllers/projects/commits_controller.rb
+3
-0
app/controllers/projects/compare_controller.rb
app/controllers/projects/compare_controller.rb
+17
-6
app/models/merge_request.rb
app/models/merge_request.rb
+1
-0
app/views/projects/commits/show.html.haml
app/views/projects/commits/show.html.haml
+4
-1
app/views/projects/compare/_form.html.haml
app/views/projects/compare/_form.html.haml
+3
-2
features/project/commits/commits.feature
features/project/commits/commits.feature
+36
-0
features/steps/project/commits/commits.rb
features/steps/project/commits/commits.rb
+57
-0
No files found.
CHANGELOG
View file @
1353cff5
...
@@ -51,6 +51,7 @@ v 8.4.4
...
@@ -51,6 +51,7 @@ v 8.4.4
- Update omniauth-saml gem to 1.4.2
- Update omniauth-saml gem to 1.4.2
- Prevent long-running backup tasks from timing out the database connection
- Prevent long-running backup tasks from timing out the database connection
- Add a Project setting to allow guests to view build logs (defaults to true)
- Add a Project setting to allow guests to view build logs (defaults to true)
- Replaces "Create merge request" link with one to the "Merge Request" when one exists
v 8.4.3
v 8.4.3
- Increase lfs_objects size column to 8-byte integer to allow files larger
- Increase lfs_objects size column to 8-byte integer to allow files larger
...
...
app/controllers/projects/commits_controller.rb
View file @
1353cff5
...
@@ -21,6 +21,9 @@ class Projects::CommitsController < Projects::ApplicationController
...
@@ -21,6 +21,9 @@ class Projects::CommitsController < Projects::ApplicationController
@note_counts
=
project
.
notes
.
where
(
commit_id:
@commits
.
map
(
&
:id
)).
@note_counts
=
project
.
notes
.
where
(
commit_id:
@commits
.
map
(
&
:id
)).
group
(
:commit_id
).
count
group
(
:commit_id
).
count
@merge_request
=
@project
.
merge_requests
.
opened
.
find_by
(
source_project:
@project
,
source_branch:
@ref
,
target_branch:
@repository
.
root_ref
)
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
format
.
html
format
.
json
{
pager_json
(
"projects/commits/_commits"
,
@commits
.
size
)
}
format
.
json
{
pager_json
(
"projects/commits/_commits"
,
@commits
.
size
)
}
...
...
app/controllers/projects/compare_controller.rb
View file @
1353cff5
...
@@ -4,24 +4,23 @@ class Projects::CompareController < Projects::ApplicationController
...
@@ -4,24 +4,23 @@ class Projects::CompareController < Projects::ApplicationController
# Authorize
# Authorize
before_action
:require_non_empty_project
before_action
:require_non_empty_project
before_action
:authorize_download_code!
before_action
:authorize_download_code!
before_action
:assign_ref_vars
,
only:
[
:index
,
:show
]
before_action
:merge_request
,
only:
[
:index
,
:show
]
def
index
def
index
@ref
=
Addressable
::
URI
.
unescape
(
params
[
:to
])
end
end
def
show
def
show
base_ref
=
Addressable
::
URI
.
unescape
(
params
[
:from
])
@ref
=
head_ref
=
Addressable
::
URI
.
unescape
(
params
[
:to
])
diff_options
=
{
ignore_whitespace_change:
true
}
if
params
[
:w
]
==
'1'
diff_options
=
{
ignore_whitespace_change:
true
}
if
params
[
:w
]
==
'1'
compare_result
=
CompareService
.
new
.
compare_result
=
CompareService
.
new
.
execute
(
@project
,
head_ref
,
@project
,
base_ref
,
diff_options
)
execute
(
@project
,
@head_ref
,
@project
,
@
base_ref
,
diff_options
)
if
compare_result
if
compare_result
@commits
=
Commit
.
decorate
(
compare_result
.
commits
,
@project
)
@commits
=
Commit
.
decorate
(
compare_result
.
commits
,
@project
)
@diffs
=
compare_result
.
diffs
@diffs
=
compare_result
.
diffs
@commit
=
@project
.
commit
(
head_ref
)
@commit
=
@project
.
commit
(
@
head_ref
)
@base_commit
=
@project
.
merge_base_commit
(
base_ref
,
head_ref
)
@base_commit
=
@project
.
merge_base_commit
(
@base_ref
,
@
head_ref
)
@diff_refs
=
[
@base_commit
,
@commit
]
@diff_refs
=
[
@base_commit
,
@commit
]
@line_notes
=
[]
@line_notes
=
[]
end
end
...
@@ -31,4 +30,16 @@ class Projects::CompareController < Projects::ApplicationController
...
@@ -31,4 +30,16 @@ class Projects::CompareController < Projects::ApplicationController
redirect_to
namespace_project_compare_path
(
@project
.
namespace
,
@project
,
redirect_to
namespace_project_compare_path
(
@project
.
namespace
,
@project
,
params
[
:from
],
params
[
:to
])
params
[
:from
],
params
[
:to
])
end
end
private
def
assign_ref_vars
@base_ref
=
Addressable
::
URI
.
unescape
(
params
[
:from
])
@ref
=
@head_ref
=
Addressable
::
URI
.
unescape
(
params
[
:to
])
end
def
merge_request
@merge_request
||=
@project
.
merge_requests
.
opened
.
find_by
(
source_project:
@project
,
source_branch:
@head_ref
,
target_branch:
@base_ref
)
end
end
end
app/models/merge_request.rb
View file @
1353cff5
...
@@ -137,6 +137,7 @@ class MergeRequest < ActiveRecord::Base
...
@@ -137,6 +137,7 @@ class MergeRequest < ActiveRecord::Base
scope
:by_milestone
,
->
(
milestone
)
{
where
(
milestone_id:
milestone
)
}
scope
:by_milestone
,
->
(
milestone
)
{
where
(
milestone_id:
milestone
)
}
scope
:in_projects
,
->
(
project_ids
)
{
where
(
"source_project_id in (:project_ids) OR target_project_id in (:project_ids)"
,
project_ids:
project_ids
)
}
scope
:in_projects
,
->
(
project_ids
)
{
where
(
"source_project_id in (:project_ids) OR target_project_id in (:project_ids)"
,
project_ids:
project_ids
)
}
scope
:of_projects
,
->
(
ids
)
{
where
(
target_project_id:
ids
)
}
scope
:of_projects
,
->
(
ids
)
{
where
(
target_project_id:
ids
)
}
scope
:opened
,
->
{
with_state
(
:opened
)
}
scope
:merged
,
->
{
with_state
(
:merged
)
}
scope
:merged
,
->
{
with_state
(
:merged
)
}
scope
:closed
,
->
{
with_state
(
:closed
)
}
scope
:closed
,
->
{
with_state
(
:closed
)
}
scope
:closed_and_merged
,
->
{
with_states
(
:closed
,
:merged
)
}
scope
:closed_and_merged
,
->
{
with_states
(
:closed
,
:merged
)
}
...
...
app/views/projects/commits/show.html.haml
View file @
1353cff5
...
@@ -11,7 +11,10 @@
...
@@ -11,7 +11,10 @@
=
render
'shared/ref_switcher'
,
destination:
'commits'
=
render
'shared/ref_switcher'
,
destination:
'commits'
.block-controls.hidden-xs.hidden-sm
.block-controls.hidden-xs.hidden-sm
-
if
create_mr_button?
(
@repository
.
root_ref
,
@ref
)
-
if
@merge_request
.
present?
.control
=
link_to
"View
#{
@merge_request
.
to_reference
}
"
,
namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
),
class:
'btn btn-success'
-
elsif
create_mr_button?
(
@repository
.
root_ref
,
@ref
)
.control
.control
=
link_to
create_mr_path
(
@repository
.
root_ref
,
@ref
),
class:
'btn btn-success'
do
=
link_to
create_mr_path
(
@repository
.
root_ref
,
@ref
),
class:
'btn btn-success'
do
=
icon
(
'plus'
)
=
icon
(
'plus'
)
...
...
app/views/projects/compare/_form.html.haml
View file @
1353cff5
...
@@ -13,12 +13,13 @@
...
@@ -13,12 +13,13 @@
=
text_field_tag
:to
,
params
[
:to
],
class:
"form-control"
,
required:
true
=
text_field_tag
:to
,
params
[
:to
],
class:
"form-control"
,
required:
true
=
button_tag
"Compare"
,
class:
"btn btn-create commits-compare-btn"
=
button_tag
"Compare"
,
class:
"btn btn-create commits-compare-btn"
-
if
create_mr_button?
-
if
@merge_request
.
present?
=
link_to
"View
#{
@merge_request
.
to_reference
}
"
,
namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
),
class:
'prepend-left-10 btn'
-
elsif
create_mr_button?
=
link_to
create_mr_path
,
class:
'prepend-left-10 btn'
do
=
link_to
create_mr_path
,
class:
'prepend-left-10 btn'
do
=
icon
(
"plus"
)
=
icon
(
"plus"
)
Create Merge Request
Create Merge Request
:javascript
:javascript
var
availableTags
=
#{
@project
.
repository
.
ref_names
.
to_json
}
;
var
availableTags
=
#{
@project
.
repository
.
ref_names
.
to_json
}
;
...
...
features/project/commits/commits.feature
View file @
1353cff5
...
@@ -7,6 +7,26 @@ Feature: Project Commits
...
@@ -7,6 +7,26 @@ Feature: Project Commits
Scenario
:
I
browse commits list for master branch
Scenario
:
I
browse commits list for master branch
Then
I see project commits
Then
I see project commits
And
I should not see button to create a new merge request
Then
I click the
"Compare"
tab
And
I should not see button to create a new merge request
Scenario
:
I
browse commits list for feature branch without a merge request
Given
I visit commits list page for feature branch
Then
I see feature branch commits
And
I see button to create a new merge request
Then
I click the
"Compare"
tab
And
I see button to create a new merge request
Scenario
:
I
browse commits list for feature branch with an open merge request
Given
project have an open merge request
And
I visit commits list page for feature branch
Then
I see feature branch commits
And
I should not see button to create a new merge request
And
I should see button to the merge request
Then
I click the
"Compare"
tab
And
I should not see button to create a new merge request
And
I should see button to the merge request
Scenario
:
I
browse atom feed of commits list for master branch
Scenario
:
I
browse atom feed of commits list for master branch
Given
I click atom feed link
Given
I click atom feed link
...
@@ -30,6 +50,22 @@ Feature: Project Commits
...
@@ -30,6 +50,22 @@ Feature: Project Commits
And
I click side-by-side diff button
And
I click side-by-side diff button
Then
I see inline diff button
Then
I see inline diff button
@javascript
Scenario
:
I
compare branches without a merge request
Given
I visit compare refs page
And
I fill compare fields with branches
Then
I see compared branches
And
I see button to create a new merge request
@javascript
Scenario
:
I
compare branches with an open merge request
Given
project have an open merge request
And
I visit compare refs page
And
I fill compare fields with branches
Then
I see compared branches
And
I should not see button to create a new merge request
And
I should see button to the merge request
@javascript
@javascript
Scenario
:
I
compare refs
Scenario
:
I
compare refs
Given
I visit compare refs page
Given
I visit compare refs page
...
...
features/steps/project/commits/commits.rb
View file @
1353cff5
...
@@ -33,6 +33,13 @@ class Spinach::Features::ProjectCommits < Spinach::FeatureSteps
...
@@ -33,6 +33,13 @@ class Spinach::Features::ProjectCommits < Spinach::FeatureSteps
expect
(
page
).
to
have_content
"Showing
#{
sample_commit
.
files_changed_count
}
changed files"
expect
(
page
).
to
have_content
"Showing
#{
sample_commit
.
files_changed_count
}
changed files"
end
end
step
'I fill compare fields with branches'
do
fill_in
'from'
,
with:
'feature'
fill_in
'to'
,
with:
'master'
click_button
'Compare'
end
step
'I fill compare fields with refs'
do
step
'I fill compare fields with refs'
do
fill_in
"from"
,
with:
sample_commit
.
parent_id
fill_in
"from"
,
with:
sample_commit
.
parent_id
fill_in
"to"
,
with:
sample_commit
.
id
fill_in
"to"
,
with:
sample_commit
.
id
...
@@ -56,6 +63,56 @@ class Spinach::Features::ProjectCommits < Spinach::FeatureSteps
...
@@ -56,6 +63,56 @@ class Spinach::Features::ProjectCommits < Spinach::FeatureSteps
expect
(
page
).
to
have_content
"Showing 2 changed files"
expect
(
page
).
to
have_content
"Showing 2 changed files"
end
end
step
'I visit commits list page for feature branch'
do
visit
namespace_project_commits_path
(
@project
.
namespace
,
@project
,
'feature'
,
{
limit:
5
})
end
step
'I see feature branch commits'
do
commit
=
@project
.
repository
.
commit
(
'0b4bc9a'
)
expect
(
page
).
to
have_content
(
@project
.
name
)
expect
(
page
).
to
have_content
(
commit
.
message
[
0
..
12
])
expect
(
page
).
to
have_content
(
commit
.
short_id
)
end
step
'project have an open merge request'
do
create
(
:merge_request
,
title:
'Feature'
,
source_project:
@project
,
source_branch:
'feature'
,
target_branch:
'master'
,
author:
@project
.
users
.
first
)
end
step
'I click the "Compare" tab'
do
click_link
(
'Compare'
)
end
step
'I fill compare fields with branches'
do
fill_in
'from'
,
with:
'master'
fill_in
'to'
,
with:
'feature'
click_button
'Compare'
end
step
'I see compared branches'
do
expect
(
page
).
to
have_content
'Commits (1)'
expect
(
page
).
to
have_content
'Showing 1 changed file with 5 additions and 0 deletions'
end
step
'I see button to create a new merge request'
do
expect
(
page
).
to
have_link
'Create Merge Request'
end
step
'I should not see button to create a new merge request'
do
expect
(
page
).
to_not
have_link
'Create Merge Request'
end
step
'I should see button to the merge request'
do
merge_request
=
MergeRequest
.
find_by
(
title:
'Feature'
)
expect
(
page
).
to
have_link
"View
#{
merge_request
.
to_reference
}
"
,
href:
namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
merge_request
)
end
step
'I see breadcrumb links'
do
step
'I see breadcrumb links'
do
expect
(
page
).
to
have_selector
(
'ul.breadcrumb'
)
expect
(
page
).
to
have_selector
(
'ul.breadcrumb'
)
expect
(
page
).
to
have_selector
(
'ul.breadcrumb a'
,
count:
4
)
expect
(
page
).
to
have_selector
(
'ul.breadcrumb a'
,
count:
4
)
...
...
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