Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
7df1cb52
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,体验更适合开发者的 AI 搜索 >>
提交
7df1cb52
编写于
11月 18, 2017
作者:
L
Lin Jen-Shin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move identical merged branch check to merged_branch_names
上级
3e558d8d
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
27 addition
and
32 deletion
+27
-32
app/models/repository.rb
app/models/repository.rb
+2
-8
app/views/projects/branches/index.html.haml
app/views/projects/branches/index.html.haml
+1
-1
lib/api/entities.rb
lib/api/entities.rb
+5
-1
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+13
-3
spec/lib/gitlab/git/repository_spec.rb
spec/lib/gitlab/git/repository_spec.rb
+6
-1
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+0
-18
未找到文件。
app/models/repository.rb
浏览文件 @
7df1cb52
...
...
@@ -909,19 +909,13 @@ class Repository
end
end
def
merged_to_root_ref?
(
branch_or_name
,
pre_loaded_merged_branches
=
nil
)
def
merged_to_root_ref?
(
branch_or_name
)
branch
=
Gitlab
::
Git
::
Branch
.
find
(
self
,
branch_or_name
)
if
branch
@root_ref_sha
||=
commit
(
root_ref
).
sha
same_head
=
branch
.
target
==
@root_ref_sha
merged
=
if
pre_loaded_merged_branches
pre_loaded_merged_branches
.
include?
(
branch
.
name
)
else
ancestor?
(
branch
.
target
,
@root_ref_sha
)
end
merged
=
ancestor?
(
branch
.
target
,
@root_ref_sha
)
!
same_head
&&
merged
else
nil
...
...
app/views/projects/branches/index.html.haml
浏览文件 @
7df1cb52
...
...
@@ -38,7 +38,7 @@
-
if
@branches
.
any?
%ul
.content-list.all-branches
-
@branches
.
each
do
|
branch
|
=
render
"projects/branches/branch"
,
branch:
branch
,
merged:
@
repository
.
merged_to_root_ref?
(
branch
,
@merged_branch_names
)
=
render
"projects/branches/branch"
,
branch:
branch
,
merged:
@
merged_branch_names
.
include?
(
branch
.
name
)
=
paginate
@branches
,
theme:
'gitlab'
-
else
.nothing-here-block
...
...
lib/api/entities.rb
浏览文件 @
7df1cb52
...
...
@@ -242,7 +242,11 @@ module API
end
expose
:merged
do
|
repo_branch
,
options
|
options
[
:project
].
repository
.
merged_to_root_ref?
(
repo_branch
,
options
[
:merged_branch_names
])
if
options
[
:merged_branch_names
]
options
[
:merged_branch_names
].
include?
(
repo_branch
.
name
)
else
options
[
:project
].
repository
.
merged_to_root_ref?
(
repo_branch
)
end
end
expose
:protected
do
|
repo_branch
,
options
|
...
...
lib/gitlab/git/repository.rb
浏览文件 @
7df1cb52
...
...
@@ -1243,11 +1243,21 @@ module Gitlab
sort_branches
(
branches
,
sort_by
)
end
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/695
def
git_merged_branch_names
(
branch_names
=
[])
lines
=
run_git
([
'branch'
,
'--merged'
,
root_ref
]
+
branch_names
)
.
first
.
lines
root_sha
=
find_branch
(
root_ref
).
target
lines
.
map
(
&
:strip
)
git_arguments
=
%W[branch --merged
#{
root_sha
}
--format=%(refname:short)
\
%(objectname)]
+
branch_names
lines
=
run_git
(
git_arguments
).
first
.
lines
lines
.
each_with_object
([])
do
|
line
,
branches
|
name
,
sha
=
line
.
strip
.
split
(
' '
,
2
)
branches
<<
name
if
sha
!=
root_sha
end
end
def
log_using_shell?
(
options
)
...
...
spec/lib/gitlab/git/repository_spec.rb
浏览文件 @
7df1cb52
...
...
@@ -1211,12 +1211,17 @@ describe Gitlab::Git::Repository, seed_helper: true do
end
context
'when no branch names are specified'
do
it
'returns all merged branch names'
do
before
do
repository
.
create_branch
(
'identical'
,
'master'
)
end
it
'returns all merged branch names except for identical one'
do
names
=
repository
.
merged_branch_names
expect
(
names
).
to
include
(
'merge-test'
)
expect
(
names
).
to
include
(
'fix-mode'
)
expect
(
names
).
not_to
include
(
'feature'
)
expect
(
names
).
not_to
include
(
'identical'
)
end
end
end
...
...
spec/models/repository_spec.rb
浏览文件 @
7df1cb52
...
...
@@ -299,24 +299,6 @@ describe Repository do
it
{
is_expected
.
to
be_falsey
}
end
context
'when pre-loaded merged branches are provided'
do
using
RSpec
::
Parameterized
::
TableSyntax
where
(
:branch
,
:pre_loaded
,
:expected
)
do
'not-merged-branch'
|
[
'branch-merged'
]
|
false
'branch-merged'
|
[
'not-merged-branch'
]
|
false
'branch-merged'
|
[
'branch-merged'
]
|
true
'not-merged-branch'
|
[
'not-merged-branch'
]
|
false
'master'
|
[
'master'
]
|
false
end
with_them
do
subject
{
repository
.
merged_to_root_ref?
(
branch
,
pre_loaded
)
}
it
{
is_expected
.
to
eq
(
expected
)
}
end
end
end
describe
'#can_be_merged?'
do
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录