Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
165cacce
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,发现更多精彩内容 >>
提交
165cacce
编写于
4月 25, 2015
作者:
R
Robert Speicher
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename `CommitRange#inclusive?` to `#exclude_start?`
上级
95ca6584
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
15 addition
and
17 deletion
+15
-17
app/models/commit_range.rb
app/models/commit_range.rb
+12
-14
spec/models/commit_range_spec.rb
spec/models/commit_range_spec.rb
+3
-3
未找到文件。
app/models/commit_range.rb
浏览文件 @
165cacce
...
...
@@ -3,14 +3,15 @@
# Examples:
#
# range = CommitRange.new('f3f85602...e86e1013')
# range.inclusive? # => false
# range.to_s # => "f3f85602...e86e1013"
# range.exclude_start? # => false
# range.reference_title # => "Commits f3f85602 through e86e1013"
# range.to_s # => "f3f85602...e86e1013"
#
# range = CommitRange.new('f3f856029bc5f966c5a7ee24cf7efefdd20e6019..e86e1013709735be5bb767e2b228930c543f25ae')
# range.inclusive? # => true
# range.to_s # => "f3f85602..e86e1013"
# range.to_param # => {from: "f3f856029bc5f966c5a7ee24cf7efefdd20e6019^", to: "e86e1013709735be5bb767e2b228930c543f25ae"}
# range.exclude_start? # => true
# range.reference_title # => "Commits f3f85602^ through e86e1013"
# range.to_param # => {from: "f3f856029bc5f966c5a7ee24cf7efefdd20e6019^", to: "e86e1013709735be5bb767e2b228930c543f25ae"}
# range.to_s # => "f3f85602..e86e1013"
#
# # Assuming `project` is a Project with a repository containing both commits:
# range.project = project
...
...
@@ -24,8 +25,8 @@ class CommitRange
# Optional Project model
attr_accessor
:project
# See `
inclusive
?`
attr_reader
:
inclusive
# See `
exclude_start
?`
attr_reader
:
exclude_start
# The beginning and ending SHA sums can be between 6 and 40 hex characters,
# and the range selection can be double- or triple-dot.
...
...
@@ -44,7 +45,7 @@ class CommitRange
raise
ArgumentError
,
"invalid CommitRange string format:
#{
range_string
}
"
end
@
inclusive
=
!
range_string
.
include?
(
'...'
)
@
exclude_start
=
!
range_string
.
include?
(
'...'
)
@sha_from
,
@notation
,
@sha_to
=
range_string
.
split
(
/(\.{2,3})/
,
2
)
@project
=
project
...
...
@@ -70,11 +71,8 @@ class CommitRange
{
from:
sha_from_as_param
,
to:
sha_to
}
end
# Check if the range is inclusive
#
# We consider a CommitRange "inclusive" when it uses the two-dot syntax.
def
inclusive?
inclusive
def
exclude_start?
exclude_start
end
# Check if both the starting and ending commit IDs exist in a project's
...
...
@@ -103,6 +101,6 @@ class CommitRange
private
def
sha_from_as_param
sha_from
+
(
inclusive
?
?
'^'
:
''
)
sha_from
+
(
exclude_start
?
?
'^'
:
''
)
end
end
spec/models/commit_range_spec.rb
浏览文件 @
165cacce
...
...
@@ -45,13 +45,13 @@ describe CommitRange do
end
end
describe
'#
inclusive
?'
do
describe
'#
exclude_start
?'
do
it
'is false for three-dot ranges'
do
expect
(
range
).
not_to
be_inclusiv
e
expect
(
range
.
exclude_start?
).
to
eq
fals
e
end
it
'is true for two-dot ranges'
do
expect
(
range2
).
to
be_inclusiv
e
expect
(
range2
.
exclude_start?
).
to
eq
tru
e
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录