lazylead 0.5.0 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +4 -3
- data/bin/lazylead +6 -4
- data/lazylead.gemspec +4 -3
- data/lib/lazylead/cli/app.rb +11 -3
- data/lib/lazylead/email.rb +0 -20
- data/lib/lazylead/exchange.rb +16 -29
- data/lib/lazylead/log.rb +2 -1
- data/lib/lazylead/model.rb +7 -0
- data/lib/lazylead/opts.rb +49 -1
- data/lib/lazylead/postman.rb +18 -17
- data/lib/lazylead/smtp.rb +3 -1
- data/lib/lazylead/system/jira.rb +30 -8
- data/lib/lazylead/task/accuracy/accuracy.rb +10 -1
- data/lib/lazylead/task/accuracy/logs.rb +7 -3
- data/lib/lazylead/task/accuracy/records.rb +1 -1
- data/lib/lazylead/task/accuracy/servers.rb +1 -1
- data/lib/lazylead/task/accuracy/stacktrace.rb +50 -10
- data/lib/lazylead/task/accuracy/testcase.rb +23 -6
- data/lib/lazylead/task/assignment.rb +96 -0
- data/lib/lazylead/task/fix_version.rb +6 -0
- data/lib/lazylead/task/svn/diff.rb +77 -0
- data/lib/lazylead/task/svn/grep.rb +132 -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 +8 -0
- data/lib/messages/svn_diff.erb +110 -0
- data/lib/messages/{svn_log.erb → svn_diff_attachment.erb} +19 -9
- data/lib/messages/svn_grep.erb +114 -0
- data/test/lazylead/model_test.rb +10 -0
- data/test/lazylead/opts_test.rb +35 -0
- data/test/lazylead/postman_test.rb +8 -5
- data/test/lazylead/system/jira_test.rb +14 -7
- data/test/lazylead/task/accuracy/logs_test.rb +62 -2
- data/test/lazylead/task/accuracy/score_test.rb +46 -0
- data/test/lazylead/task/accuracy/stacktrace_test.rb +227 -0
- data/test/lazylead/task/accuracy/testcase_test.rb +49 -0
- data/test/lazylead/task/assignment_test.rb +53 -0
- data/test/lazylead/task/fix_version_test.rb +1 -0
- data/test/lazylead/task/savepoint_test.rb +7 -4
- data/test/lazylead/task/svn/diff_test.rb +97 -0
- data/test/lazylead/task/svn/grep_test.rb +103 -0
- data/test/lazylead/task/{touch_test.rb → svn/touch_test.rb} +7 -34
- data/upgrades/sqlite/999.testdata.sql +2 -1
- metadata +48 -20
- data/lib/lazylead/task/touch.rb +0 -119
data/lib/lazylead/task/touch.rb
DELETED
@@ -1,119 +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 #{opts.decrypt('svn_user', 'svn_salt')}",
|
70
|
-
"--password #{opts.decrypt('svn_password', 'svn_salt')}",
|
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
|
-
# Convert single revision(XML text) to entry object.
|
78
|
-
# Entry object is a simple ruby struct object.
|
79
|
-
def to_entry(xml)
|
80
|
-
e = to_struct(Hash.from_xml(xml.to_s.strip)).logentry
|
81
|
-
if e.paths.path.respond_to? :each
|
82
|
-
e.paths.path.each(&:strip!)
|
83
|
-
else
|
84
|
-
e.paths.path.strip!
|
85
|
-
end
|
86
|
-
e
|
87
|
-
end
|
88
|
-
|
89
|
-
# Make a simple ruby struct object from hash hierarchically,
|
90
|
-
# considering nested hash(es) (if applicable)
|
91
|
-
def to_struct(hsh)
|
92
|
-
OpenStruct.new(
|
93
|
-
hsh.transform_values { |v| v.is_a?(Hash) ? to_struct(v) : v }
|
94
|
-
)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
#
|
99
|
-
# Send notification about modification of svn files since particular
|
100
|
-
# revision.
|
101
|
-
#
|
102
|
-
class SvnLog
|
103
|
-
def initialize(log = Log.new)
|
104
|
-
@log = log
|
105
|
-
end
|
106
|
-
|
107
|
-
def run(_, postman, opts)
|
108
|
-
cmd = [
|
109
|
-
"svn log --diff --no-auth-cache",
|
110
|
-
"--username #{opts.decrypt('svn_user', 'svn_salt')}",
|
111
|
-
"--password #{opts.decrypt('svn_password', 'svn_salt')}",
|
112
|
-
"-r#{opts['since_rev']}:HEAD #{opts['svn_url']}"
|
113
|
-
]
|
114
|
-
stdout = `#{cmd.join(" ")}`
|
115
|
-
postman.send(opts.merge(stdout: stdout)) unless stdout.blank?
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|