code_review_notifier 0.1.2 → 0.1.3
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 +4 -4
- data/lib/code_review_notifier.rb +17 -5
- data/lib/gerrit_api.rb +7 -2
- data/lib/notifier.rb +19 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6de431ed11fa0855c6ed44e294a4b8a76bd69ad845c1ea9bfacdd9a326e0b66
|
4
|
+
data.tar.gz: 0b084e6c55eda7ee644232ad770ad2bde38b43f12c1bea6f209d2ebce816b6dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28eae7ef98c923678e89c54d3a23c73dd4ff649ce55fcb7ee9f51a80ea0e74e331aae31f878c432fdb6657e27f275afffce16001ffd5bdeb341f095235207f0c
|
7
|
+
data.tar.gz: b586a847bca12814d570e2f73ace4d5860cf144e0024ea503994cdc5846e489f88416f3b0847731a6feb6f40cc90714fa96aca2afb6f3c1ac17782ac44f9e175
|
data/lib/code_review_notifier.rb
CHANGED
@@ -2,7 +2,7 @@ require "io/console"
|
|
2
2
|
require_relative "./api.rb"
|
3
3
|
require_relative "./notifier.rb"
|
4
4
|
|
5
|
-
SECONDS_BETWEEN_RUNS =
|
5
|
+
SECONDS_BETWEEN_RUNS = 90
|
6
6
|
SECONDS_BETWEEN_NOTIFICATIONS = 5
|
7
7
|
|
8
8
|
class CodeReviewNotifier
|
@@ -10,7 +10,7 @@ class CodeReviewNotifier
|
|
10
10
|
system("mkdir -p ~/.code_review_notifier")
|
11
11
|
system("brew bundle --file #{File.expand_path(File.dirname(__FILE__) + "/..")}/Brewfile")
|
12
12
|
|
13
|
-
if args[0] == "--setup"
|
13
|
+
if args[0] == "--setup"
|
14
14
|
print("What's the base URL? (i.e. https://gerrit.google.com) ")
|
15
15
|
DB.save_setting("base_api_url", STDIN.gets.chomp, is_secret: false)
|
16
16
|
|
@@ -25,6 +25,18 @@ class CodeReviewNotifier
|
|
25
25
|
DB.save_setting("account_id", STDIN.gets.chomp, is_secret: false)
|
26
26
|
|
27
27
|
puts("All setup!")
|
28
|
+
puts
|
29
|
+
puts("It's recommended that you set this up as a system service with serviceman. Check it out here: https://git.rootprojects.org/root/serviceman")
|
30
|
+
puts("Set code_review_notifier to run on startup with `serviceman add --name code_review_notifier code_review_notifier`")
|
31
|
+
exit
|
32
|
+
end
|
33
|
+
|
34
|
+
if !Api.current_api.is_setup?
|
35
|
+
Notifier.notify("Missing Setup Info", "Run `code_review_notifier --setup` to setup.")
|
36
|
+
puts
|
37
|
+
puts("You must finish setup first by running with the `--setup` option.")
|
38
|
+
puts("`code_review_notifier --setup`")
|
39
|
+
exit
|
28
40
|
end
|
29
41
|
end
|
30
42
|
|
@@ -48,11 +60,11 @@ class CodeReviewNotifier
|
|
48
60
|
code_change_activity.notified
|
49
61
|
unless is_first_run
|
50
62
|
puts("Notifying of change!")
|
51
|
-
Notifier.
|
52
|
-
sleep
|
63
|
+
Notifier.notify_about_code_change(code_change_activity)
|
64
|
+
sleep(SECONDS_BETWEEN_NOTIFICATIONS)
|
53
65
|
end
|
54
66
|
end
|
55
|
-
sleep
|
67
|
+
sleep(SECONDS_BETWEEN_RUNS)
|
56
68
|
end
|
57
69
|
end
|
58
70
|
|
data/lib/gerrit_api.rb
CHANGED
@@ -11,8 +11,13 @@ class GerritApi < BaseApi
|
|
11
11
|
},
|
12
12
|
follow_redirects: false
|
13
13
|
})
|
14
|
-
|
15
|
-
|
14
|
+
set_cookie_header = res.headers["set-cookie"] || ""
|
15
|
+
@token = set_cookie_header.match("GerritAccount=(.*?);")&.to_a&.fetch(1)
|
16
|
+
if @token.nil?
|
17
|
+
Notifier.notify("Incorrect Credentials", "Trying running `code_review_notifier --setup` again.")
|
18
|
+
sleep(120)
|
19
|
+
exit
|
20
|
+
end
|
16
21
|
end
|
17
22
|
|
18
23
|
def self.all_code_changes
|
data/lib/notifier.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require_relative './api.rb'
|
2
2
|
|
3
3
|
class Notifier
|
4
|
-
def self.
|
4
|
+
def self.notify_about_code_change(code_change_activity)
|
5
5
|
code_change = code_change_activity.code_change
|
6
6
|
id = code_change.id
|
7
7
|
owner = code_change.owner
|
@@ -9,6 +9,23 @@ class Notifier
|
|
9
9
|
|
10
10
|
message = code_change_activity.message
|
11
11
|
author = code_change_activity.author
|
12
|
-
|
12
|
+
notify(author, message, "#{owner}: #{subject}", Api.current_api.favicon, Api.current_api.code_change_url(code_change))
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.notify(title, message, subtitle = nil, icon = nil, url = nil)
|
16
|
+
args = {
|
17
|
+
"title" => title,
|
18
|
+
"message" => message,
|
19
|
+
"subtitle" => subtitle,
|
20
|
+
"appIcon" => icon,
|
21
|
+
"open" => url
|
22
|
+
}
|
23
|
+
all_args = args.keys.reduce("") do |arg_string, key|
|
24
|
+
if args[key]
|
25
|
+
arg_string += " -#{key} '#{args[key]}'"
|
26
|
+
end
|
27
|
+
arg_string
|
28
|
+
end
|
29
|
+
system("/usr/local/bin/terminal-notifier #{all_args}")
|
13
30
|
end
|
14
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: code_review_notifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kyle Grinstead
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: kyleag@hey.com
|