hubstats 0.0.19 → 0.0.20

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MDIwZjQ4NTg1MjA4NzA1OTQ3ZTk4ZTVhYWUwNzFmMjE2ZWQ3YzMyYw==
4
+ NGU1YzA2ZmVmOTA5NTMzNzdhMTk3NDllZjczNzI2NTc4YjY3ZDZlOQ==
5
5
  data.tar.gz: !binary |-
6
- Nzg3Y2I2Y2UxYWY5MDdkZjBlYzc3NmMzZGNiNTk4MjkzNjk2NzEyZA==
6
+ MWJlNDA1MDAxZWZmNDFjNzE5ZjI0OGUxZjQxYmZhYzRmYmU4YzJmOA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZTVlZWY4ZWQ0YmJjZDY5ZWNjNTYwMTg4YjFkNTliNTBiNzgyYTAyZDZlNzY1
10
- Yjc5OTdhMzc0Yjg4NzdhYTNjYjg0YjM4ZmI0MGQ5MDQ4NzFmMDFjNGY0YzRm
11
- OTJlOTVjY2UwMWY3OTU1M2I3NjBhZTQwZDEwYWFiOGU4M2I2Zjc=
9
+ YTQ1YmJlYmE3ZjkxNTcxMzliZTRhMWMwZGRkOTAyMTc1MmZmM2IyZmViNmNi
10
+ ZTJlMmNjOGQ4N2RkZGExNTUyMTA4YmQzYWE1ZmIzZGIwYjE2N2ExOTMzYjZk
11
+ N2I2MjRjMWM0NjkwZmQyNzI5MjA4YmQ3Y2IzZTlkMGE5NWU5Yjk=
12
12
  data.tar.gz: !binary |-
13
- Y2I0ZDMzZDg0Mjc3YjhiYzRiYjhmMTlhOTMxMjYxZTFlYmMwNjhhMzI4Nzli
14
- ODA4NGQ2YmRjMGVkMjQ1ZTUyNjE3ZDVhMjFjZGE2ZmU1ODhkZTdkNjJhNWEw
15
- NGYxN2NlODVkOGM2ZDM3NjZkMmFhMzM1OWJhNmE2NjRlMGU2NTU=
13
+ MjJmYjg3MTE5N2Y5NTM5ZDRlMDY5ODgyMmQ0NTEyZDFhZGExYjNmNTUzZmUx
14
+ Y2RiN2Y5MzNlOWU2Mzg1ZTZjZWI5MjdkNmUyNzVkZDk0MWMyMTBjZGI2ODcy
15
+ NjAxNjcwMmJkZTU1ZjM3ODZkODI4NmJmYmU1YjE5ZTg2NTA3ZDQ=
@@ -17,5 +17,13 @@ module Hubstats
17
17
 
18
18
  has_and_belongs_to_many :pull_requests, :join_table => 'hubstats_labels_pull_requests'
19
19
 
20
+ def self.first_or_create(label)
21
+ if exists = Hubstats::Label.where(name: label[:name]).first
22
+ return exists
23
+ else
24
+ Hubstats::Label.new(name: label[:name], url: label[:url], color: label[:color])
25
+ end
26
+ end
27
+
20
28
  end
21
29
  end
@@ -40,7 +40,7 @@ module Hubstats
40
40
  end
41
41
 
42
42
  def add_labels(labels)
43
- labels.map!{|v| Hubstats::Label.where(name: v.name).first}
43
+ labels.map!{ |label| Hubstats::Label.first_or_create(label) }
44
44
  self.labels = labels
45
45
  end
46
46
 
@@ -17,8 +17,10 @@ module Hubstats
17
17
  def pull_processor(payload)
18
18
  pull_request = payload[:pull_request]
19
19
  pull_request[:repository] = payload[:repository]
20
-
21
- Hubstats::PullRequest.create_or_update(pull_request.with_indifferent_access)
20
+ new_pull = Hubstats::PullRequest.create_or_update(pull_request.with_indifferent_access)
21
+ repo_name = Hubstats::Repo.where(id: new_pull.repo_id).first.full_name
22
+ labels = Hubstats::GithubAPI.get_labels(repo_name, new_pull.number )
23
+ new_pull.add_labels(labels)
22
24
  end
23
25
 
24
26
  def comment_processor(payload,kind)
@@ -111,6 +111,12 @@ module Hubstats
111
111
  end
112
112
  end
113
113
 
114
+ def self.get_labels(repo_name, pull_request_number)
115
+ issue = Hubstats::GithubAPI.client.issue(repo_name, pull_request_number)
116
+ issue[:labels]
117
+ end
118
+
119
+
114
120
  def self.wait_limit(grab_size,rate_limit)
115
121
  if rate_limit.remaining < grab_size
116
122
  puts "Hit Github rate limit, waiting #{Time.at(rate_limit.resets_in).utc.strftime("%H:%M:%S")} to get more"
@@ -1,3 +1,3 @@
1
1
  module Hubstats
2
- VERSION = "0.0.19"
2
+ VERSION = "0.0.20"
3
3
  end
Binary file