Skip to content
This repository was archived by the owner on Feb 19, 2020. It is now read-only.

Commit 278633a

Browse files
authored
Merge pull request #34 from codacy/remove-extra-chars-from-url
Remove extra characters from commit uuid
2 parents 20d07b8 + 5efe1c5 commit 278633a

File tree

5 files changed

+24
-8
lines changed

5 files changed

+24
-8
lines changed

circle.yml

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ dependencies:
33
- git config --global user.email "ci@codacy.com"
44
- git config --global user.name "Codacy CI"
55
override:
6-
- rvm install 1.9.3-p551
76
- rvm install 2.0.0-p648
87
- rvm install 2.1.10
98
- rvm install 2.2.5

codacy-coverage.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Gem::Specification.new do |gem|
1616
gem.require_paths = ["lib"]
1717
gem.version = ENV['PUBLISH_VERSION'] || '1.0.dev'.freeze
1818

19-
gem.required_ruby_version = '>= 1.9'
19+
gem.required_ruby_version = '>= 2'
2020

2121
gem.add_runtime_dependency 'simplecov'
2222

lib/codacy/client.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def self.post_results(parsed_result)
1111
project_token = ENV['CODACY_PROJECT_TOKEN']
1212
codacy_base_api = ENV['CODACY_BASE_API_URL'] || 'https://api.codacy.com'
1313
commit = Codacy::Git.commit_id
14-
url = codacy_base_api + '/2.0/coverage/' + commit + '/ruby'
14+
create_url(codacy_base_api, commit)
1515

1616
result = parsed_result.to_json
1717

@@ -51,5 +51,10 @@ def self.send_request(url, content, project_token, redirects = 3)
5151
def self.logger
5252
Codacy::Configuration.logger
5353
end
54+
55+
def self.create_url(codacy_base_api, commit)
56+
commit = commit.gsub(/[^[:alnum:]]/, "")
57+
codacy_base_api + '/2.0/coverage/' + commit + '/ruby'
58+
end
5459
end
5560
end

scripts/ci.sh

-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22

33
set -e
44

5-
rvm use 1.9.3-p551
6-
ruby -v
7-
bundle install --gemfile Gemfile.ruby-19
8-
bundle exec rspec
9-
105
rvm use 2.0.0-p648
116
ruby -v
127
bundle install

spec/codacy/client_spec.rb

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
require "spec_helper"
2+
3+
describe Codacy::ClientAPI do
4+
describe 'create url' do
5+
it 'checks if the url is correct.' do
6+
codacy_base_api = 'https://api.codacy.com'
7+
8+
expected_commit_uuid = "9a7d25976a11f2a145f8fee7c4e4ad58b621d560"
9+
expected_url = Codacy::ClientAPI.create_url(codacy_base_api, expected_commit_uuid)
10+
11+
wrong_commit_uuid = "'9a7d25976a11f2a145f8fee7c4e4ad58b621d560'"
12+
fixed_url = Codacy::ClientAPI.create_url(codacy_base_api, wrong_commit_uuid)
13+
14+
expect(fixed_url).to eq expected_url
15+
end
16+
end
17+
end

0 commit comments

Comments
 (0)