pronto 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c6eced888221992765e7822d10cc30c5bb425807
4
- data.tar.gz: 3691ca0e624f99993eff02d044fc76dc8f13b633
3
+ metadata.gz: 745decf88e9fb240c3a33e5ac1d0969872f74ef4
4
+ data.tar.gz: 256b5eb2b0dcb08bf3322dd29f4499d8cdd47bef
5
5
  SHA512:
6
- metadata.gz: 502260ec324f87bda046de5c75313abc8a48a2dc29c9c9f5339820ad40c683e1150e80013f9c5864b9f003a601759fcadfc99458fcb9424bf095aea02a0d4882
7
- data.tar.gz: 640af0dbfe133fa024ccd924ccd9496011a32d5001bb076a692ac9e833a36b3bbeeb5caa857ef33600f9e1c0929e221899827a1f42d5c4ecd608446651cd84c9
6
+ metadata.gz: 0880f55cf76eb358fc5668ba9ef18ee1182d3d4d43ca5fce301c5862701a0524a95caedf2a90719f58bacd17ed23bbcddfd585d80200f5cb7543617281f94d8a
7
+ data.tar.gz: acbd3f8bedf6e2a5a830ba254307e59cab146993268d8e23375a6c6ee9a32386e9a77dd7ac23d9f61eecbe6b8a79d2141d808b557a24bd69da6573d6d7a7e939
@@ -6,6 +6,12 @@
6
6
  ### Changes
7
7
  ### Bugs fixed
8
8
 
9
+ ## 0.5.1
10
+
11
+ ### Changes
12
+
13
+ * Try to retrieve commit sha for GitHub PR via GitHub API instead of trusting local sha.
14
+
9
15
  ## 0.5.0
10
16
 
11
17
  ### New features
@@ -31,7 +31,8 @@ module Pronto
31
31
 
32
32
  def create_pull_comment(comment)
33
33
  client.create_pull_comment(slug, pull_id, comment.body,
34
- comment.sha, comment.path, comment.position)
34
+ pull_sha || comment.sha,
35
+ comment.path, comment.position)
35
36
  end
36
37
 
37
38
  private
@@ -54,20 +55,29 @@ module Pronto
54
55
  auto_paginate: true)
55
56
  end
56
57
 
57
- def pull_requests
58
- @pull_requests ||= client.pull_requests(slug)
58
+ def pull_id
59
+ pull ? pull[:number].to_i : env_pull_id.to_i
59
60
  end
60
61
 
61
- def pull_id
62
- @pull_id ||= begin
63
- pull_id = ENV['PULL_REQUEST_ID']
64
- if pull_id
65
- pull_id.to_i
66
- elsif @repo.branch
67
- pull = pull_requests.find { |pr| pr[:head][:ref] == @repo.branch }
68
- pull[:number].to_i if pull
69
- end
70
- end
62
+ def env_pull_id
63
+ ENV['PULL_REQUEST_ID']
64
+ end
65
+
66
+ def pull_sha
67
+ pull[:head][:sha] if pull
68
+ end
69
+
70
+ def pull
71
+ return unless @repo.branch
72
+ @pull ||= if env_pull_id
73
+ pull_requests.find { |pr| pr[:number].to_i == env_pull_id.to_i }
74
+ else
75
+ pull_requests.find { |pr| pr[:head][:ref] == @repo.branch }
76
+ end
77
+ end
78
+
79
+ def pull_requests
80
+ @pull_requests ||= client.pull_requests(slug)
71
81
  end
72
82
 
73
83
  Comment = Struct.new(:sha, :body, :path, :position) do
@@ -1,3 +1,3 @@
1
1
  module Pronto
2
- VERSION = '0.5.0'
2
+ VERSION = '0.5.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pronto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mindaugas Mozūras