Method: Kennel::GithubReporter#initialize

Defined in:
lib/kennel/github_reporter.rb

#initialize(token, ref: "HEAD") ⇒ GithubReporter

Returns a new instance of GithubReporter.



15
16
17
18
19
20
21
22
23
24
# File 'lib/kennel/github_reporter.rb', line 15

def initialize(token, ref: "HEAD")
  @token = token
  commit = Utils.capture_sh("git show #{ref}")
  @sha = commit[/^Merge: \S+ (\S+)/, 1] || commit[/\Acommit (\S+)/, 1] || raise("Unable to find commit")
  @pr = commit[/^\s+.*\(#(\d+)\)/, 1] # from squash
  @repo_part = ENV["GITHUB_REPOSITORY"] || begin
    origin = ENV["PROJECT_REPOSITORY"] || Utils.capture_sh("git remote -v").split("\n").first
    origin[%r{github\.com[:/](\S+?)(\.git|$)}, 1] || raise("no origin found in #{origin}")
  end
end