BigW Consortium Gitlab

Commit 165cacce by Robert Speicher

Rename `CommitRange#inclusive?` to `#exclude_start?`

parent 95ca6584
...@@ -3,14 +3,15 @@ ...@@ -3,14 +3,15 @@
# Examples: # Examples:
# #
# range = CommitRange.new('f3f85602...e86e1013') # range = CommitRange.new('f3f85602...e86e1013')
# range.inclusive? # => false # range.exclude_start? # => false
# range.to_s # => "f3f85602...e86e1013"
# range.reference_title # => "Commits f3f85602 through e86e1013" # range.reference_title # => "Commits f3f85602 through e86e1013"
# range.to_s # => "f3f85602...e86e1013"
# #
# range = CommitRange.new('f3f856029bc5f966c5a7ee24cf7efefdd20e6019..e86e1013709735be5bb767e2b228930c543f25ae') # range = CommitRange.new('f3f856029bc5f966c5a7ee24cf7efefdd20e6019..e86e1013709735be5bb767e2b228930c543f25ae')
# range.inclusive? # => true # range.exclude_start? # => true
# range.to_s # => "f3f85602..e86e1013" # range.reference_title # => "Commits f3f85602^ through e86e1013"
# range.to_param # => {from: "f3f856029bc5f966c5a7ee24cf7efefdd20e6019^", to: "e86e1013709735be5bb767e2b228930c543f25ae"} # range.to_param # => {from: "f3f856029bc5f966c5a7ee24cf7efefdd20e6019^", to: "e86e1013709735be5bb767e2b228930c543f25ae"}
# range.to_s # => "f3f85602..e86e1013"
# #
# # Assuming `project` is a Project with a repository containing both commits: # # Assuming `project` is a Project with a repository containing both commits:
# range.project = project # range.project = project
...@@ -24,8 +25,8 @@ class CommitRange ...@@ -24,8 +25,8 @@ class CommitRange
# Optional Project model # Optional Project model
attr_accessor :project attr_accessor :project
# See `inclusive?` # See `exclude_start?`
attr_reader :inclusive attr_reader :exclude_start
# The beginning and ending SHA sums can be between 6 and 40 hex characters, # The beginning and ending SHA sums can be between 6 and 40 hex characters,
# and the range selection can be double- or triple-dot. # and the range selection can be double- or triple-dot.
...@@ -44,7 +45,7 @@ class CommitRange ...@@ -44,7 +45,7 @@ class CommitRange
raise ArgumentError, "invalid CommitRange string format: #{range_string}" raise ArgumentError, "invalid CommitRange string format: #{range_string}"
end end
@inclusive = !range_string.include?('...') @exclude_start = !range_string.include?('...')
@sha_from, @notation, @sha_to = range_string.split(/(\.{2,3})/, 2) @sha_from, @notation, @sha_to = range_string.split(/(\.{2,3})/, 2)
@project = project @project = project
...@@ -70,11 +71,8 @@ class CommitRange ...@@ -70,11 +71,8 @@ class CommitRange
{ from: sha_from_as_param, to: sha_to } { from: sha_from_as_param, to: sha_to }
end end
# Check if the range is inclusive def exclude_start?
# exclude_start
# We consider a CommitRange "inclusive" when it uses the two-dot syntax.
def inclusive?
inclusive
end end
# Check if both the starting and ending commit IDs exist in a project's # Check if both the starting and ending commit IDs exist in a project's
...@@ -103,6 +101,6 @@ class CommitRange ...@@ -103,6 +101,6 @@ class CommitRange
private private
def sha_from_as_param def sha_from_as_param
sha_from + (inclusive? ? '^' : '') sha_from + (exclude_start? ? '^' : '')
end end
end end
...@@ -45,13 +45,13 @@ describe CommitRange do ...@@ -45,13 +45,13 @@ describe CommitRange do
end end
end end
describe '#inclusive?' do describe '#exclude_start?' do
it 'is false for three-dot ranges' do it 'is false for three-dot ranges' do
expect(range).not_to be_inclusive expect(range.exclude_start?).to eq false
end end
it 'is true for two-dot ranges' do it 'is true for two-dot ranges' do
expect(range2).to be_inclusive expect(range2.exclude_start?).to eq true
end end
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment