code_review_notifier 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/base_api.rb +4 -0
- data/lib/gerrit_api.rb +7 -3
- data/lib/models/code_change.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69b61c9f19daf4e8a85cfef15ffe035d232a5352a7240b326fadc8930b85bf9f
|
4
|
+
data.tar.gz: 1e2f0b33a43e4db336fc20a2ee99a9c5e79b3da9856f48b15ac04daa87f180fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3fe2b9b7ef4e7b40b2e8e3581ba8ba73b7e8c93686a32c93be4f5dfd6ab9534c7aaf8016d59994ebd9bd7ec45df9260d62e91d000ba459425309b8dd2eecd5d4
|
7
|
+
data.tar.gz: f79a7ab782fd1f7d73fb6ceead88144523cb39ea7cb7228563ff2393d7941bf296083af15e66ac563dd41d8ffffa4ee65fcba82781e7d59b891d4020ad93f34b
|
data/lib/base_api.rb
CHANGED
data/lib/gerrit_api.rb
CHANGED
@@ -4,6 +4,7 @@ require_relative "./models/code_change_activity.rb"
|
|
4
4
|
|
5
5
|
class GerritApi < BaseApi
|
6
6
|
def self.authenticate
|
7
|
+
@token = nil
|
7
8
|
res = post("/login/", {
|
8
9
|
body: "username=#{username}&password=#{URI.escape(password)}&rememberme=1",
|
9
10
|
headers: {
|
@@ -12,11 +13,14 @@ class GerritApi < BaseApi
|
|
12
13
|
follow_redirects: false
|
13
14
|
})
|
14
15
|
set_cookie_header = res.headers["set-cookie"] || ""
|
15
|
-
|
16
|
-
if
|
16
|
+
token = set_cookie_header.match("GerritAccount=(.*?);")&.to_a&.fetch(1)
|
17
|
+
if token.nil?
|
17
18
|
Notifier.notify("Incorrect Credentials", "Trying running `code_review_notifier --setup` again.")
|
18
19
|
sleep(120)
|
19
20
|
exit
|
21
|
+
else
|
22
|
+
DB.save_setting("api_token", token, is_secret: true)
|
23
|
+
token
|
20
24
|
end
|
21
25
|
end
|
22
26
|
|
@@ -24,7 +28,7 @@ class GerritApi < BaseApi
|
|
24
28
|
wrap_with_authentication do
|
25
29
|
get("/changes/?S=0&q=is%3Aopen%20owner%3Aself%20-is%3Awip%20-is%3Aignored%20limit%3A25&q=is%3Aopen%20owner%3Aself%20is%3Awip%20limit%3A25&q=is%3Aopen%20-owner%3Aself%20-is%3Awip%20-is%3Aignored%20reviewer%3Aself%20limit%3A25&q=is%3Aclosed%20-is%3Aignored%20%28-is%3Awip%20OR%20owner%3Aself%29%20%28owner%3Aself%20OR%20reviewer%3Aself%29%20-age%3A4w%20limit%3A10&o=DETAILED_ACCOUNTS&o=MESSAGES", {
|
26
30
|
headers: {
|
27
|
-
"Cookie" => "GerritAccount=#{
|
31
|
+
"Cookie" => "GerritAccount=#{token};"
|
28
32
|
}
|
29
33
|
})
|
30
34
|
end.parsed_response.flat_map { |js| js.map { |j| code_change_from_json(j) } }
|
data/lib/models/code_change.rb
CHANGED