Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
6eeb6384
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,发现更多精彩内容 >>
提交
6eeb6384
编写于
7月 11, 2017
作者:
C
Clement Ho
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make commits behind text a link to the target branch commits page
上级
09193a4f
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
46 addition
and
7 deletion
+46
-7
app/assets/javascripts/vue_merge_request_widget/components/mr_widget_header.js
...s/vue_merge_request_widget/components/mr_widget_header.js
+2
-2
app/assets/javascripts/vue_merge_request_widget/stores/mr_widget_store.js
...cripts/vue_merge_request_widget/stores/mr_widget_store.js
+2
-1
app/presenters/merge_request_presenter.rb
app/presenters/merge_request_presenter.rb
+6
-0
app/serializers/merge_request_entity.rb
app/serializers/merge_request_entity.rb
+4
-0
spec/fixtures/api/schemas/entities/merge_request.json
spec/fixtures/api/schemas/entities/merge_request.json
+1
-0
spec/javascripts/vue_mr_widget/components/mr_widget_header_spec.js
...scripts/vue_mr_widget/components/mr_widget_header_spec.js
+5
-2
spec/presenters/merge_request_presenter_spec.rb
spec/presenters/merge_request_presenter_spec.rb
+24
-0
spec/serializers/merge_request_entity_spec.rb
spec/serializers/merge_request_entity_spec.rb
+2
-2
未找到文件。
app/assets/javascripts/vue_merge_request_widget/components/mr_widget_header.js
浏览文件 @
6eeb6384
...
@@ -92,13 +92,13 @@ export default {
...
@@ -92,13 +92,13 @@ export default {
:class="{'label-truncated has-tooltip': isBranchTitleLong(mr.targetBranch)}"
:class="{'label-truncated has-tooltip': isBranchTitleLong(mr.targetBranch)}"
:title="isBranchTitleLong(mr.targetBranch) ? mr.targetBranch : ''"
:title="isBranchTitleLong(mr.targetBranch) ? mr.targetBranch : ''"
data-placement="bottom">
data-placement="bottom">
<a :href="mr.targetBranchPath">{{mr.targetBranch}}</a>
<a :href="mr.targetBranch
Tree
Path">{{mr.targetBranch}}</a>
</span>
</span>
</strong>
</strong>
<span
<span
v-if="shouldShowCommitsBehindText"
v-if="shouldShowCommitsBehindText"
class="diverged-commits-count">
class="diverged-commits-count">
(
{{mr.divergedCommitsCount}} {{commitsText}} behind
)
(
<a :href="mr.targetBranchPath">{{mr.divergedCommitsCount}} {{commitsText}} behind</a>
)
</span>
</span>
</div>
</div>
</div>
</div>
...
...
app/assets/javascripts/vue_merge_request_widget/stores/mr_widget_store.js
浏览文件 @
6eeb6384
...
@@ -47,7 +47,8 @@ export default class MergeRequestStore {
...
@@ -47,7 +47,8 @@ export default class MergeRequestStore {
this
.
sourceBranchPath
=
data
.
source_branch_path
;
this
.
sourceBranchPath
=
data
.
source_branch_path
;
this
.
sourceBranchLink
=
data
.
source_branch_with_namespace_link
;
this
.
sourceBranchLink
=
data
.
source_branch_with_namespace_link
;
this
.
mergeError
=
data
.
merge_error
;
this
.
mergeError
=
data
.
merge_error
;
this
.
targetBranchPath
=
data
.
target_branch_tree_path
;
this
.
targetBranchPath
=
data
.
target_branch_commits_path
;
this
.
targetBranchTreePath
=
data
.
target_branch_tree_path
;
this
.
conflictResolutionPath
=
data
.
conflict_resolution_path
;
this
.
conflictResolutionPath
=
data
.
conflict_resolution_path
;
this
.
cancelAutoMergePath
=
data
.
cancel_merge_when_pipeline_succeeds_path
;
this
.
cancelAutoMergePath
=
data
.
cancel_merge_when_pipeline_succeeds_path
;
this
.
removeWIPPath
=
data
.
remove_wip_path
;
this
.
removeWIPPath
=
data
.
remove_wip_path
;
...
...
app/presenters/merge_request_presenter.rb
浏览文件 @
6eeb6384
...
@@ -82,6 +82,12 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated
...
@@ -82,6 +82,12 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated
end
end
end
end
def
target_branch_commits_path
if
target_branch_exists?
project_commits_path
(
project
,
target_branch
)
end
end
def
source_branch_path
def
source_branch_path
if
source_branch_exists?
if
source_branch_exists?
project_branch_path
(
source_project
,
source_branch
)
project_branch_path
(
source_project
,
source_branch
)
...
...
app/serializers/merge_request_entity.rb
浏览文件 @
6eeb6384
...
@@ -93,6 +93,10 @@ class MergeRequestEntity < IssuableEntity
...
@@ -93,6 +93,10 @@ class MergeRequestEntity < IssuableEntity
# Paths
# Paths
#
#
expose
:target_branch_commits_path
do
|
merge_request
|
presenter
(
merge_request
).
target_branch_commits_path
end
expose
:target_branch_tree_path
do
|
merge_request
|
expose
:target_branch_tree_path
do
|
merge_request
|
presenter
(
merge_request
).
target_branch_tree_path
presenter
(
merge_request
).
target_branch_tree_path
end
end
...
...
spec/fixtures/api/schemas/entities/merge_request.json
浏览文件 @
6eeb6384
...
@@ -74,6 +74,7 @@
...
@@ -74,6 +74,7 @@
},
},
"additionalProperties"
:
false
"additionalProperties"
:
false
},
},
"target_branch_commits_path"
:
{
"type"
:
"string"
},
"target_branch_tree_path"
:
{
"type"
:
"string"
},
"target_branch_tree_path"
:
{
"type"
:
"string"
},
"source_branch_path"
:
{
"type"
:
"string"
},
"source_branch_path"
:
{
"type"
:
"string"
},
"conflict_resolution_path"
:
{
"type"
:
[
"string"
,
"null"
]
},
"conflict_resolution_path"
:
{
"type"
:
[
"string"
,
"null"
]
},
...
...
spec/javascripts/vue_mr_widget/components/mr_widget_header_spec.js
浏览文件 @
6eeb6384
...
@@ -54,6 +54,7 @@ describe('MRWidgetHeader', () => {
...
@@ -54,6 +54,7 @@ describe('MRWidgetHeader', () => {
sourceBranch
:
'
mr-widget-refactor
'
,
sourceBranch
:
'
mr-widget-refactor
'
,
sourceBranchLink
:
`<a href="
${
sourceBranchPath
}
">mr-widget-refactor</a>`
,
sourceBranchLink
:
`<a href="
${
sourceBranchPath
}
">mr-widget-refactor</a>`
,
targetBranchPath
:
'
foo/bar/commits-path
'
,
targetBranchPath
:
'
foo/bar/commits-path
'
,
targetBranchTreePath
:
'
foo/bar/tree/path
'
,
targetBranch
:
'
master
'
,
targetBranch
:
'
master
'
,
isOpen
:
true
,
isOpen
:
true
,
emailPatchesPath
:
'
/mr/email-patches
'
,
emailPatchesPath
:
'
/mr/email-patches
'
,
...
@@ -69,12 +70,14 @@ describe('MRWidgetHeader', () => {
...
@@ -69,12 +70,14 @@ describe('MRWidgetHeader', () => {
expect
(
el
.
classList
.
contains
(
'
mr-source-target
'
)).
toBeTruthy
();
expect
(
el
.
classList
.
contains
(
'
mr-source-target
'
)).
toBeTruthy
();
const
sourceBranchLink
=
el
.
querySelectorAll
(
'
.label-branch
'
)[
0
];
const
sourceBranchLink
=
el
.
querySelectorAll
(
'
.label-branch
'
)[
0
];
const
targetBranchLink
=
el
.
querySelectorAll
(
'
.label-branch
'
)[
1
];
const
targetBranchLink
=
el
.
querySelectorAll
(
'
.label-branch
'
)[
1
];
const
commitsCount
=
el
.
querySelector
(
'
.diverged-commits-count
'
);
expect
(
sourceBranchLink
.
textContent
).
toContain
(
mr
.
sourceBranch
);
expect
(
sourceBranchLink
.
textContent
).
toContain
(
mr
.
sourceBranch
);
expect
(
targetBranchLink
.
textContent
).
toContain
(
mr
.
targetBranch
);
expect
(
targetBranchLink
.
textContent
).
toContain
(
mr
.
targetBranch
);
expect
(
sourceBranchLink
.
querySelector
(
'
a
'
).
getAttribute
(
'
href
'
)).
toEqual
(
sourceBranchPath
);
expect
(
sourceBranchLink
.
querySelector
(
'
a
'
).
getAttribute
(
'
href
'
)).
toEqual
(
sourceBranchPath
);
expect
(
targetBranchLink
.
querySelector
(
'
a
'
).
getAttribute
(
'
href
'
)).
toEqual
(
mr
.
targetBranchPath
);
expect
(
targetBranchLink
.
querySelector
(
'
a
'
).
getAttribute
(
'
href
'
)).
toEqual
(
mr
.
targetBranchTreePath
);
expect
(
el
.
querySelector
(
'
.diverged-commits-count
'
).
textContent
).
toContain
(
'
12 commits behind
'
);
expect
(
commitsCount
.
textContent
).
toContain
(
'
12 commits behind
'
);
expect
(
commitsCount
.
querySelector
(
'
a
'
).
getAttribute
(
'
href
'
)).
toEqual
(
mr
.
targetBranchPath
);
expect
(
el
.
textContent
).
toContain
(
'
Check out branch
'
);
expect
(
el
.
textContent
).
toContain
(
'
Check out branch
'
);
expect
(
el
.
querySelectorAll
(
'
.dropdown li a
'
)[
0
].
getAttribute
(
'
href
'
)).
toEqual
(
mr
.
emailPatchesPath
);
expect
(
el
.
querySelectorAll
(
'
.dropdown li a
'
)[
0
].
getAttribute
(
'
href
'
)).
toEqual
(
mr
.
emailPatchesPath
);
...
...
spec/presenters/merge_request_presenter_spec.rb
浏览文件 @
6eeb6384
...
@@ -317,6 +317,30 @@ describe MergeRequestPresenter do
...
@@ -317,6 +317,30 @@ describe MergeRequestPresenter do
end
end
end
end
describe
'#target_branch_commits_path'
do
subject
do
described_class
.
new
(
resource
,
current_user:
user
)
.
target_branch_commits_path
end
context
'when target branch exists'
do
it
'returns path'
do
allow
(
resource
).
to
receive
(
:target_branch_exists?
)
{
true
}
is_expected
.
to
eq
(
"/
#{
resource
.
target_project
.
full_path
}
/commits/
#{
resource
.
target_branch
}
"
)
end
end
context
'when target branch does not exists'
do
it
'returns nil'
do
allow
(
resource
).
to
receive
(
:target_branch_exists?
)
{
false
}
is_expected
.
to
be_nil
end
end
end
describe
'#target_branch_tree_path'
do
describe
'#target_branch_tree_path'
do
subject
do
subject
do
described_class
.
new
(
resource
,
current_user:
user
)
described_class
.
new
(
resource
,
current_user:
user
)
...
...
spec/serializers/merge_request_entity_spec.rb
浏览文件 @
6eeb6384
...
@@ -46,8 +46,8 @@ describe MergeRequestEntity do
...
@@ -46,8 +46,8 @@ describe MergeRequestEntity do
:conflict_resolution_path
,
:conflict_resolution_path
,
:cancel_merge_when_pipeline_succeeds_path
,
:cancel_merge_when_pipeline_succeeds_path
,
:create_issue_to_resolve_discussions_path
,
:create_issue_to_resolve_discussions_path
,
:source_branch_path
,
:target_branch_
tree
_path
,
:source_branch_path
,
:target_branch_
commits
_path
,
:commits_count
)
:
target_branch_tree_path
,
:
commits_count
)
end
end
it
'has email_patches_path'
do
it
'has email_patches_path'
do
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录