From 165cacce163366fa3b362bb5005ed9ede346a8e1 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Sat, 25 Apr 2015 14:58:49 -0400 Subject: Rename `CommitRange#inclusive?` to `#exclude_start?` --- app/models/commit_range.rb | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'app/models/commit_range.rb') 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 -- cgit v1.2.3