Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
82f19211
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
82f19211
编写于
10月 01, 2015
作者:
D
Dmitriy Zaporozhets
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'mr_improve_errors_handling'
上级
58036d68
05fdd12f
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
33 addition
and
6 deletion
+33
-6
CHANGELOG
CHANGELOG
+1
-0
app/assets/javascripts/merge_request_widget.js.coffee
app/assets/javascripts/merge_request_widget.js.coffee
+6
-5
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+1
-0
app/services/merge_requests/merge_service.rb
app/services/merge_requests/merge_service.rb
+4
-0
db/migrate/20150930001110_merge_request_error_field.rb
db/migrate/20150930001110_merge_request_error_field.rb
+5
-0
db/schema.rb
db/schema.rb
+2
-1
spec/services/merge_requests/merge_service_spec.rb
spec/services/merge_requests/merge_service_spec.rb
+14
-0
未找到文件。
CHANGELOG
浏览文件 @
82f19211
...
...
@@ -20,6 +20,7 @@ v 8.1.0 (unreleased)
- Move CI project settings page to CE project settings area
- Fix bug when removed file was not appearing in merge request diff
- Note the original location of a moved project when notifying users of the move
- Improve error message when merging fails
v 8.0.3
- Fix URL shown in Slack notifications
...
...
app/assets/javascripts/merge_request_widget.js.coffee
浏览文件 @
82f19211
...
...
@@ -15,11 +15,12 @@ class @MergeRequestWidget
type
:
'GET'
url
:
$
(
'.merge-request'
).
data
(
'url'
)
success
:
(
data
)
=>
switch
data
.
state
when
'merged'
location
.
reload
()
else
setTimeout
(
merge_request_widget
.
mergeInProgress
,
2000
)
if
data
.
state
==
"merged"
location
.
reload
()
else
if
data
.
merge_error
$
(
'.mr-widget-body'
).
html
(
"<h4>"
+
data
.
merge_error
+
"</h4>"
)
else
setTimeout
(
merge_request_widget
.
mergeInProgress
,
2000
)
dataType
:
'json'
getMergeStatus
:
->
...
...
app/controllers/projects/merge_requests_controller.rb
浏览文件 @
82f19211
...
...
@@ -150,6 +150,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
return
access_denied!
unless
@merge_request
.
can_be_merged_by?
(
current_user
)
if
@merge_request
.
mergeable?
@merge_request
.
update
(
merge_error:
nil
)
MergeWorker
.
perform_async
(
@merge_request
.
id
,
current_user
.
id
,
params
)
@status
=
true
else
...
...
app/services/merge_requests/merge_service.rb
浏览文件 @
82f19211
...
...
@@ -38,6 +38,10 @@ module MergeRequests
}
repository
.
merge
(
current_user
,
merge_request
.
source_sha
,
merge_request
.
target_branch
,
options
)
rescue
Exception
=>
e
merge_request
.
update
(
merge_error:
"Something went wrong during merge"
)
Rails
.
logger
.
error
(
e
.
message
)
return
false
end
def
after_merge
...
...
db/migrate/20150930001110_merge_request_error_field.rb
0 → 100644
浏览文件 @
82f19211
class
MergeRequestErrorField
<
ActiveRecord
::
Migration
def
up
add_column
:merge_requests
,
:merge_error
,
:string
end
end
db/schema.rb
浏览文件 @
82f19211
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
201509300
95736
)
do
ActiveRecord
::
Schema
.
define
(
version:
201509300
01110
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
...
...
@@ -453,6 +453,7 @@ ActiveRecord::Schema.define(version: 20150930095736) do
t
.
integer
"position"
,
default:
0
t
.
datetime
"locked_at"
t
.
integer
"updated_by_id"
t
.
string
"merge_error"
end
add_index
"merge_requests"
,
[
"assignee_id"
],
name:
"index_merge_requests_on_assignee_id"
,
using: :btree
...
...
spec/services/merge_requests/merge_service_spec.rb
浏览文件 @
82f19211
...
...
@@ -35,5 +35,19 @@ describe MergeRequests::MergeService do
expect
(
note
.
note
).
to
include
'Status changed to merged'
end
end
context
"error handling"
do
let
(
:service
)
{
MergeRequests
::
MergeService
.
new
(
project
,
user
,
{})
}
it
'saves error if there is an exception'
do
allow
(
service
).
to
receive
(
:repository
).
and_raise
(
"error"
)
allow
(
service
).
to
receive
(
:execute_hooks
)
service
.
execute
(
merge_request
,
'Awesome message'
)
expect
(
merge_request
.
merge_error
).
to
eq
(
"Something went wrong during merge"
)
end
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录