coveralls-revelry 0.8.23

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d8e66bdd3c49b5285809089618290401081c224aaf9ded5b1b4fc63fa1f6eee5
4
+ data.tar.gz: '035552619f1a33ee61c56b4b54c6823cacec2c83ebdd2edd954d54bbf80a5ba2'
5
+ SHA512:
6
+ metadata.gz: c0ebc35c32bdb6d2f152aa6ef444af5232f74341d90b52f120481864b34549201793f15a1ba254f6db634c83f8b646eba25d79af10c6dc4c2692271403f3f526
7
+ data.tar.gz: c916bc26a49aba46344648b57a1044a35d0ec2e6a470080cf404e4661c3f36028712b0f81652da6e03fd82670ed7502df0dcf13d87792ea7a640ba14e31e016f
data/.gitignore ADDED
@@ -0,0 +1,20 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+
19
+ .DS_Store
20
+ /vendor/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --warn
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.3.3
data/.travis.yml ADDED
@@ -0,0 +1,24 @@
1
+ language: ruby
2
+
3
+ cache: bundler
4
+
5
+ sudo: false
6
+
7
+ rvm:
8
+ - 1.9.3
9
+ - 2.0.0
10
+ - 2.1
11
+ - 2.2
12
+ - 2.3
13
+ - 2.4
14
+ - 2.5
15
+ - ruby-head
16
+ - jruby
17
+
18
+ matrix:
19
+ allow_failures:
20
+ - rvm: ruby-head
21
+ - rvm: jruby
22
+ # NOTE: The tests never pass with 1.9.3 since WebMock stopped supporting 1.9.
23
+ - rvm: 1.9.3
24
+ fast_finish: true
data/CHANGELOG.md ADDED
@@ -0,0 +1,21 @@
1
+ # Changelog
2
+
3
+ ### Please see Github Releases section for current releases.
4
+
5
+ ## 0.7.0 (September 18, 2013)
6
+
7
+ [Full Changelog](https://github.com/lemurheavy/coveralls-ruby/compare/v0.6.4...v0.7.0)
8
+
9
+ Added:
10
+ * output silencing (Thanks @elizabrock)
11
+ * ruby warning fixes (Thanks @steveklabnik and @Nucc)
12
+
13
+ ## 0.6.4 (April 2, 2013)
14
+
15
+ [Full Changelog](https://github.com/lemurheavy/coveralls-ruby/compare/v0.6.3...v0.6.4)
16
+
17
+ Enhancements:
18
+
19
+ * Support [Jenkins CI](http://jenkins-ci.org/)
20
+ * Support VCR versions <= 2
21
+ * Add SimpleCov filter 'vendor' by default.
data/Gemfile ADDED
@@ -0,0 +1,41 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in coveralls-ruby.gemspec
4
+ gemspec
5
+
6
+ gem 'rake', Gem::Version.new(RUBY_VERSION) < Gem::Version.new('1.9.3') ? '~> 10.3' : '>= 10.3'
7
+ gem 'rspec', '>= 3.2'
8
+ gem 'simplecov', :require => false
9
+ gem 'truthy', '>= 1'
10
+
11
+ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('1.9')
12
+ gem 'vcr', '~> 2.9'
13
+ gem 'webmock', '~> 1.20'
14
+ else
15
+ gem 'vcr', '>= 2.9'
16
+ gem 'webmock', '>= 1.20'
17
+ end
18
+
19
+ platforms :ruby_18 do
20
+ gem 'addressable', '~> 2.3.8', :group => :test
21
+ gem 'mime-types', '~> 1.25'
22
+ end
23
+
24
+ platforms :ruby_18, :ruby_19 do
25
+ gem 'json', '~> 1.8'
26
+ gem 'term-ansicolor', '~> 1.3.0'
27
+ gem 'tins', '~> 1.6.0'
28
+ end
29
+
30
+ platforms :jruby do
31
+ gem 'jruby-openssl'
32
+ end
33
+
34
+ platform :rbx do
35
+ gem 'rubysl', '~> 2.0'
36
+ gem 'rubinius-developer_tools'
37
+ end
38
+
39
+ group :test do
40
+ gem 'pry'
41
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Wil Gieseler
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # [Coveralls](http://coveralls.io) for Ruby [![Test Coverage](https://coveralls.io/repos/lemurheavy/coveralls-ruby/badge.svg?branch=master)](https://coveralls.io/r/lemurheavy/coveralls-ruby) [![Build Status](https://secure.travis-ci.org/lemurheavy/coveralls-ruby.svg?branch=master)](https://travis-ci.org/lemurheavy/coveralls-ruby) [![Gem Version](https://badge.fury.io/rb/coveralls.svg)](http://badge.fury.io/rb/coveralls)
2
+
3
+ ### [Read the docs &rarr;](https://docs.coveralls.io/ruby-on-rails)
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+
4
+ # Travis!
5
+ require 'rubygems'
6
+ require 'rake'
7
+ require 'rspec/core/rake_task'
8
+
9
+ desc "Run RSpec"
10
+ RSpec::Core::RakeTask.new do |t|
11
+ t.verbose = false
12
+ end
13
+
14
+ task :default => :spec
data/bin/coveralls ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
4
+ $LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
5
+
6
+ require 'coveralls'
7
+ require 'coveralls/command'
8
+
9
+ Coveralls::CommandLine.start
@@ -0,0 +1,29 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'coveralls/version'
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.authors = ["Robert Prehn"]
7
+ gem.email = ["robert@revelry.co"]
8
+ gem.description = "A forked ruby implementation of the coveralls API."
9
+ gem.summary = "A forked ruby implementation of the coveralls API."
10
+ gem.homepage = "https://github.com/revelrylabs/coveralls-ruby"
11
+ gem.license = "MIT"
12
+
13
+ gem.files = `git ls-files`.split($\)
14
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
15
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
16
+ gem.name = "coveralls-revelry"
17
+ gem.require_paths = ["lib"]
18
+ gem.version = Coveralls::VERSION
19
+
20
+ gem.required_ruby_version = '>= 1.8.7'
21
+
22
+ gem.add_dependency 'json', '>= 1.8', '< 3'
23
+ gem.add_dependency 'simplecov', '~> 0.16.1'
24
+ gem.add_dependency 'tins', '~> 1.6'
25
+ gem.add_dependency 'term-ansicolor', '~> 1.3'
26
+ gem.add_dependency 'thor', '~> 0.19.4'
27
+
28
+ gem.add_development_dependency 'bundler', '~> 1.7'
29
+ end
@@ -0,0 +1,128 @@
1
+ require 'json'
2
+ require 'net/https'
3
+ require 'tempfile'
4
+
5
+ module Coveralls
6
+ class API
7
+ if ENV['COVERALLS_ENDPOINT']
8
+ API_HOST = ENV['COVERALLS_ENDPOINT']
9
+ API_DOMAIN = ENV['COVERALLS_ENDPOINT']
10
+ else
11
+ API_HOST = ENV['COVERALLS_DEVELOPMENT'] ? "localhost:3000" : "coveralls.io"
12
+ API_PROTOCOL = ENV['COVERALLS_DEVELOPMENT'] ? "http" : "https"
13
+ API_DOMAIN = "#{API_PROTOCOL}://#{API_HOST}"
14
+ end
15
+
16
+ API_BASE = "#{API_DOMAIN}/api/v1"
17
+
18
+ def self.post_json(endpoint, hash)
19
+ disable_net_blockers!
20
+
21
+ uri = endpoint_to_uri(endpoint)
22
+
23
+ Coveralls::Output.puts("#{ JSON.pretty_generate(hash) }", :color => "green") if ENV['COVERALLS_DEBUG']
24
+ Coveralls::Output.puts("[Coveralls] Submitting to #{API_BASE}", :color => "cyan")
25
+
26
+ client = build_client(uri)
27
+ request = build_request(uri.path, hash)
28
+
29
+ response = client.request(request)
30
+
31
+ response_hash = JSON.load(response.body.to_str)
32
+
33
+ if response_hash['message']
34
+ Coveralls::Output.puts("[Coveralls] #{ response_hash['message'] }", :color => "cyan")
35
+ end
36
+
37
+ if response_hash['url']
38
+ Coveralls::Output.puts("[Coveralls] #{ Coveralls::Output.format(response_hash['url'], :color => "underline") }", :color => "cyan")
39
+ end
40
+
41
+ case response
42
+ when Net::HTTPServiceUnavailable
43
+ Coveralls::Output.puts("[Coveralls] API timeout occured, but data should still be processed", :color => "red")
44
+ when Net::HTTPInternalServerError
45
+ Coveralls::Output.puts("[Coveralls] API internal error occured, we're on it!", :color => "red")
46
+ end
47
+ end
48
+
49
+ private
50
+
51
+ def self.disable_net_blockers!
52
+ begin
53
+ require 'webmock'
54
+
55
+ allow = WebMock::Config.instance.allow || []
56
+ WebMock::Config.instance.allow = [*allow].push API_HOST
57
+ rescue LoadError
58
+ end
59
+
60
+ begin
61
+ require 'vcr'
62
+
63
+ VCR.send(VCR.version.major < 2 ? :config : :configure) do |c|
64
+ c.ignore_hosts API_HOST
65
+ end
66
+ rescue LoadError
67
+ end
68
+ end
69
+
70
+ def self.endpoint_to_uri(endpoint)
71
+ URI.parse("#{API_BASE}/#{endpoint}")
72
+ end
73
+
74
+ def self.build_client(uri)
75
+ client = Net::HTTP.new(uri.host, uri.port)
76
+ client.use_ssl = true if uri.port == 443
77
+ client.verify_mode = OpenSSL::SSL::VERIFY_NONE
78
+
79
+ unless client.respond_to?(:ssl_version=)
80
+ Net::HTTP.ssl_context_accessor("ssl_version")
81
+ end
82
+
83
+ # client.ssl_version = 'TLSv1'
84
+
85
+ client
86
+ end
87
+
88
+ def self.build_request(path, hash)
89
+ request = Net::HTTP::Post.new(path)
90
+ boundary = rand(1_000_000).to_s
91
+
92
+ request.body = build_request_body(hash, boundary)
93
+ request.content_type = "multipart/form-data, boundary=#{boundary}"
94
+
95
+ request
96
+ end
97
+
98
+ def self.build_request_body(hash, boundary)
99
+ hash = apified_hash(hash)
100
+ file = hash_to_file(hash)
101
+
102
+ "--#{boundary}\r\n" \
103
+ "Content-Disposition: form-data; name=\"json_file\"; filename=\"#{File.basename(file.path)}\"\r\n" \
104
+ "Content-Type: text/plain\r\n\r\n" +
105
+ File.read(file.path) +
106
+ "\r\n--#{boundary}--\r\n"
107
+ end
108
+
109
+ def self.hash_to_file(hash)
110
+ file = nil
111
+ Tempfile.open(['coveralls-upload', 'json']) do |f|
112
+ f.write(JSON.dump hash)
113
+ file = f
114
+ end
115
+ File.new(file.path, 'rb')
116
+ end
117
+
118
+ def self.apified_hash hash
119
+ config = Coveralls::Configuration.configuration
120
+ if ENV['COVERALLS_DEBUG'] || Coveralls.testing
121
+ Coveralls::Output.puts "[Coveralls] Submitting with config:", :color => "yellow"
122
+ output = JSON.pretty_generate(config).gsub(/"repo_token": ?"(.*?)"/,'"repo_token": "[secure]"')
123
+ Coveralls::Output.puts output, :color => "yellow"
124
+ end
125
+ hash.merge(config)
126
+ end
127
+ end
128
+ end
@@ -0,0 +1,69 @@
1
+ require "thor"
2
+
3
+ module Coveralls
4
+ class CommandLine < Thor
5
+
6
+ desc "push", "Runs your test suite and pushes the coverage results to Coveralls."
7
+ def push
8
+ return unless ensure_can_run_locally!
9
+ ENV["COVERALLS_RUN_LOCALLY"] = "true"
10
+ cmds = "bundle exec rake"
11
+ if File.exist?('.travis.yml')
12
+ cmds = YAML.load_file('.travis.yml')["script"] || cmds rescue cmds
13
+ end
14
+ cmds.each { |cmd| system cmd }
15
+ ENV["COVERALLS_RUN_LOCALLY"] = nil
16
+ end
17
+
18
+ desc "report", "Runs your test suite locally and displays coverage statistics."
19
+ def report
20
+ ENV["COVERALLS_NOISY"] = "true"
21
+ exec "bundle exec rake"
22
+ ENV["COVERALLS_NOISY"] = nil
23
+ end
24
+
25
+ desc "open", "View this repository on Coveralls."
26
+ def open
27
+ open_token_based_url "https://coveralls.io/repos/%@"
28
+ end
29
+
30
+ desc "service", "View this repository on your CI service's website."
31
+ def service
32
+ open_token_based_url "https://coveralls.io/repos/%@/service"
33
+ end
34
+
35
+ desc "last", "View the last build for this repository on Coveralls."
36
+ def last
37
+ open_token_based_url "https://coveralls.io/repos/%@/last_build"
38
+ end
39
+
40
+ desc "version", "See version"
41
+ def version
42
+ Coveralls::Output.puts Coveralls::VERSION
43
+ end
44
+
45
+ private
46
+
47
+ def open_token_based_url url
48
+ config = Coveralls::Configuration.configuration
49
+ if config[:repo_token]
50
+ url = url.gsub("%@", config[:repo_token])
51
+ `open #{url}`
52
+ else
53
+ Coveralls::Output.puts "No repo_token configured."
54
+ end
55
+ end
56
+
57
+ def ensure_can_run_locally!
58
+ config = Coveralls::Configuration.configuration
59
+ if config[:repo_token].nil?
60
+ Coveralls::Output.puts "Coveralls cannot run locally because no repo_secret_token is set in .coveralls.yml", :color => "red"
61
+ Coveralls::Output.puts "Please try again when you get your act together.", :color => "red"
62
+
63
+ return false
64
+ end
65
+ true
66
+ end
67
+
68
+ end
69
+ end
@@ -0,0 +1,233 @@
1
+ require 'yaml'
2
+ require 'securerandom'
3
+
4
+ module Coveralls
5
+ module Configuration
6
+
7
+ def self.configuration
8
+ config = {
9
+ :environment => self.relevant_env,
10
+ :git => git
11
+ }
12
+ yml = self.yaml_config
13
+ if yml
14
+ config[:configuration] = yml
15
+ config[:repo_token] = yml['repo_token'] || yml['repo_secret_token']
16
+ end
17
+ if ENV['COVERALLS_REPO_TOKEN']
18
+ config[:repo_token] = ENV['COVERALLS_REPO_TOKEN']
19
+ end
20
+ if ENV['COVERALLS_PARALLEL'] && ENV['COVERALLS_PARALLEL'] != "false"
21
+ config[:parallel] = true
22
+ end
23
+ if ENV['COVERALLS_FLAG_NAME']
24
+ config[:flag_name] = ENV['COVERALLS_FLAG_NAME']
25
+ end
26
+ if ENV['TRAVIS']
27
+ set_service_params_for_travis(config, yml ? yml['service_name'] : nil)
28
+ elsif ENV['CIRCLECI']
29
+ set_service_params_for_circleci(config)
30
+ elsif ENV['SEMAPHORE']
31
+ set_service_params_for_semaphore(config)
32
+ elsif ENV['JENKINS_URL'] || ENV['JENKINS_HOME']
33
+ set_service_params_for_jenkins(config)
34
+ elsif ENV['APPVEYOR']
35
+ set_service_params_for_appveyor(config)
36
+ elsif ENV['TDDIUM']
37
+ set_service_params_for_tddium(config)
38
+ elsif ENV['GITLAB_CI']
39
+ set_service_params_for_gitlab(config)
40
+ elsif ENV['COVERALLS_RUN_LOCALLY'] || Coveralls.testing
41
+ set_service_params_for_coveralls_local(config)
42
+ end
43
+
44
+ # standardized env vars
45
+ set_standard_service_params_for_generic_ci(config)
46
+
47
+ if service_name = ENV['COVERALLS_SERVICE_NAME']
48
+ config[:service_name] = service_name
49
+ end
50
+
51
+ config
52
+ end
53
+
54
+ def self.set_service_params_for_travis(config, service_name)
55
+ config[:service_job_id] = ENV['TRAVIS_JOB_ID']
56
+ config[:service_pull_request] = ENV['TRAVIS_PULL_REQUEST'] unless ENV['TRAVIS_PULL_REQUEST'] == 'false'
57
+ config[:service_name] = service_name || 'travis-ci'
58
+ config[:service_branch] = ENV['TRAVIS_BRANCH']
59
+ end
60
+
61
+ def self.set_service_params_for_circleci(config)
62
+ config[:service_name] = 'circleci'
63
+ config[:service_number] = ENV['CIRCLE_BUILD_NUM']
64
+ config[:service_pull_request] = (ENV['CI_PULL_REQUEST'] || "")[/(\d+)$/,1]
65
+ config[:parallel] = ENV['CIRCLE_NODE_TOTAL'].to_i > 1
66
+ config[:service_job_number] = ENV['CIRCLE_NODE_INDEX']
67
+ end
68
+
69
+ def self.set_service_params_for_semaphore(config)
70
+ config[:service_name] = 'semaphore'
71
+ config[:service_number] = ENV['SEMAPHORE_BUILD_NUMBER']
72
+ config[:service_pull_request] = ENV['PULL_REQUEST_NUMBER']
73
+ end
74
+
75
+ def self.set_service_params_for_jenkins(config)
76
+ config[:service_name] = 'jenkins'
77
+ config[:service_number] = ENV['BUILD_NUMBER']
78
+ config[:service_branch] = ENV['BRANCH_NAME']
79
+ config[:service_pull_request] = ENV['ghprbPullId']
80
+ end
81
+
82
+ def self.set_service_params_for_appveyor(config)
83
+ config[:service_name] = 'appveyor'
84
+ config[:service_number] = ENV['APPVEYOR_BUILD_VERSION']
85
+ config[:service_branch] = ENV['APPVEYOR_REPO_BRANCH']
86
+ config[:commit_sha] = ENV['APPVEYOR_REPO_COMMIT']
87
+ repo_name = ENV['APPVEYOR_REPO_NAME']
88
+ config[:service_build_url] = 'https://ci.appveyor.com/project/%s/build/%s' % [repo_name, config[:service_number]]
89
+ end
90
+
91
+ def self.set_service_params_for_tddium(config)
92
+ config[:service_name] = 'tddium'
93
+ config[:service_number] = ENV['TDDIUM_SESSION_ID']
94
+ config[:service_job_number] = ENV['TDDIUM_TID']
95
+ config[:service_pull_request] = ENV['TDDIUM_PR_ID']
96
+ config[:service_branch] = ENV['TDDIUM_CURRENT_BRANCH']
97
+ config[:service_build_url] = "https://ci.solanolabs.com/reports/#{ENV['TDDIUM_SESSION_ID']}"
98
+ end
99
+
100
+ def self.set_service_params_for_gitlab(config)
101
+ config[:service_name] = 'gitlab-ci'
102
+ config[:service_job_number] = ENV['CI_BUILD_NAME']
103
+ config[:service_job_id] = ENV['CI_BUILD_ID']
104
+ config[:service_branch] = ENV['CI_BUILD_REF_NAME']
105
+ config[:commit_sha] = ENV['CI_BUILD_REF']
106
+ end
107
+
108
+ def self.set_service_params_for_coveralls_local(config)
109
+ config[:service_job_id] = nil
110
+ config[:service_name] = 'coveralls-ruby'
111
+ config[:service_event_type] = 'manual'
112
+ end
113
+
114
+ def self.set_standard_service_params_for_generic_ci(config)
115
+ config[:service_name] ||= ENV['CI_NAME']
116
+ config[:service_number] ||= ENV['CI_BUILD_NUMBER']
117
+ config[:service_job_id] ||= ENV['CI_JOB_ID']
118
+ config[:service_build_url] ||= ENV['CI_BUILD_URL']
119
+ config[:service_branch] ||= ENV['CI_BRANCH']
120
+ config[:service_pull_request] ||= (ENV['CI_PULL_REQUEST'] || "")[/(\d+)$/,1]
121
+ end
122
+
123
+ def self.yaml_config
124
+ if self.configuration_path && File.exist?(self.configuration_path)
125
+ YAML::load_file(self.configuration_path)
126
+ end
127
+ end
128
+
129
+ def self.configuration_path
130
+ File.expand_path(File.join(self.root, ".coveralls.yml")) if self.root
131
+ end
132
+
133
+ def self.root
134
+ pwd
135
+ end
136
+
137
+ def self.pwd
138
+ Dir.pwd
139
+ end
140
+
141
+ def self.simplecov_root
142
+ if defined?(::SimpleCov)
143
+ ::SimpleCov.root
144
+ end
145
+ end
146
+
147
+ def self.rails_root
148
+ Rails.root.to_s
149
+ rescue
150
+ nil
151
+ end
152
+
153
+ def self.git
154
+ hash = {}
155
+
156
+ Dir.chdir(root) do
157
+
158
+ hash[:head] = {
159
+ :id => ENV.fetch("GIT_ID", `git log -1 --pretty=format:'%H'`),
160
+ :author_name => ENV.fetch("GIT_AUTHOR_NAME", `git log -1 --pretty=format:'%aN'`),
161
+ :author_email => ENV.fetch("GIT_AUTHOR_EMAIL", `git log -1 --pretty=format:'%ae'`),
162
+ :committer_name => ENV.fetch("GIT_COMMITTER_NAME", `git log -1 --pretty=format:'%cN'`),
163
+ :committer_email => ENV.fetch("GIT_COMMITTER_EMAIL", `git log -1 --pretty=format:'%ce'`),
164
+ :message => ENV.fetch("GIT_MESSAGE", `git log -1 --pretty=format:'%s'`)
165
+ }
166
+
167
+ # Branch
168
+ hash[:branch] = ENV.fetch("GIT_BRANCH", `git rev-parse --abbrev-ref HEAD`)
169
+
170
+ # Remotes
171
+ remotes = nil
172
+ begin
173
+ remotes = `git remote -v`.split(/\n/).map do |remote|
174
+ splits = remote.split(" ").compact
175
+ {:name => splits[0], :url => splits[1]}
176
+ end.uniq
177
+ rescue
178
+ end
179
+ hash[:remotes] = remotes
180
+
181
+ end
182
+
183
+ hash
184
+
185
+ rescue Exception => e
186
+ Coveralls::Output.puts "Coveralls git error:", :color => "red"
187
+ Coveralls::Output.puts e.to_s, :color => "red"
188
+ nil
189
+ end
190
+
191
+ def self.relevant_env
192
+ hash = {
193
+ :pwd => self.pwd,
194
+ :rails_root => self.rails_root,
195
+ :simplecov_root => simplecov_root,
196
+ :gem_version => VERSION
197
+ }
198
+
199
+ hash.merge! begin
200
+ if ENV['TRAVIS']
201
+ {
202
+ :travis_job_id => ENV['TRAVIS_JOB_ID'],
203
+ :travis_pull_request => ENV['TRAVIS_PULL_REQUEST'],
204
+ :branch => ENV['TRAVIS_BRANCH']
205
+ }
206
+ elsif ENV['CIRCLECI']
207
+ {
208
+ :circleci_build_num => ENV['CIRCLE_BUILD_NUM'],
209
+ :branch => ENV['CIRCLE_BRANCH'],
210
+ :commit_sha => ENV['CIRCLE_SHA1']
211
+ }
212
+ elsif ENV['JENKINS_URL']
213
+ {
214
+ :jenkins_build_num => ENV['BUILD_NUMBER'],
215
+ :jenkins_build_url => ENV['BUILD_URL'],
216
+ :branch => ENV['GIT_BRANCH'],
217
+ :commit_sha => ENV['GIT_COMMIT']
218
+ }
219
+ elsif ENV['SEMAPHORE']
220
+ {
221
+ :branch => ENV['BRANCH_NAME'],
222
+ :commit_sha => ENV['REVISION']
223
+ }
224
+ else
225
+ {}
226
+ end
227
+ end
228
+
229
+ hash
230
+ end
231
+
232
+ end
233
+ end