Skip to content

Commit

Permalink
Merge pull request #208 from simplybusiness/fix-incorrect-error
Browse files Browse the repository at this point in the history
Fix incorrect error
  • Loading branch information
addersuk authored Jun 26, 2024
2 parents 0c87d7f + edc3d4b commit 713e190
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ inherit_gem:
- .simplycop_rspec.yml

AllCops:
TargetRubyVersion: 3.0
TargetRubyVersion: 3.1
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.2.1
3.3.2
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ source 'https://rubygems.org'
gem 'jwt'
gem 'octokit'
gem 'semantic'

group :development, :test do
gem 'pry'
gem 'rspec'
Expand Down
13 changes: 8 additions & 5 deletions lib/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@ class Command

COMMAND_PREFIX = '/dobby'

# Improved version of the initialize method in command.rb
def initialize(config)
@config = config
comment = config.payload['comment']['body'].strip.downcase
error_msg = "Comment must start with #{COMMAND_PREFIX}"
puts "::error title=Argument Error::#{error_msg}"
raise ArgumentError, error_msg unless comment.start_with?(COMMAND_PREFIX)
unless comment.start_with?(COMMAND_PREFIX)
error_msg = "Comment must start with #{COMMAND_PREFIX}"
puts "::error title=Argument Error::#{error_msg}"
raise ArgumentError, error_msg
end

cmd = comment.delete_prefix(COMMAND_PREFIX)
@command, @options = cmd.split
cmd = comment.delete_prefix(COMMAND_PREFIX).strip
@command, @options = cmd.split(/\s+/, 2)
end

def call
Expand Down

0 comments on commit 713e190

Please sign in to comment.