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
ca936d27
Commit
ca936d27
authored
Dec 11, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve CI integration for merge requests
parent
c92726e6
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
83 additions
and
12 deletions
+83
-12
app/assets/javascripts/merge_requests.js
app/assets/javascripts/merge_requests.js
+11
-0
app/assets/stylesheets/sections/merge_requests.scss
app/assets/stylesheets/sections/merge_requests.scss
+0
-6
app/controllers/merge_requests_controller.rb
app/controllers/merge_requests_controller.rb
+8
-1
app/helpers/merge_requests_helper.rb
app/helpers/merge_requests_helper.rb
+2
-2
app/models/gitlab_ci_service.rb
app/models/gitlab_ci_service.rb
+18
-0
app/models/merge_request.rb
app/models/merge_request.rb
+4
-0
app/views/merge_requests/_show.html.haml
app/views/merge_requests/_show.html.haml
+4
-0
app/views/merge_requests/show/_mr_box.html.haml
app/views/merge_requests/show/_mr_box.html.haml
+0
-3
app/views/merge_requests/show/_mr_ci.html.haml
app/views/merge_requests/show/_mr_ci.html.haml
+35
-0
config/routes.rb
config/routes.rb
+1
-0
No files found.
app/assets/javascripts/merge_requests.js
View file @
ca936d27
...
...
@@ -26,6 +26,12 @@ var MergeRequest = {
self
.
showState
(
data
.
state
);
},
"
json
"
);
}
if
(
self
.
opts
.
ci_enable
){
$
.
get
(
self
.
opts
.
url_to_ci_check
,
function
(
data
){
self
.
showCiState
(
data
.
status
);
},
"
json
"
);
}
},
initTabs
:
...
...
@@ -79,6 +85,11 @@ var MergeRequest = {
$
(
"
.automerge_widget.
"
+
state
).
show
();
},
showCiState
:
function
(
state
){
$
(
"
.ci_widget
"
).
hide
();
$
(
"
.ci_widget.ci-
"
+
state
).
show
();
},
loadDiff
:
function
()
{
...
...
app/assets/stylesheets/sections/merge_requests.scss
View file @
ca936d27
...
...
@@ -136,9 +136,3 @@ li.merge_request {
}
}
}
.status-badge
{
height
:
32px
;
width
:
100%
;
@include
border-radius
(
5px
);
}
app/controllers/merge_requests_controller.rb
View file @
ca936d27
class
MergeRequestsController
<
ProjectResourceController
before_filter
:module_enabled
before_filter
:merge_request
,
only:
[
:edit
,
:update
,
:destroy
,
:show
,
:commits
,
:diffs
,
:automerge
,
:automerge_check
]
before_filter
:merge_request
,
only:
[
:edit
,
:update
,
:destroy
,
:show
,
:commits
,
:diffs
,
:automerge
,
:automerge_check
,
:ci_status
]
before_filter
:validates_merge_request
,
only:
[
:show
,
:diffs
]
before_filter
:define_show_vars
,
only:
[
:show
,
:diffs
]
...
...
@@ -103,6 +103,13 @@ class MergeRequestsController < ProjectResourceController
@commit
=
CommitDecorator
.
decorate
(
@commit
)
end
def
ci_status
status
=
project
.
gitlab_ci_service
.
commit_status
(
merge_request
.
last_commit
.
sha
)
response
=
{
status:
status
}
render
json:
response
end
protected
def
merge_request
...
...
app/helpers/merge_requests_helper.rb
View file @
ca936d27
...
...
@@ -39,7 +39,7 @@ module MergeRequestsHelper
classes
end
def
ci_
status_path
@project
.
gitlab_ci_service
.
commit_badge_path
(
@
merge_request
.
last_commit
.
sha
)
def
ci_
build_details_path
merge_request
merge_request
.
project
.
gitlab_ci_service
.
build_page
(
merge_request
.
last_commit
.
sha
)
end
end
app/models/gitlab_ci_service.rb
View file @
ca936d27
...
...
@@ -36,4 +36,22 @@ class GitlabCiService < Service
def
commit_badge_path
sha
project_url
+
"/status?sha=
#{
sha
}
"
end
def
commit_status_path
sha
project_url
+
"/builds/
#{
sha
}
/status.json?token=
#{
token
}
"
end
def
commit_status
sha
response
=
HTTParty
.
get
(
commit_status_path
(
sha
))
if
response
.
code
==
200
and
response
[
"status"
]
response
[
"status"
]
else
:error
end
end
def
build_page
sha
project_url
+
"/builds/
#{
sha
}
"
end
end
app/models/merge_request.rb
View file @
ca936d27
...
...
@@ -220,4 +220,8 @@ class MergeRequest < ActiveRecord::Base
def
to_patch
project
.
repo
.
git
.
format_patch
({
timeout:
30
,
raise:
true
,
stdout:
true
},
"
#{
target_branch
}
..
#{
source_branch
}
"
)
end
def
last_commit_short_sha
@last_commit_short_sha
||=
last_commit
.
sha
[
0
..
10
]
end
end
app/views/merge_requests/_show.html.haml
View file @
ca936d27
...
...
@@ -2,6 +2,8 @@
=
render
"merge_requests/show/how_to_merge"
=
render
"merge_requests/show/mr_box"
=
render
"merge_requests/show/mr_accept"
-
if
@project
.
gitlab_ci?
=
render
"merge_requests/show/mr_ci"
=
render
"merge_requests/show/commits"
-
if
@commits
.
present?
...
...
@@ -28,6 +30,8 @@
MergeRequest
.
init
({
url_to_automerge_check
:
"
#{
automerge_check_project_merge_request_path
(
@project
,
@merge_request
)
}
"
,
check_enable
:
#{
@merge_request
.
state
==
MergeRequest
::
UNCHECKED
?
"true"
:
"false"
}
,
url_to_ci_check
:
"
#{
ci_status_project_merge_request_path
(
@project
,
@merge_request
)
}
"
,
ci_enable
:
#{
@project
.
gitlab_ci?
?
"true"
:
"false"
}
,
current_state
:
"
#{
@merge_request
.
human_state
}
"
,
action
:
"
#{
controller
.
action_name
}
"
});
...
...
app/views/merge_requests/show/_mr_box.html.haml
View file @
ca936d27
...
...
@@ -6,9 +6,6 @@
-
else
.alert-message.success.status_info
Open
=
gfm
escape_once
(
@merge_request
.
title
)
-
if
@project
.
gitlab_ci?
.right
=
image_tag
ci_status_path
,
class:
'status-badge'
.middle_box_content
%div
...
...
app/views/merge_requests/show/_mr_ci.html.haml
0 → 100644
View file @
ca936d27
-
if
@merge_request
.
open?
&&
@commits
.
any?
.ci_widget.ci-success
{
style:
"display:none"
}
.alert.alert-success
%i
.icon-ok
%strong
CI build passed
for
#{
@merge_request
.
last_commit_short_sha
}
.
=
link_to
"Build page"
,
ci_build_details_path
(
@merge_request
)
.ci_widget.ci-failed
{
style:
"display:none"
}
.alert.alert-error
%i
.icon-remove
%strong
CI build failed
for
#{
@merge_request
.
last_commit_short_sha
}
.
=
link_to
"Build page"
,
ci_build_details_path
(
@merge_request
)
-
[
:running
,
:pending
].
each
do
|
status
|
.ci_widget
{
class:
"ci-#{status}"
,
style:
"display:none"
}
.alert
%i
.icon-time
%strong
CI build
#{
status
}
for
#{
@merge_request
.
last_commit_short_sha
}
.
=
link_to
"Build page"
,
ci_build_details_path
(
@merge_request
)
.ci_widget
.alert-message
%strong
%i
.icon-refresh
Checking for CI status for
#{
@merge_request
.
last_commit_short_sha
}
.ci_widget.ci-error
{
style:
"display:none"
}
.alert.alert-error
%i
.icon-remove
%strong
Cannot connect to CI server. Please check your setting
config/routes.rb
View file @
ca936d27
...
...
@@ -169,6 +169,7 @@ Gitlab::Application.routes.draw do
get
:diffs
get
:automerge
get
:automerge_check
get
:ci_status
end
collection
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