File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77
88gem "colorize"
99gem "json"
10+ gem "pry"
1011gem "rake" , "~> 13.0"
1112gem "rest-client"
1213gem "rspec" , "~> 3.0"
1314gem "rubocop" , "~> 1.21"
14- gem "pry"
Original file line number Diff line number Diff line change @@ -26,10 +26,10 @@ Gem::Specification.new do |spec|
2626 spec . require_paths = [ "lib" ]
2727
2828 # Uncomment to register a new dependency of your gem
29+ spec . add_dependency ( "colorize" )
2930 spec . add_dependency ( "json" )
3031 spec . add_dependency ( "optparse" )
3132 spec . add_dependency ( "rest-client" )
32- spec . add_dependency ( "colorize" )
3333
3434 # For more information and examples about making a new gem, check out our
3535 # guide at: https://bundler.io/guides/creating_gem.html
Original file line number Diff line number Diff line change 11# frozen_string_literal: true
22
33require_relative "codeclimate_diff/version"
4+ require "yaml"
45
56module CodeclimateDiff
6- class Configuration
7- attr_accessor :gitlab ,
8- :github
9-
10- def initialize
11- @gitlab = {
12- main_branch_name : "main" ,
13- download_baseline_from_pipeline : false ,
14- project_id : nil ,
15- host : nil ,
16- personal_access_token : nil
17- }
18-
19- @github = {
20- # TODO: Add GitHub requirements
21- }
22- end
23- end
24-
257 class << self
268 def configuration
27- @configuration ||= Configuration . new
28- end
29-
30- def configure
31- yield ( configuration )
9+ YAML . load_file ( "./.codeclimate_diff.yml" )
3210 end
3311 end
3412end
Original file line number Diff line number Diff line change 11# frozen_string_literal: true
22
33require "rest-client"
4- require "yaml"
54
65module CodeclimateDiff
76 class Downloader
8-
97 def self . refresh_baseline_if_configured
10-
11- config = YAML . load_file ( "./.codeclimate_diff.yml" )
12-
13- puts config
14-
15- should_download = config [ 'gitlab' ] [ 'download_baseline_for_pipeline' ]
8+ should_download = CodeclimateDiff . configuration [ "gitlab" ] [ "download_baseline_for_pipeline" ]
169 return unless should_download
1710
18- puts "downloading baseline file from gitlab"
19- branch_name = config [ ' gitlab' ] [ ' main_branch_name' ]
20- project_id = config [ ' gitlab' ] [ ' project_id' ]
21- host = config [ ' gitlab' ] [ ' host' ]
22- personal_access_token = config [ ' gitlab' ] [ ' personal_access_token' ]
11+ puts "Downloading baseline file from gitlab"
12+ branch_name = CodeclimateDiff . configuration [ " gitlab" ] [ " main_branch_name" ]
13+ project_id = CodeclimateDiff . configuration [ " gitlab" ] [ " project_id" ]
14+ host = CodeclimateDiff . configuration [ " gitlab" ] [ " host" ]
15+ personal_access_token = CodeclimateDiff . configuration [ " gitlab" ] [ " personal_access_token" ]
2316
2417 # curl --output codeclimate_diff_baseline.json --header "PRIVATE-TOKEN: MYTOKEN" "https://gitlab.digitalnz.org/api/v4/projects/85/jobs/artifacts/main/raw/codeclimate_diff_baseline.json?job=code_quality"
2518 url = "#{ host } /api/v4/projects/#{ project_id } /jobs/artifacts/#{ branch_name } /raw/codeclimate_diff_baseline.json?job=code_quality"
Original file line number Diff line number Diff line change @@ -11,7 +11,8 @@ module CodeclimateDiff
1111 class Runner
1212 def self . calculate_changed_filenames ( pattern )
1313 extra_grep_filter = pattern ? " | grep '#{ pattern } '" : ""
14- files_changed = `git diff --name-only main | grep --invert-match spec/ | grep --extended-regexp '.js$|.rb$'#{ extra_grep_filter } `
14+ branch_name = CodeclimateDiff . configuration [ "gitlab" ] [ "main_branch_name" ]
15+ files_changed = `git diff --name-only #{ branch_name } | grep --invert-match spec/ | grep --extended-regexp '.js$|.rb$'#{ extra_grep_filter } `
1516 files_changed . split ( "\n " )
1617 end
1718
You can’t perform that action at this time.
0 commit comments