Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/models/commit_range.rb26
-rw-r--r--spec/models/commit_range_spec.rb6
2 files changed, 15 insertions, 17 deletions
diff --git a/app/models/commit_range.rb b/app/models/commit_range.rb
index 1b4b12e70e9..67ea4155aec 100644
--- a/app/models/commit_range.rb
+++ b/app/models/commit_range.rb
@@ -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
diff --git a/spec/models/commit_range_spec.rb b/spec/models/commit_range_spec.rb
index fc2982b9a33..31ee3e99cad 100644
--- a/spec/models/commit_range_spec.rb
+++ b/spec/models/commit_range_spec.rb
@@ -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_inclusive
+ expect(range.exclude_start?).to eq false
end
it 'is true for two-dot ranges' do
- expect(range2).to be_inclusive
+ expect(range2.exclude_start?).to eq true
end
end