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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
17ed42e3
Commit
17ed42e3
authored
Dec 21, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'issue_3452'
parents
1be8a3e0
c43fbaab
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
79 additions
and
0 deletions
+79
-0
CHANGELOG
CHANGELOG
+1
-0
app/models/ci/build.rb
app/models/ci/build.rb
+10
-0
app/views/projects/builds/show.html.haml
app/views/projects/builds/show.html.haml
+4
-0
spec/models/build_spec.rb
spec/models/build_spec.rb
+64
-0
No files found.
CHANGELOG
View file @
17ed42e3
...
@@ -4,6 +4,7 @@ v 8.3.0 (unreleased)
...
@@ -4,6 +4,7 @@ v 8.3.0 (unreleased)
- Add CAS support (tduehr)
- Add CAS support (tduehr)
- Bump rack-attack to 4.3.1 for security fix (Stan Hu)
- Bump rack-attack to 4.3.1 for security fix (Stan Hu)
- API support for starred projects for authorized user (Zeger-Jan van de Weg)
- API support for starred projects for authorized user (Zeger-Jan van de Weg)
- Add link to merge request on build detail page.
- Add open_issues_count to project API (Stan Hu)
- Add open_issues_count to project API (Stan Hu)
- Expand character set of usernames created by Omniauth (Corey Hinshaw)
- Expand character set of usernames created by Omniauth (Corey Hinshaw)
- Add button to automatically merge a merge request when the build succeeds (Zeger-Jan van de Weg)
- Add button to automatically merge a merge request when the build succeeds (Zeger-Jan van de Weg)
...
...
app/models/ci/build.rb
View file @
17ed42e3
...
@@ -135,6 +135,16 @@ module Ci
...
@@ -135,6 +135,16 @@ module Ci
predefined_variables
+
yaml_variables
+
project_variables
+
trigger_variables
predefined_variables
+
yaml_variables
+
project_variables
+
trigger_variables
end
end
def
merge_request
merge_requests
=
MergeRequest
.
includes
(
:merge_request_diff
)
.
where
(
source_branch:
ref
,
source_project_id:
commit
.
gl_project_id
)
.
reorder
(
iid: :asc
)
merge_requests
.
find
do
|
merge_request
|
merge_request
.
commits
.
any?
{
|
ci
|
ci
.
id
==
commit
.
sha
}
end
end
def
project
def
project
commit
.
project
commit
.
project
end
end
...
...
app/views/projects/builds/show.html.haml
View file @
17ed42e3
...
@@ -7,6 +7,10 @@
...
@@ -7,6 +7,10 @@
%strong
.monospace
=
link_to
@build
.
commit
.
short_sha
,
ci_status_path
(
@build
.
commit
)
%strong
.monospace
=
link_to
@build
.
commit
.
short_sha
,
ci_status_path
(
@build
.
commit
)
from
from
=
link_to
@build
.
ref
,
namespace_project_commits_path
(
@project
.
namespace
,
@project
,
@build
.
ref
)
=
link_to
@build
.
ref
,
namespace_project_commits_path
(
@project
.
namespace
,
@project
,
@build
.
ref
)
-
merge_request
=
@build
.
merge_request
-
if
merge_request
via
=
link_to
"merge request #
#{
merge_request
.
iid
}
"
,
merge_request_path
(
merge_request
)
#up-build-trace
#up-build-trace
-
if
@commit
.
matrix_for_ref?
(
@build
.
ref
)
-
if
@commit
.
matrix_for_ref?
(
@build
.
ref
)
...
...
spec/models/build_spec.rb
View file @
17ed42e3
...
@@ -396,4 +396,68 @@ describe Ci::Build, models: true do
...
@@ -396,4 +396,68 @@ describe Ci::Build, models: true do
it
{
is_expected
.
to
include
(
'gitlab-ci-token'
)
}
it
{
is_expected
.
to
include
(
'gitlab-ci-token'
)
}
it
{
is_expected
.
to
include
(
project
.
web_url
[
7
..-
1
])
}
it
{
is_expected
.
to
include
(
project
.
web_url
[
7
..-
1
])
}
end
end
def
create_mr
(
build
,
commit
,
factory: :merge_request
,
created_at:
Time
.
now
)
FactoryGirl
.
create
(
factory
,
source_project_id:
commit
.
gl_project_id
,
target_project_id:
commit
.
gl_project_id
,
source_branch:
build
.
ref
,
created_at:
created_at
)
end
describe
:merge_request
do
context
'when a MR has a reference to the commit'
do
before
do
@merge_request
=
create_mr
(
build
,
commit
,
factory: :merge_request
)
commits
=
[
double
(
id:
commit
.
sha
)]
allow
(
@merge_request
).
to
receive
(
:commits
).
and_return
(
commits
)
allow
(
MergeRequest
).
to
receive_message_chain
(
:includes
,
:where
,
:reorder
).
and_return
([
@merge_request
])
end
it
'returns the single associated MR'
do
expect
(
build
.
merge_request
.
id
).
to
eq
(
@merge_request
.
id
)
end
end
context
'when there is not a MR referencing the commit'
do
it
'returns nil'
do
expect
(
build
.
merge_request
).
to
be_nil
end
end
context
'when more than one MR have a reference to the commit'
do
before
do
@merge_request
=
create_mr
(
build
,
commit
,
factory: :merge_request
)
@merge_request
.
close!
@merge_request2
=
create_mr
(
build
,
commit
,
factory: :merge_request
)
commits
=
[
double
(
id:
commit
.
sha
)]
allow
(
@merge_request
).
to
receive
(
:commits
).
and_return
(
commits
)
allow
(
@merge_request2
).
to
receive
(
:commits
).
and_return
(
commits
)
allow
(
MergeRequest
).
to
receive_message_chain
(
:includes
,
:where
,
:reorder
).
and_return
([
@merge_request
,
@merge_request2
])
end
it
'returns the first MR'
do
expect
(
build
.
merge_request
.
id
).
to
eq
(
@merge_request
.
id
)
end
end
context
'when a Build is created after the MR'
do
before
do
@merge_request
=
create_mr
(
build
,
commit
,
factory: :merge_request_with_diffs
)
commit2
=
FactoryGirl
.
create
:ci_commit
,
project:
project
@build2
=
FactoryGirl
.
create
:ci_build
,
commit:
commit2
commits
=
[
double
(
id:
commit
.
sha
),
double
(
id:
commit2
.
sha
)]
allow
(
@merge_request
).
to
receive
(
:commits
).
and_return
(
commits
)
allow
(
MergeRequest
).
to
receive_message_chain
(
:includes
,
:where
,
:reorder
).
and_return
([
@merge_request
])
end
it
'returns the current MR'
do
expect
(
@build2
.
merge_request
.
id
).
to
eq
(
@merge_request
.
id
)
end
end
end
end
end
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