Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
96a0a8cf
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,发现更多精彩内容 >>
未验证
提交
96a0a8cf
编写于
11月 16, 2018
作者:
M
Matija Čupić
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use strings instead of Gitlab::Git::Ref
上级
35b3392e
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
19 addition
and
36 deletion
+19
-36
app/models/project.rb
app/models/project.rb
+9
-8
spec/models/project_spec.rb
spec/models/project_spec.rb
+10
-28
未找到文件。
app/models/project.rb
浏览文件 @
96a0a8cf
...
@@ -1167,11 +1167,11 @@ class Project < ActiveRecord::Base
...
@@ -1167,11 +1167,11 @@ class Project < ActiveRecord::Base
if
tag_exists
&&
branch_exists
if
tag_exists
&&
branch_exists
nil
nil
elsif
tag_exists
elsif
tag_exists
repository
.
find_tag
(
ref
)
Gitlab
::
Git
::
TAG_REF_PREFIX
+
ref
elsif
branch_exists
elsif
branch_exists
repository
.
find_branch
(
ref
)
Gitlab
::
Git
::
BRANCH_REF_PREFIX
+
ref
else
else
re
pository
.
find_ref
(
ref
)
re
f
end
end
end
end
...
@@ -1755,11 +1755,12 @@ class Project < ActiveRecord::Base
...
@@ -1755,11 +1755,12 @@ class Project < ActiveRecord::Base
resolved_ref
=
resolve_ref
(
ref
)
resolved_ref
=
resolve_ref
(
ref
)
return
false
unless
resolved_ref
return
false
unless
resolved_ref
case
resolved_ref
ref_name
=
Gitlab
::
Git
.
ref_name
(
resolved_ref
)
when
Gitlab
::
Git
::
Branch
ProtectedBranch
.
protected?
(
self
,
resolved_ref
.
name
)
if
Gitlab
::
Git
.
branch_ref?
(
resolved_ref
)
when
Gitlab
::
Git
::
Tag
ProtectedBranch
.
protected?
(
self
,
ref_name
)
ProtectedTag
.
protected?
(
self
,
resolved_ref
.
name
)
elsif
Gitlab
::
Git
.
tag_ref?
(
resolved_ref
)
ProtectedTag
.
protected?
(
self
,
ref_name
)
end
end
end
end
...
...
spec/models/project_spec.rb
浏览文件 @
96a0a8cf
...
@@ -2580,7 +2580,7 @@ describe Project do
...
@@ -2580,7 +2580,7 @@ describe Project do
end
end
context
'when the ref is not protected'
do
context
'when the ref is not protected'
do
let
(
:ref
)
{
project
.
repository
.
find_branch
(
'master'
)
}
let
(
:ref
)
{
'refs/heads/master'
}
before
do
before
do
stub_application_setting
(
stub_application_setting
(
...
@@ -2593,7 +2593,7 @@ describe Project do
...
@@ -2593,7 +2593,7 @@ describe Project do
end
end
context
'when the ref is a protected branch'
do
context
'when the ref is a protected branch'
do
let
(
:ref
)
{
project
.
repository
.
find_branch
(
'master'
)
}
let
(
:ref
)
{
'refs/heads/master'
}
before
do
before
do
create
(
:protected_branch
,
name:
'master'
,
project:
project
)
create
(
:protected_branch
,
name:
'master'
,
project:
project
)
...
@@ -2605,7 +2605,7 @@ describe Project do
...
@@ -2605,7 +2605,7 @@ describe Project do
end
end
context
'when the ref is a protected tag'
do
context
'when the ref is a protected tag'
do
let
(
:ref
)
{
project
.
repository
.
find_tag
(
'v1.0.0'
)
}
let
(
:ref
)
{
'refs/tags/v1.0.0'
}
before
do
before
do
create
(
:protected_tag
,
name:
'v1.0.0'
,
project:
project
)
create
(
:protected_tag
,
name:
'v1.0.0'
,
project:
project
)
...
@@ -2802,20 +2802,10 @@ describe Project do
...
@@ -2802,20 +2802,10 @@ describe Project do
subject
{
project
.
resolve_ref
(
ref
)
}
subject
{
project
.
resolve_ref
(
ref
)
}
context
'when ref is full ref'
do
context
'when ref is full ref'
do
context
'when ref exists'
do
let
(
:ref
)
{
'refs/heads/master'
}
let
(
:ref
)
{
'refs/heads/master'
}
it
'returns a ref'
do
it
'returns the ref'
do
is_expected
.
to
be_a
(
Gitlab
::
Git
::
Ref
)
is_expected
.
to
eq
(
ref
)
end
end
context
'when ref does not exist'
do
let
(
:ref
)
{
'refs/tags/doesnotexist'
}
it
'returns nil'
do
is_expected
.
to
eq
(
nil
)
end
end
end
end
end
...
@@ -2838,12 +2828,8 @@ describe Project do
...
@@ -2838,12 +2828,8 @@ describe Project do
project
.
repository
.
add_tag
(
project
.
creator
,
ref
,
'master'
)
project
.
repository
.
add_tag
(
project
.
creator
,
ref
,
'master'
)
end
end
it
'returns a tag'
do
it
'returns the tag ref'
do
is_expected
.
to
be_a
(
Gitlab
::
Git
::
Tag
)
is_expected
.
to
eq
(
"refs/tags/
#{
ref
}
"
)
end
it
'returns the correct tag'
do
expect
(
subject
.
name
).
to
eq
(
ref
)
end
end
end
end
...
@@ -2852,12 +2838,8 @@ describe Project do
...
@@ -2852,12 +2838,8 @@ describe Project do
project
.
repository
.
add_branch
(
project
.
creator
,
ref
,
'master'
)
project
.
repository
.
add_branch
(
project
.
creator
,
ref
,
'master'
)
end
end
it
'returns a branch'
do
it
'returns the branch ref'
do
is_expected
.
to
be_a
(
Gitlab
::
Git
::
Branch
)
is_expected
.
to
eq
(
"refs/heads/
#{
ref
}
"
)
end
it
'returns the correct branch'
do
expect
(
subject
.
name
).
to
eq
(
ref
)
end
end
end
end
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录