class CommitLive::Github
Attributes
netrc[RW]
post_details[RW]
sentry[RW]
Public Class Methods
new()
click to toggle source
# File lib/commit-live/github.rb, line 9 def initialize() @netrc = CommitLive::NetrcInteractor.new() @sentry = CommitLive::Sentry.new() end
Public Instance Methods
getAttr(attr)
click to toggle source
# File lib/commit-live/github.rb, line 24 def getAttr(attr) if !attr.nil? post_details.fetch(attr) end end
getValue(key)
click to toggle source
# File lib/commit-live/github.rb, line 30 def getValue(key) data = getAttr('data') data[key] end
owner()
click to toggle source
# File lib/commit-live/github.rb, line 19 def owner netrc.read(machine: 'ga-extra') netrc.login end
post(repo_name, isFork = false)
click to toggle source
# File lib/commit-live/github.rb, line 35 def post(repo_name, isFork = false) enc_url = "/v2/github/createPullRequest" log_title = "#{owner} - Pull Request Failed" if isFork enc_url = URI.escape("/v2/github/createFork") log_title = "#{owner} - Lesson Forked Failed" end begin Timeout::timeout(60) do response = CommitLive::API.new().post( enc_url, headers: { 'Authorization' => "#{token}", 'Content-Type' => 'application/json' }, body: { "repoUrl": repo_name } ) @post_details = JSON.parse(response.body) if response.status != 200 && !response.body.match(/A pull request already exists/) sentry.log_message(log_title, { 'url' => enc_url, 'repo_name' => repo_name, 'response-body' => response.body, 'response-status' => response.status } ) end end rescue Timeout::Error sentry.log_message(log_title, { 'url' => enc_url, 'track_name' => repo_name } ) end end
token()
click to toggle source
# File lib/commit-live/github.rb, line 14 def token netrc.read netrc.password end