tractive 1.0.3 → 1.0.4
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/Gemfile.lock +1 -1
- data/README.adoc +48 -14
- data/config.example.yaml +31 -7
- data/lib/tractive/github_api/client/labels.rb +33 -0
- data/lib/tractive/github_api/client.rb +2 -0
- data/lib/tractive/info.rb +3 -3
- data/lib/tractive/main.rb +0 -2
- data/lib/tractive/migrator/converter/trac_to_github.rb +25 -6
- data/lib/tractive/models/ticket.rb +4 -1
- data/lib/tractive/utilities.rb +2 -2
- data/lib/tractive/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73d210f072099b2362c1b39ebb5dfd7d6096fcb76b5096e9fc3db14dec34f14e
|
4
|
+
data.tar.gz: 39b0716034e7ddd0604bc7390f8a4332c2bb5c0664ba88834d7381761dd759aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c765fe77b184c12c4e161691df30181eea49b0ebd757893b28718b13cb8ccd89f25eec0e7037398bdabe1fa84e9a0df513706ddcc8cef21b27bc0c37812b9d62
|
7
|
+
data.tar.gz: 88eb6e7049f269feab229e39ab0de8ff9835648cf92f300b64ff07b94ad25e8274991bf9106f0c2050b75fceef430965b98d7ba493690965a7306b4e0932bc25
|
data/Gemfile.lock
CHANGED
data/README.adoc
CHANGED
@@ -385,25 +385,55 @@ The pattern of a mapping is like:
|
|
385
385
|
+
|
386
386
|
[source,yaml]
|
387
387
|
----
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
388
|
+
trivial:
|
389
|
+
name: trivial
|
390
|
+
color: ff0000
|
391
|
+
major:
|
392
|
+
name: major
|
393
|
+
color: b44647
|
394
|
+
minor:
|
395
|
+
name: minor
|
396
|
+
color: f7347a
|
397
|
+
medium:
|
398
|
+
name: medium
|
399
|
+
color: f3c77c
|
396
400
|
----
|
397
401
|
|
398
402
|
`priority:`::: Priority of the Trac ticket.
|
399
403
|
+
|
400
404
|
[source,yaml]
|
401
405
|
----
|
402
|
-
Low:
|
403
|
-
|
406
|
+
Low:
|
407
|
+
name: low
|
408
|
+
color: 22dd00
|
409
|
+
High:
|
410
|
+
name: high
|
411
|
+
color: ff0000
|
404
412
|
----
|
405
413
|
|
406
414
|
|
415
|
+
`tracstate:`::: Status of the Trac ticket.
|
416
|
+
+
|
417
|
+
[source,yaml]
|
418
|
+
----
|
419
|
+
accepted:
|
420
|
+
name: accepted
|
421
|
+
color: 22dd00
|
422
|
+
assigned:
|
423
|
+
name: assigned
|
424
|
+
color: aadd88
|
425
|
+
closed:
|
426
|
+
name: closed
|
427
|
+
color: ee00aa
|
428
|
+
new:
|
429
|
+
name: new
|
430
|
+
color:
|
431
|
+
----
|
432
|
+
|
433
|
+
|
434
|
+
NOTE: As `severity`, `priority` and `tracstate` are converted into `labels` on github so there is an option to specify the `color` for those labels.
|
435
|
+
|
436
|
+
|
407
437
|
==== User mapping
|
408
438
|
|
409
439
|
`users:`:: a one-to-one mapping between Trac usernames or email addresses to
|
@@ -412,7 +442,8 @@ GitHub usernames for users, in the following pattern:
|
|
412
442
|
[source,yaml]
|
413
443
|
----
|
414
444
|
users:
|
415
|
-
|
445
|
+
{Trac email or username}:
|
446
|
+
email: {Github email}
|
416
447
|
name: {name of the person}
|
417
448
|
username: {username on GitHub}
|
418
449
|
...
|
@@ -423,10 +454,12 @@ EXAMPLE:
|
|
423
454
|
[source,yaml]
|
424
455
|
----
|
425
456
|
users:
|
426
|
-
|
457
|
+
matthew@gmail.org:
|
458
|
+
email: matthew@example.org
|
427
459
|
name: Matthew
|
428
460
|
username: example-matt
|
429
|
-
|
461
|
+
valencia:
|
462
|
+
email: valencia
|
430
463
|
name: Valencia
|
431
464
|
username: example-vale
|
432
465
|
----
|
@@ -434,7 +467,8 @@ users:
|
|
434
467
|
If you don't want to map a user, you can just leave the `username` empty like below:
|
435
468
|
----
|
436
469
|
users:
|
437
|
-
|
470
|
+
matthew@gmail.org:
|
471
|
+
email: matthew@example.org
|
438
472
|
name: Matthew
|
439
473
|
username:
|
440
474
|
----
|
data/config.example.yaml
CHANGED
@@ -54,14 +54,38 @@ labels:
|
|
54
54
|
|
55
55
|
# less useful, but also possible:
|
56
56
|
priority:
|
57
|
-
Low:
|
58
|
-
|
57
|
+
Low:
|
58
|
+
name: low
|
59
|
+
color: 22dd00
|
60
|
+
High:
|
61
|
+
name: high
|
62
|
+
color: ff0000
|
59
63
|
severity:
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
64
|
+
trivial:
|
65
|
+
name: trivial
|
66
|
+
color: ff0000
|
67
|
+
major:
|
68
|
+
name: major
|
69
|
+
color: b44647
|
70
|
+
minor:
|
71
|
+
name: minor
|
72
|
+
color: f7347a
|
73
|
+
medium:
|
74
|
+
name: medium
|
75
|
+
color: f3c77c
|
76
|
+
tracstate:
|
77
|
+
accepted:
|
78
|
+
name: accepted
|
79
|
+
color: 22dd00
|
80
|
+
assigned:
|
81
|
+
name: assigned
|
82
|
+
color: aadd88
|
83
|
+
closed:
|
84
|
+
name: closed
|
85
|
+
color: ee00aa
|
86
|
+
new:
|
87
|
+
name: new
|
88
|
+
color:
|
65
89
|
version:
|
66
90
|
'1.3': v1.3
|
67
91
|
'1.4': v1.4
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GithubApi
|
4
|
+
class Client
|
5
|
+
module Labels
|
6
|
+
def list_labels(repo, params = {})
|
7
|
+
JSON.parse(
|
8
|
+
RestClient.get(
|
9
|
+
"https://api.github.com/repos/#{repo}/labels",
|
10
|
+
{
|
11
|
+
"Authorization" => "token #{@token}",
|
12
|
+
params: params
|
13
|
+
}
|
14
|
+
)
|
15
|
+
)
|
16
|
+
end
|
17
|
+
alias labels list_labels
|
18
|
+
|
19
|
+
def create_label(repo, params)
|
20
|
+
JSON.parse(
|
21
|
+
RestClient.post(
|
22
|
+
"https://api.github.com/repos/#{repo}/labels",
|
23
|
+
params.to_json,
|
24
|
+
{
|
25
|
+
"Authorization" => "token #{@token}",
|
26
|
+
"Accept" => "application/vnd.github.v3+json"
|
27
|
+
}
|
28
|
+
)
|
29
|
+
)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -1,12 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "client/issues"
|
4
|
+
require_relative "client/labels"
|
4
5
|
require_relative "client/milestones"
|
5
6
|
|
6
7
|
# Service to perform github actions
|
7
8
|
module GithubApi
|
8
9
|
class Client
|
9
10
|
include GithubApi::Client::Issues
|
11
|
+
include GithubApi::Client::Labels
|
10
12
|
include GithubApi::Client::Milestones
|
11
13
|
|
12
14
|
def initialize(options = {})
|
data/lib/tractive/info.rb
CHANGED
@@ -36,9 +36,9 @@ module Tractive
|
|
36
36
|
"type" => Utilities.make_hash("type_", types),
|
37
37
|
"component" => Utilities.make_hash("component_", components),
|
38
38
|
"resolution" => Utilities.make_hash("resolution_", resolutions),
|
39
|
-
"severity" => Utilities.
|
40
|
-
"priority" => Utilities.
|
41
|
-
"tracstate" => Utilities.
|
39
|
+
"severity" => Utilities.make_each_hash(severity, %w[name color]),
|
40
|
+
"priority" => Utilities.make_each_hash(priorities, %w[name color]),
|
41
|
+
"tracstate" => Utilities.make_each_hash(tracstates, %w[name color])
|
42
42
|
}
|
43
43
|
}
|
44
44
|
end
|
data/lib/tractive/main.rb
CHANGED
@@ -8,8 +8,6 @@ module Tractive
|
|
8
8
|
@opts = opts
|
9
9
|
@cfg = YAML.load_file(@opts[:config])
|
10
10
|
|
11
|
-
@cfg["users"] = @cfg["users"].map { |user| [user["email"], user["username"]] }.to_h
|
12
|
-
|
13
11
|
Tractive::Utilities.setup_logger(output_stream: @opts[:log_file] || $stderr, verbose: @opts[:verbose])
|
14
12
|
@db = Tractive::Utilities.setup_db!(@cfg["trac"]["database"])
|
15
13
|
rescue Sequel::DatabaseConnectionError, Sequel::AdapterNotFound, URI::InvalidURIError, Sequel::DatabaseError => e
|
@@ -17,6 +17,9 @@ module Migrator
|
|
17
17
|
@wiki_attachments_url = args[:cfg]["trac"]["wiki_attachments_url"]
|
18
18
|
|
19
19
|
load_milestone_map
|
20
|
+
create_labels_on_github(@labels_cfg["severity"].values)
|
21
|
+
create_labels_on_github(@labels_cfg["priority"].values)
|
22
|
+
create_labels_on_github(@labels_cfg["tracstate"].values)
|
20
23
|
|
21
24
|
@uri_parser = URI::Parser.new
|
22
25
|
@twf_to_markdown = Migrator::Converter::TwfToMarkdown.new(@tracticketbaseurl, @attachurl, @changeset_base_url, @wiki_attachments_url)
|
@@ -116,7 +119,8 @@ module Migrator
|
|
116
119
|
# compose body
|
117
120
|
body = [badgetable, body, footer].join("\n\n___\n")
|
118
121
|
|
119
|
-
labels.add("owner:#{github_assignee}")
|
122
|
+
labels.add("name" => "owner:#{github_assignee}") unless github_assignee.nil? || github_assignee.empty?
|
123
|
+
labels = labels.map { |label| label["name"] }
|
120
124
|
|
121
125
|
issue = {
|
122
126
|
"title" => ticket[:summary],
|
@@ -129,7 +133,7 @@ module Migrator
|
|
129
133
|
|
130
134
|
if @users.key?(ticket[:owner])
|
131
135
|
owner = trac_mail(ticket[:owner])
|
132
|
-
github_owner = @users[owner]
|
136
|
+
github_owner = @users[owner]["username"]
|
133
137
|
$logger.debug("..owner in trac: #{owner}")
|
134
138
|
$logger.debug("..assignee in GitHub: #{github_owner}")
|
135
139
|
issue["assignee"] = github_owner
|
@@ -155,11 +159,11 @@ module Migrator
|
|
155
159
|
private
|
156
160
|
|
157
161
|
def map_user(user)
|
158
|
-
@users[
|
162
|
+
@users.fetch(user, {})["email"] || user
|
159
163
|
end
|
160
164
|
|
161
165
|
def map_assignee(user)
|
162
|
-
@users[
|
166
|
+
@users.fetch(user, {})["email"]
|
163
167
|
end
|
164
168
|
|
165
169
|
def load_milestone_map
|
@@ -168,9 +172,9 @@ module Migrator
|
|
168
172
|
newmilestonekeys = @milestonesfromtrac.keys - @milestonemap.keys
|
169
173
|
|
170
174
|
newmilestonekeys.each do |milestonelabel|
|
171
|
-
milestone
|
175
|
+
milestone = {
|
172
176
|
"title" => milestonelabel.to_s,
|
173
|
-
"state" => @milestonesfromtrac[milestonelabel][:completed].
|
177
|
+
"state" => @milestonesfromtrac[milestonelabel][:completed].to_i.zero? ? "open" : "closed",
|
174
178
|
"description" => @milestonesfromtrac[milestonelabel][:description] || "no description in trac",
|
175
179
|
"due_on" => "2012-10-09T23:39:01Z"
|
176
180
|
}
|
@@ -194,6 +198,21 @@ module Migrator
|
|
194
198
|
nil
|
195
199
|
end
|
196
200
|
|
201
|
+
def create_labels_on_github(labels)
|
202
|
+
return if labels.nil? || labels.empty?
|
203
|
+
|
204
|
+
existing_labels = @client.labels(@repo).map { |label| label["name"] }
|
205
|
+
new_labels = labels.reject { |label| existing_labels.include?(label["name"]) }
|
206
|
+
|
207
|
+
new_labels.each do |label|
|
208
|
+
params = { name: label["name"] }
|
209
|
+
params["color"] = label["color"] unless label["color"].nil?
|
210
|
+
|
211
|
+
@client.create_label(@repo, params)
|
212
|
+
$logger.info("Created label: #{label["name"]}")
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
197
216
|
def ticket_change(append, meta)
|
198
217
|
# kind
|
199
218
|
kind = if meta[:ticket]
|
@@ -19,8 +19,11 @@ module Tractive
|
|
19
19
|
def filter_column(options)
|
20
20
|
return self if options.nil? || options.values.compact.empty?
|
21
21
|
|
22
|
-
|
22
|
+
case options[:operator].downcase
|
23
|
+
when "like"
|
23
24
|
where { Sequel.like(options[:column_name].to_sym, options[:column_value]) }
|
25
|
+
when "not like"
|
26
|
+
where { ~Sequel.like(options[:column_name].to_sym, options[:column_value]) }
|
24
27
|
else
|
25
28
|
where { Sequel.lit("#{options[:column_name]} #{options[:operator]} '#{options[:column_value]}'") }
|
26
29
|
end
|
data/lib/tractive/utilities.rb
CHANGED
data/lib/tractive/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tractive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10-
|
11
|
+
date: 2021-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mysql2
|
@@ -140,6 +140,7 @@ files:
|
|
140
140
|
- lib/tractive/github_api.rb
|
141
141
|
- lib/tractive/github_api/client.rb
|
142
142
|
- lib/tractive/github_api/client/issues.rb
|
143
|
+
- lib/tractive/github_api/client/labels.rb
|
143
144
|
- lib/tractive/github_api/client/milestones.rb
|
144
145
|
- lib/tractive/graceful_quit.rb
|
145
146
|
- lib/tractive/info.rb
|