kennel 1.91.3 → 1.92.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7a85c311024f48c14e9e346eb863a47fbb67239f5d83cd82eddea6f53742ec74
4
- data.tar.gz: 672ef53f76ee577f9f976ee9432f06f1e56d426bef74020d50850863e851635a
3
+ metadata.gz: 9c49a8d3df01c51505bd27350f74dde6f4211fe576a97857e68f27f5d86aae4d
4
+ data.tar.gz: 72641a908961fe238b70a59d3e952abfccc83bd9522c12757f0d436993f73263
5
5
  SHA512:
6
- metadata.gz: 8407d6564013f12ce1e00e1394eb742b7f721fe9302396d821c8c3441c62e4e30781b9681f430dcedb96e3c757a740b9604a2c56194afabdabd69ed52f8c1a27
7
- data.tar.gz: efceaa72bc4ff084e1d8bd54ed79dbcaa021d6a95897fa66465dbec686b0712f05a153198b3c882029df08812b93353ed3061c34c5f4c5f1303b826bc3d17711
6
+ metadata.gz: 1789814bea2d153d1428a751ce1b56dbdbd89714cc81608e4a133ae05377a55c724a26809419c995224f5f669387f5116926eb558646307a3415cb0672b10da5
7
+ data.tar.gz: 69ea27ba49933d745bf5cf362cb4361bee0bdf74cd4934fad6616b5ec9ba52216e4a5e365723550792c64a866d114b328c3c61483cce5b7b5ec0d2b21cdc476b
@@ -8,13 +8,15 @@ module Kennel
8
8
  class << self
9
9
  def report(token, &block)
10
10
  return yield unless token
11
- new(token, Utils.capture_sh("git rev-parse HEAD").strip).report(&block)
11
+ new(token).report(&block)
12
12
  end
13
13
  end
14
14
 
15
- def initialize(token, git_sha)
15
+ def initialize(token, ref: "HEAD")
16
16
  @token = token
17
- @git_sha = git_sha
17
+ commit = Utils.capture_sh("git show #{ref}")
18
+ @sha = commit[/^Merge: \S+ (\S+)/, 1] || commit[/\Acommit (\S+)/, 1] || raise("Unable to find commit")
19
+ @pr = commit[/^\s+.*\(#(\d+)\)/, 1] # from squash
18
20
  @repo_part = ENV["GITHUB_REPOSITORY"] || begin
19
21
  origin = ENV["PROJECT_REPOSITORY"] || Utils.capture_sh("git remote -v").split("\n").first
20
22
  origin[%r{github\.com[:/](\S+?)(\.git|$)}, 1] || raise("no origin found in #{origin}")
@@ -37,13 +39,14 @@ module Kennel
37
39
  body = body.byteslice(0, MAX_COMMENT_SIZE - TRUNCATED_MSG.bytesize) + TRUNCATED_MSG
38
40
  end
39
41
 
40
- post "commits/#{@git_sha}/comments", body: body
42
+ path = (@pr ? "/repos/#{@repo_part}/issues/#{@pr}/comments" : "/repos/#{@repo_part}/commits/#{@sha}/comments")
43
+ post path, body: body
41
44
  end
42
45
 
43
46
  private
44
47
 
45
48
  def post(path, data)
46
- url = "https://api.github.com/repos/#{@repo_part}/#{path}"
49
+ url = "https://api.github.com#{path}"
47
50
  response = Faraday.post(url, data.to_json, authorization: "token #{@token}")
48
51
  raise "failed to POST to github:\n#{url} -> #{response.status}\n#{response.body}" unless response.status == 201
49
52
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Kennel
3
- VERSION = "1.91.3"
3
+ VERSION = "1.92.0"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kennel
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.91.3
4
+ version: 1.92.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-17 00:00:00.000000000 Z
11
+ date: 2021-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday