Class: Taeval::GitCheckout::GithubRepo
- Inherits:
-
Object
- Object
- Taeval::GitCheckout::GithubRepo
- Defined in:
- lib/taeval/git_checkout/github_repo.rb
Instance Method Summary collapse
- #clone ⇒ Object
-
#initialize(config, output, reporter) ⇒ GithubRepo
constructor
A new instance of GithubRepo.
- #validate ⇒ Object
Constructor Details
#initialize(config, output, reporter) ⇒ GithubRepo
Returns a new instance of GithubRepo.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/taeval/git_checkout/github_repo.rb', line 6 def initialize(config, output, reporter) @reporter = reporter @output = output @id = config[:id] @token = config[:token] @user = config[:user] @repo = config[:repo] @branch = config[:branch] @solution = config[:solution] @prefix = config[:prefix] @attr = config[:attr] end |
Instance Method Details
#clone ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/taeval/git_checkout/github_repo.rb', line 39 def clone url = "https://#{@user}:#{@token}@github.com/#{@user}/#{@repo}.git" cmd = "git clone #{url} --branch=#{@branch} #{@solution}/#{@repo}" stdout, stderr, status = Open3.capture3(cmd) @output.print "cloning #{url}", stdout, stderr @reporter.add(repo: @repo, runner: :git_checkout, msg: "#{status}; #{stderr}") if status != 0 end |
#validate ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/taeval/git_checkout/github_repo.rb', line 22 def validate url = "https://api.github.com/repos/#{@user}/#{@repo}" cmd = "curl -sL -H 'Authorization: token #{@token}' -H 'Accept: application/vnd.github.v3+json' #{url}" stdout, stderr, status = Open3.capture3(cmd) @output.print "validating #{url}", stdout, stderr repo_api_data = JSON.parse(stdout, symbolize_names: true) if stderr == '' && !repo_api_data.has_key?(:message) field_validate(repo_api_data) else @reporter.add(repo: @repo, runner: :git_checkout, msg: "status: #{status}; message: #{stderr}") if stderr != '' @reporter.add(repo: @repo, runner: :git_checkout, msg: "status: #{status}; message: #{repo_api_data[:message]}; url: #{url}") if repo_api_data.has_key?(:message) end end |