lazylead 0.4.3 → 0.6.1
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/.docs/accuracy.md +2 -2
- data/.docs/duedate_expired.md +3 -3
- data/.docs/propagate_down.md +3 -3
- data/.gitattributes +1 -0
- data/Rakefile +6 -3
- data/bin/lazylead +7 -5
- data/lazylead.gemspec +4 -3
- data/lib/lazylead/cli/app.rb +11 -3
- data/lib/lazylead/exchange.rb +15 -9
- data/lib/lazylead/log.rb +2 -1
- data/lib/lazylead/model.rb +42 -1
- data/lib/lazylead/opts.rb +13 -0
- data/lib/lazylead/postman.rb +13 -7
- data/lib/lazylead/schedule.rb +16 -15
- data/lib/lazylead/smtp.rb +3 -1
- data/lib/lazylead/system/jira.rb +65 -4
- data/lib/lazylead/task/accuracy/accuracy.rb +13 -8
- data/lib/lazylead/task/accuracy/affected_build.rb +2 -6
- data/lib/lazylead/task/accuracy/attachment.rb +44 -0
- data/lib/lazylead/task/accuracy/environment.rb +39 -0
- data/lib/lazylead/task/accuracy/logs.rb +42 -0
- data/lib/lazylead/task/accuracy/records.rb +45 -0
- data/lib/lazylead/task/accuracy/requirement.rb +9 -0
- data/lib/lazylead/task/accuracy/servers.rb +50 -0
- data/lib/lazylead/task/accuracy/stacktrace.rb +103 -0
- data/lib/lazylead/task/accuracy/testcase.rb +92 -0
- data/lib/lazylead/task/accuracy/wiki.rb +41 -0
- data/lib/lazylead/task/assignment.rb +96 -0
- data/lib/lazylead/task/echo.rb +18 -0
- data/lib/lazylead/task/fix_version.rb +13 -2
- data/lib/lazylead/task/svn/diff.rb +85 -0
- data/lib/lazylead/task/svn/grep.rb +111 -0
- data/lib/lazylead/task/svn/touch.rb +101 -0
- data/lib/lazylead/version.rb +1 -1
- data/lib/messages/illegal_assignee_change.erb +123 -0
- data/lib/messages/illegal_fixversion_change.erb +2 -0
- data/lib/messages/svn_diff.erb +110 -0
- data/lib/messages/svn_diff_attachment.erb +117 -0
- data/lib/messages/svn_grep.erb +114 -0
- data/license.txt +1 -1
- data/readme.md +5 -5
- data/test/lazylead/cli/app_test.rb +11 -11
- data/test/lazylead/model_test.rb +10 -0
- data/test/lazylead/system/jira_test.rb +41 -4
- data/test/lazylead/task/accuracy/accuracy_test.rb +1 -1
- data/test/lazylead/task/accuracy/affected_build_test.rb +2 -2
- data/test/lazylead/task/accuracy/attachment_test.rb +50 -0
- data/test/lazylead/task/accuracy/environment_test.rb +42 -0
- data/test/lazylead/task/accuracy/logs_test.rb +138 -0
- data/test/lazylead/task/accuracy/records_test.rb +60 -0
- data/test/lazylead/task/accuracy/score_test.rb +46 -0
- data/test/lazylead/task/accuracy/servers_test.rb +66 -0
- data/test/lazylead/task/accuracy/stacktrace_test.rb +340 -0
- data/test/lazylead/task/accuracy/testcase_test.rb +254 -0
- data/test/lazylead/task/accuracy/wiki_test.rb +40 -0
- data/test/lazylead/task/assignment_test.rb +53 -0
- data/test/lazylead/task/svn/diff_test.rb +97 -0
- data/test/lazylead/task/svn/grep_test.rb +61 -0
- data/test/lazylead/task/{touch_test.rb → svn/touch_test.rb} +8 -8
- data/test/test.rb +16 -0
- data/upgrades/sqlite/001-install-main-lazylead-tables.sql +1 -5
- data/upgrades/sqlite/999.testdata.sql +13 -17
- metadata +72 -20
- data/.travis.yml +0 -16
- data/lib/lazylead/task/touch.rb +0 -104
@@ -23,21 +23,21 @@
|
|
23
23
|
# OR OTHER DEALINGS IN THE SOFTWARE.
|
24
24
|
|
25
25
|
require "mail"
|
26
|
-
require_relative "
|
27
|
-
require_relative "
|
28
|
-
require_relative "
|
29
|
-
require_relative "
|
30
|
-
require_relative "
|
26
|
+
require_relative "../../../test"
|
27
|
+
require_relative "../../../../lib/lazylead/smtp"
|
28
|
+
require_relative "../../../../lib/lazylead/opts"
|
29
|
+
require_relative "../../../../lib/lazylead/postman"
|
30
|
+
require_relative "../../../../lib/lazylead/task/svn/touch"
|
31
31
|
|
32
32
|
module Lazylead
|
33
|
-
class
|
33
|
+
class TouchTest < Lazylead::Test
|
34
34
|
test "important files changed in svn repo" do
|
35
35
|
skip "No svn credentials provided" unless env? "svn_touch_user",
|
36
36
|
"svn_touch_password"
|
37
37
|
skip "No internet connection to riouxsvn.com" unless ping? "riouxsvn.com"
|
38
38
|
Lazylead::Smtp.new.enable
|
39
|
-
Task::
|
40
|
-
|
39
|
+
Task::Svn::Touch.new.run(
|
40
|
+
[],
|
41
41
|
Postman.new,
|
42
42
|
Opts.new(
|
43
43
|
"svn_url" => "https://svn.riouxsvn.com/touch4ll",
|
data/test/test.rb
CHANGED
@@ -111,6 +111,22 @@ module Lazylead
|
|
111
111
|
.body.parts.first.body.raw_source
|
112
112
|
end
|
113
113
|
|
114
|
+
# Assert that email sent using 'mail' gem in test mode
|
115
|
+
# has expected subject and line with expected words
|
116
|
+
# @todo #/DEV Gem 'mail' sends email as a single line, find a way how to add
|
117
|
+
# symbol '\n' to each line for email during unit testing.
|
118
|
+
def assert_email_line(subject, words)
|
119
|
+
words = [words] unless words.respond_to? :each
|
120
|
+
mail = Mail::TestMailer.deliveries
|
121
|
+
.filter { |m| m.subject.eql? subject }
|
122
|
+
.first
|
123
|
+
.body.parts.first.body.raw_source
|
124
|
+
.split("\n")
|
125
|
+
.reject(&:blank?)
|
126
|
+
assert mail.any? { |line| words.all? { |w| line.include? w } },
|
127
|
+
"Words '#{words.join(',')}' wasn't found in '#{mail.join('\n')}'"
|
128
|
+
end
|
129
|
+
|
114
130
|
# Ping remote host
|
115
131
|
# https://github.com/eitoball/net-ping
|
116
132
|
# https://stackoverflow.com/a/35508446/6916890
|
@@ -46,11 +46,7 @@ create table if not exists tasks
|
|
46
46
|
(
|
47
47
|
id integer primary key,
|
48
48
|
name text not null,
|
49
|
-
|
50
|
-
-- @todo #/DEV task.cron - add support for non-cron based schedule like at, once, every.
|
51
|
-
-- More details:
|
52
|
-
-- https://github.com/jmettraux/rufus-scheduler
|
53
|
-
-- https://stackoverflow.com/questions/46691666/using-constantize-to-invoke-both-a-class-and-method-from-separate-strings
|
49
|
+
schedule text not null,
|
54
50
|
system integer not null,
|
55
51
|
action text not null,
|
56
52
|
team_id integer not null,
|
@@ -22,24 +22,20 @@
|
|
22
22
|
* OR OTHER DEALINGS IN THE SOFTWARE.
|
23
23
|
*/
|
24
24
|
insert into systems(id, properties)
|
25
|
-
values (1,
|
26
|
-
|
27
|
-
(2,
|
28
|
-
'{"type":"Lazylead::Jira", "username":"${jsi_usr}", "password":"${jsi_psw}", "site":"https://jira.spring.io", "context_path":""}');
|
25
|
+
values (1,'{"type":"Lazylead::Jira", "username":"", "password":"", "site":"https://jira.spring.io", "context_path":""}'),
|
26
|
+
(2,'{"type":"Lazylead::Jira", "username":"${jsi_usr}", "password":"${jsi_psw}", "site":"https://jira.spring.io", "context_path":""}');
|
29
27
|
insert into teams(id, name, properties)
|
30
28
|
values (1, 'BA squad', '{"from":"basquad@fake.com", "usr":"${usr}"}'),
|
31
29
|
(154, 'Team for issue #154', '{"cc":"lead@fake.com"}');
|
32
|
-
insert into tasks(name,
|
33
|
-
values ('echo', '
|
34
|
-
('expired due date', '
|
35
|
-
|
36
|
-
|
37
|
-
('task with cc', '* * * * *', 'false', 3, 1, 1, 'Lazylead::Task::Echo',
|
38
|
-
'{"cc":"leelakenny@mail.com,maciecrane@mail.com"}'),
|
39
|
-
('task', '* * * * *', 'false', 4, 2, 1, 'Lazylead::Task::Echo', '{}'),
|
30
|
+
insert into tasks(name, schedule, enabled, id, system, team_id, action, properties)
|
31
|
+
values ('echo', 'cron:* * * * *', 'false', 1, 1, 1, 'Lazylead::Task::Echo', '{}'),
|
32
|
+
('expired due date', 'cron:* * * * *', 'false', 2, 1, 1,'Lazylead::Task::Notification','{"sql":"filter=100500","subject":"[DD] PDTN!","template":"lib/messages/due_date_expired.erb"}'),
|
33
|
+
('task with cc', 'cron:* * * * *', 'false', 3, 1, 1, 'Lazylead::Task::Echo','{"cc":"leelakenny@mail.com,maciecrane@mail.com"}'),
|
34
|
+
('task', 'cron:* * * * *', 'false', 4, 2, 1, 'Lazylead::Task::Echo', '{}'),
|
40
35
|
('pman', '', '', 5, 2, 1, '', '{"postman":"Lazylead::Postman"}'),
|
41
|
-
('issue 154', '
|
42
|
-
('task with complex cc', '
|
43
|
-
|
44
|
-
('issue
|
45
|
-
('issue
|
36
|
+
('issue 154', '', 'false', 154, 1, 154, 'Lazylead::Task::AssigneeAlert', '{}'),
|
37
|
+
('task with complex cc', '', 'false', 165, 1, 1, 'Lazylead::Task::Echo','{"cc":{"type":"Lazylead::PredefinedCC","opts": {"jvm":"tom@fake.com","jdbc":"mike@fake.com"}}}'),
|
38
|
+
('issue 171', '', 'false', 171, 1, 1, 'Lazylead::Task::Echo', '{"envkey":"${key171}"}'),
|
39
|
+
('issue 195', '', 'false', 195, 1, 1, 'Lazylead::Task::Accuracy', '{"key":"value"}'),
|
40
|
+
('issue 130', 'in:0.001s', 'true', 130, 1, 1, 'Lazylead::Task::EchoIO', '{}'),
|
41
|
+
('issue 260', 'cron:* * * * *', 'false', 260, 1, 1, 'Lazylead::Task::EchoIO', '{abc}');
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lazylead
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yurii Dubinka
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: colorize
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.8.1
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.8.1
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: faraday
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -151,7 +165,7 @@ dependencies:
|
|
151
165
|
- !ruby/object:Gem::Version
|
152
166
|
version: 2.1.2
|
153
167
|
- !ruby/object:Gem::Dependency
|
154
|
-
name:
|
168
|
+
name: require_all
|
155
169
|
requirement: !ruby/object:Gem::Requirement
|
156
170
|
requirements:
|
157
171
|
- - '='
|
@@ -165,61 +179,61 @@ dependencies:
|
|
165
179
|
- !ruby/object:Gem::Version
|
166
180
|
version: 3.0.0
|
167
181
|
- !ruby/object:Gem::Dependency
|
168
|
-
name:
|
182
|
+
name: rufus-scheduler
|
169
183
|
requirement: !ruby/object:Gem::Requirement
|
170
184
|
requirements:
|
171
185
|
- - '='
|
172
186
|
- !ruby/object:Gem::Version
|
173
|
-
version: 3.
|
187
|
+
version: 3.6.0
|
174
188
|
type: :runtime
|
175
189
|
prerelease: false
|
176
190
|
version_requirements: !ruby/object:Gem::Requirement
|
177
191
|
requirements:
|
178
192
|
- - '='
|
179
193
|
- !ruby/object:Gem::Version
|
180
|
-
version: 3.
|
194
|
+
version: 3.6.0
|
181
195
|
- !ruby/object:Gem::Dependency
|
182
|
-
name:
|
196
|
+
name: slop
|
183
197
|
requirement: !ruby/object:Gem::Requirement
|
184
198
|
requirements:
|
185
199
|
- - '='
|
186
200
|
- !ruby/object:Gem::Version
|
187
|
-
version:
|
201
|
+
version: '4.4'
|
188
202
|
type: :runtime
|
189
203
|
prerelease: false
|
190
204
|
version_requirements: !ruby/object:Gem::Requirement
|
191
205
|
requirements:
|
192
206
|
- - '='
|
193
207
|
- !ruby/object:Gem::Version
|
194
|
-
version:
|
208
|
+
version: '4.4'
|
195
209
|
- !ruby/object:Gem::Dependency
|
196
|
-
name:
|
210
|
+
name: sqlite3
|
197
211
|
requirement: !ruby/object:Gem::Requirement
|
198
212
|
requirements:
|
199
213
|
- - '='
|
200
214
|
- !ruby/object:Gem::Version
|
201
|
-
version:
|
215
|
+
version: 1.4.2
|
202
216
|
type: :runtime
|
203
217
|
prerelease: false
|
204
218
|
version_requirements: !ruby/object:Gem::Requirement
|
205
219
|
requirements:
|
206
220
|
- - '='
|
207
221
|
- !ruby/object:Gem::Version
|
208
|
-
version:
|
222
|
+
version: 1.4.2
|
209
223
|
- !ruby/object:Gem::Dependency
|
210
|
-
name:
|
224
|
+
name: tempfile
|
211
225
|
requirement: !ruby/object:Gem::Requirement
|
212
226
|
requirements:
|
213
227
|
- - '='
|
214
228
|
- !ruby/object:Gem::Version
|
215
|
-
version: 1.
|
229
|
+
version: 0.1.0
|
216
230
|
type: :runtime
|
217
231
|
prerelease: false
|
218
232
|
version_requirements: !ruby/object:Gem::Requirement
|
219
233
|
requirements:
|
220
234
|
- - '='
|
221
235
|
- !ruby/object:Gem::Version
|
222
|
-
version: 1.
|
236
|
+
version: 0.1.0
|
223
237
|
- !ruby/object:Gem::Dependency
|
224
238
|
name: tilt
|
225
239
|
requirement: !ruby/object:Gem::Requirement
|
@@ -576,7 +590,6 @@ files:
|
|
576
590
|
- ".ruby-version"
|
577
591
|
- ".rultor.yml"
|
578
592
|
- ".simplecov"
|
579
|
-
- ".travis.yml"
|
580
593
|
- CNAME
|
581
594
|
- Gemfile
|
582
595
|
- Guardfile
|
@@ -607,21 +620,36 @@ files:
|
|
607
620
|
- lib/lazylead/system/synced.rb
|
608
621
|
- lib/lazylead/task/accuracy/accuracy.rb
|
609
622
|
- lib/lazylead/task/accuracy/affected_build.rb
|
623
|
+
- lib/lazylead/task/accuracy/attachment.rb
|
624
|
+
- lib/lazylead/task/accuracy/environment.rb
|
625
|
+
- lib/lazylead/task/accuracy/logs.rb
|
626
|
+
- lib/lazylead/task/accuracy/records.rb
|
610
627
|
- lib/lazylead/task/accuracy/requirement.rb
|
628
|
+
- lib/lazylead/task/accuracy/servers.rb
|
629
|
+
- lib/lazylead/task/accuracy/stacktrace.rb
|
630
|
+
- lib/lazylead/task/accuracy/testcase.rb
|
631
|
+
- lib/lazylead/task/accuracy/wiki.rb
|
611
632
|
- lib/lazylead/task/alert.rb
|
633
|
+
- lib/lazylead/task/assignment.rb
|
612
634
|
- lib/lazylead/task/confluence_ref.rb
|
613
635
|
- lib/lazylead/task/echo.rb
|
614
636
|
- lib/lazylead/task/fix_version.rb
|
615
637
|
- lib/lazylead/task/missing_comment.rb
|
616
638
|
- lib/lazylead/task/propagate_down.rb
|
617
639
|
- lib/lazylead/task/savepoint.rb
|
618
|
-
- lib/lazylead/task/
|
640
|
+
- lib/lazylead/task/svn/diff.rb
|
641
|
+
- lib/lazylead/task/svn/grep.rb
|
642
|
+
- lib/lazylead/task/svn/touch.rb
|
619
643
|
- lib/lazylead/version.rb
|
620
644
|
- lib/messages/accuracy.erb
|
621
645
|
- lib/messages/due_date_expired.erb
|
646
|
+
- lib/messages/illegal_assignee_change.erb
|
622
647
|
- lib/messages/illegal_fixversion_change.erb
|
623
648
|
- lib/messages/missing_comment.erb
|
624
649
|
- lib/messages/savepoint.erb
|
650
|
+
- lib/messages/svn_diff.erb
|
651
|
+
- lib/messages/svn_diff_attachment.erb
|
652
|
+
- lib/messages/svn_grep.erb
|
625
653
|
- lib/messages/svn_touch.erb
|
626
654
|
- license.txt
|
627
655
|
- readme.md
|
@@ -639,7 +667,17 @@ files:
|
|
639
667
|
- test/lazylead/system/jira_test.rb
|
640
668
|
- test/lazylead/task/accuracy/accuracy_test.rb
|
641
669
|
- test/lazylead/task/accuracy/affected_build_test.rb
|
670
|
+
- test/lazylead/task/accuracy/attachment_test.rb
|
671
|
+
- test/lazylead/task/accuracy/environment_test.rb
|
672
|
+
- test/lazylead/task/accuracy/logs_test.rb
|
673
|
+
- test/lazylead/task/accuracy/records_test.rb
|
674
|
+
- test/lazylead/task/accuracy/score_test.rb
|
675
|
+
- test/lazylead/task/accuracy/servers_test.rb
|
676
|
+
- test/lazylead/task/accuracy/stacktrace_test.rb
|
677
|
+
- test/lazylead/task/accuracy/testcase_test.rb
|
678
|
+
- test/lazylead/task/accuracy/wiki_test.rb
|
642
679
|
- test/lazylead/task/assignee_alert_test.rb
|
680
|
+
- test/lazylead/task/assignment_test.rb
|
643
681
|
- test/lazylead/task/confluence_ref_test.rb
|
644
682
|
- test/lazylead/task/duedate_test.rb
|
645
683
|
- test/lazylead/task/echo_test.rb
|
@@ -647,7 +685,9 @@ files:
|
|
647
685
|
- test/lazylead/task/missing_comment_test.rb
|
648
686
|
- test/lazylead/task/propagate_down_test.rb
|
649
687
|
- test/lazylead/task/savepoint_test.rb
|
650
|
-
- test/lazylead/task/
|
688
|
+
- test/lazylead/task/svn/diff_test.rb
|
689
|
+
- test/lazylead/task/svn/grep_test.rb
|
690
|
+
- test/lazylead/task/svn/touch_test.rb
|
651
691
|
- test/lazylead/version_test.rb
|
652
692
|
- test/sqlite_test.rb
|
653
693
|
- test/test.rb
|
@@ -658,7 +698,7 @@ licenses:
|
|
658
698
|
- MIT
|
659
699
|
metadata: {}
|
660
700
|
post_install_message: |-
|
661
|
-
Thanks for installing Lazylead v0.
|
701
|
+
Thanks for installing Lazylead v0.6.1!
|
662
702
|
Read our blog posts: https://lazylead.org
|
663
703
|
Stay in touch with the community in Telegram: https://t.me/lazylead
|
664
704
|
Follow us on Twitter: https://twitter.com/lazylead
|
@@ -697,7 +737,17 @@ test_files:
|
|
697
737
|
- test/lazylead/system/jira_test.rb
|
698
738
|
- test/lazylead/task/accuracy/accuracy_test.rb
|
699
739
|
- test/lazylead/task/accuracy/affected_build_test.rb
|
740
|
+
- test/lazylead/task/accuracy/attachment_test.rb
|
741
|
+
- test/lazylead/task/accuracy/environment_test.rb
|
742
|
+
- test/lazylead/task/accuracy/logs_test.rb
|
743
|
+
- test/lazylead/task/accuracy/records_test.rb
|
744
|
+
- test/lazylead/task/accuracy/score_test.rb
|
745
|
+
- test/lazylead/task/accuracy/servers_test.rb
|
746
|
+
- test/lazylead/task/accuracy/stacktrace_test.rb
|
747
|
+
- test/lazylead/task/accuracy/testcase_test.rb
|
748
|
+
- test/lazylead/task/accuracy/wiki_test.rb
|
700
749
|
- test/lazylead/task/assignee_alert_test.rb
|
750
|
+
- test/lazylead/task/assignment_test.rb
|
701
751
|
- test/lazylead/task/confluence_ref_test.rb
|
702
752
|
- test/lazylead/task/duedate_test.rb
|
703
753
|
- test/lazylead/task/echo_test.rb
|
@@ -705,7 +755,9 @@ test_files:
|
|
705
755
|
- test/lazylead/task/missing_comment_test.rb
|
706
756
|
- test/lazylead/task/propagate_down_test.rb
|
707
757
|
- test/lazylead/task/savepoint_test.rb
|
708
|
-
- test/lazylead/task/
|
758
|
+
- test/lazylead/task/svn/diff_test.rb
|
759
|
+
- test/lazylead/task/svn/grep_test.rb
|
760
|
+
- test/lazylead/task/svn/touch_test.rb
|
709
761
|
- test/lazylead/version_test.rb
|
710
762
|
- test/sqlite_test.rb
|
711
763
|
- test/test.rb
|
data/.travis.yml
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
rvm:
|
3
|
-
- 2.6.5
|
4
|
-
cache: bundler
|
5
|
-
branches:
|
6
|
-
only:
|
7
|
-
- master
|
8
|
-
install:
|
9
|
-
- travis_retry bundle update
|
10
|
-
- gem install pdd -v 0.20.5
|
11
|
-
script:
|
12
|
-
- pdd -f /dev/null
|
13
|
-
- export RUBYOPT="-W0"
|
14
|
-
- rake --quiet
|
15
|
-
after_success:
|
16
|
-
- "bash <(curl -s https://codecov.io/bash)"
|
data/lib/lazylead/task/touch.rb
DELETED
@@ -1,104 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# The MIT License
|
4
|
-
#
|
5
|
-
# Copyright (c) 2019-2020 Yurii Dubinka
|
6
|
-
#
|
7
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
-
# of this software and associated documentation files (the "Software"),
|
9
|
-
# to deal in the Software without restriction, including without limitation
|
10
|
-
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
11
|
-
# and/or sell copies of the Software, and to permit persons to whom
|
12
|
-
# the Software is furnished to do so, subject to the following conditions:
|
13
|
-
#
|
14
|
-
# The above copyright notice and this permission notice shall be included
|
15
|
-
# in all copies or substantial portions of the Software.
|
16
|
-
#
|
17
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
22
|
-
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
23
|
-
# OR OTHER DEALINGS IN THE SOFTWARE.
|
24
|
-
|
25
|
-
require "nokogiri"
|
26
|
-
require "active_support/core_ext/hash/conversions"
|
27
|
-
require_relative "../salt"
|
28
|
-
require_relative "../opts"
|
29
|
-
|
30
|
-
module Lazylead
|
31
|
-
module Task
|
32
|
-
#
|
33
|
-
# Send notification about modification of critical files in svn repo.
|
34
|
-
#
|
35
|
-
class SvnTouch
|
36
|
-
def initialize(log = Log.new)
|
37
|
-
@log = log
|
38
|
-
end
|
39
|
-
|
40
|
-
def run(_, postman, opts)
|
41
|
-
files = opts.slice("files", ",")
|
42
|
-
commits = touch(files, opts)
|
43
|
-
postman.send(opts.merge(entries: commits)) unless commits.empty?
|
44
|
-
end
|
45
|
-
|
46
|
-
# Return all svn commits for a particular date range, which are touching
|
47
|
-
# somehow the critical files within the svn repo.
|
48
|
-
def touch(files, opts)
|
49
|
-
xpath = files.map { |f| "contains(text(),\"#{f}\")" }.join(" or ")
|
50
|
-
svn_log(opts).xpath("//logentry[paths/path[#{xpath}]]")
|
51
|
-
.map(&method(:to_entry))
|
52
|
-
.each do |e|
|
53
|
-
if e.paths.path.respond_to? :delete_if
|
54
|
-
e.paths.path.delete_if { |p| files.none? { |f| p.include? f } }
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
# Return all svn commits for particular date range in repo
|
60
|
-
def svn_log(opts)
|
61
|
-
now = if opts.key? "now"
|
62
|
-
DateTime.parse(opts["now"])
|
63
|
-
else
|
64
|
-
DateTime.now
|
65
|
-
end
|
66
|
-
start = (now.to_time - opts["period"].to_i).to_datetime
|
67
|
-
cmd = [
|
68
|
-
"svn log --no-auth-cache",
|
69
|
-
"--username #{decrypt(opts['svn_user'])}",
|
70
|
-
"--password #{decrypt(opts['svn_password'])}",
|
71
|
-
"--xml -v -r {#{start}}:{#{now}} #{opts['svn_url']}"
|
72
|
-
]
|
73
|
-
raw = `#{cmd.join(" ")}`
|
74
|
-
Nokogiri.XML(raw, nil, "UTF-8")
|
75
|
-
end
|
76
|
-
|
77
|
-
# Decrypt text using cryptography salt
|
78
|
-
def decrypt(text, sid = "svn_salt")
|
79
|
-
return Salt.new(sid).decrypt(text) if ENV.key? sid
|
80
|
-
text
|
81
|
-
end
|
82
|
-
|
83
|
-
# Convert single revision(XML text) to entry object.
|
84
|
-
# Entry object is a simple ruby struct object.
|
85
|
-
def to_entry(xml)
|
86
|
-
e = to_struct(Hash.from_xml(xml.to_s.strip)).logentry
|
87
|
-
if e.paths.path.respond_to? :each
|
88
|
-
e.paths.path.each(&:strip!)
|
89
|
-
else
|
90
|
-
e.paths.path.strip!
|
91
|
-
end
|
92
|
-
e
|
93
|
-
end
|
94
|
-
|
95
|
-
# Make a simple ruby struct object from hash hierarchically,
|
96
|
-
# considering nested hash(es) (if applicable)
|
97
|
-
def to_struct(hsh)
|
98
|
-
OpenStruct.new(
|
99
|
-
hsh.transform_values { |v| v.is_a?(Hash) ? to_struct(v) : v }
|
100
|
-
)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|