redmine_remotes 0.8.0 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/remote_issues_controller.rb +2 -1
- data/app/models/redmine_remotes/tableless/remote_issue_fetch/base.rb +4 -7
- data/app/models/redmine_remotes/tableless/remote_issue_fetch/base/_local_issue.rb +26 -1
- data/app/models/redmine_remotes/tableless/remote_issue_fetch/create.rb +7 -6
- data/app/models/redmine_remotes/tableless/remote_issue_fetch/create/_local_issue.rb +5 -11
- data/app/models/redmine_remotes/tableless/remote_issue_fetch/update.rb +1 -1
- data/app/models/redmine_remotes/tableless/remote_issue_fetch/update/_local_issue.rb +1 -8
- data/app/models/remote_tracker.rb +2 -8
- data/app/models/remote_tracker/remote.rb +19 -0
- data/config/locales/en.yml +2 -0
- data/config/locales/pt-BR.yml +2 -0
- data/lib/redmine_remotes/esosti.rb +15 -0
- data/lib/redmine_remotes/esosti/entities/issue.rb +45 -0
- data/lib/redmine_remotes/esosti/instance.rb +26 -0
- data/lib/redmine_remotes/jira/entities/issue.rb +0 -4
- data/lib/redmine_remotes/version.rb +1 -1
- metadata +8 -11
- data/app/models/remote_tracker/jira.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b9a64e1477b3e084cb4d065af0ec66ac260ad54297e687f6561592cfb4052c7
|
4
|
+
data.tar.gz: ebbbc2b95438d7607df5ce0f3b55dbdf2f96a22217cb50a4c1cd1ced6486904f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 480b67c9ea42377485df5690606b138f22f3c4763c21631230be44247e1c2e90f95579dc6ce871a4c9361938430dc7c7fd4bbc1a01db3e518d72b79e8e5ac560
|
7
|
+
data.tar.gz: b5aeb056db0c2386a1020116415708602db7105fa3fdabddc2db97e6e734225383961ede83283a645cfd753eaa1a0109222233ca279ad32781014319f7a3aa8f
|
@@ -9,6 +9,7 @@ class RemoteIssuesController < ApplicationController
|
|
9
9
|
require_permission PERMISSIONS
|
10
10
|
|
11
11
|
active_scaffold :remote_issue do |conf|
|
12
|
-
conf.columns[:
|
12
|
+
conf.columns[:remote_tracker].form_ui = :select
|
13
|
+
conf.actions.exclude :create, :update, :delete
|
13
14
|
end
|
14
15
|
end
|
@@ -11,16 +11,13 @@ module RedmineRemotes
|
|
11
11
|
require_sub __FILE__
|
12
12
|
include ::Eac::Model
|
13
13
|
|
14
|
+
validates :local_tracker, presence: true
|
15
|
+
validates :remote_tracker, presence: true
|
16
|
+
validates :issue_remote_code, presence: true
|
17
|
+
|
14
18
|
validate :author_present
|
15
19
|
validate :provider_issue_present
|
16
20
|
|
17
|
-
def tracker_in_project
|
18
|
-
return unless local_tracker.present? && project.present?
|
19
|
-
return if project.trackers.include?(local_tracker)
|
20
|
-
|
21
|
-
errors.add(:local_tracker, 'is not a tracker of project')
|
22
|
-
end
|
23
|
-
|
24
21
|
def author_present
|
25
22
|
return if provider_issue.blank?
|
26
23
|
return if local_issue_author.present?
|
@@ -6,11 +6,36 @@ module RedmineRemotes
|
|
6
6
|
class Base < ::EacRailsUtils::TablelessModel
|
7
7
|
private
|
8
8
|
|
9
|
+
def save_local_issue
|
10
|
+
save_local_issue_except_create_on && save_local_issue_created_on
|
11
|
+
end
|
12
|
+
|
13
|
+
def save_local_issue_created_on
|
14
|
+
local_issue_provider_attributes[:created_on].if_present do |created_on|
|
15
|
+
if created_on.present? && local_issue.created_on != created_on
|
16
|
+
local_issue.update_column( # rubocop:disable Rails/SkipsModelValidations
|
17
|
+
:created_on, created_on
|
18
|
+
)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
true
|
23
|
+
end
|
24
|
+
|
25
|
+
def save_local_issue_except_create_on
|
26
|
+
local_issue_provider_attributes.except(:created_on)
|
27
|
+
.each { |attr, value| local_issue.send("#{attr}=", value) }
|
28
|
+
return true if local_issue.save
|
29
|
+
|
30
|
+
fetch_record_errors(local_issue, default_column: default_error_column)
|
31
|
+
false
|
32
|
+
end
|
33
|
+
|
9
34
|
def local_issue_provider_attributes
|
10
35
|
{
|
11
36
|
subject: local_issue_subject, author: local_issue_author, status: local_issue_status,
|
12
37
|
description: local_issue_description,
|
13
|
-
created_on: provider_issue.created_on
|
38
|
+
created_on: provider_issue.created_on
|
14
39
|
}
|
15
40
|
end
|
16
41
|
|
@@ -15,17 +15,14 @@ module RedmineRemotes
|
|
15
15
|
belongs_to :project, class_name: 'Project'
|
16
16
|
belongs_to :remote_tracker, class_name: 'RemoteTracker'
|
17
17
|
|
18
|
-
validates :local_tracker, presence: true
|
19
|
-
validates :remote_tracker, presence: true
|
20
18
|
validates :project, presence: true
|
21
|
-
validates :issue_remote_code, presence: true
|
22
19
|
|
23
20
|
validate :tracker_in_project
|
24
21
|
|
25
22
|
def create
|
26
23
|
::Issue.transaction do
|
27
24
|
return false unless valid?
|
28
|
-
return false unless
|
25
|
+
return false unless save_local_issue
|
29
26
|
return false unless create_remote_issue
|
30
27
|
end
|
31
28
|
true
|
@@ -47,8 +44,12 @@ module RedmineRemotes
|
|
47
44
|
end
|
48
45
|
|
49
46
|
def update
|
50
|
-
::RedmineRemotes::Tableless::RemoteIssueFetch::Update
|
51
|
-
|
47
|
+
update_record = ::RedmineRemotes::Tableless::RemoteIssueFetch::Update
|
48
|
+
.new(remote_issue: remote_issue_by_remote_code)
|
49
|
+
return true if update_record.save
|
50
|
+
|
51
|
+
fetch_record_errors(update_record, default_column: default_error_column)
|
52
|
+
false
|
52
53
|
end
|
53
54
|
end
|
54
55
|
end
|
@@ -6,20 +6,14 @@ module RedmineRemotes
|
|
6
6
|
class Create < ::RedmineRemotes::Tableless::RemoteIssueFetch::Base
|
7
7
|
private
|
8
8
|
|
9
|
-
def
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
false
|
9
|
+
def local_issue_provider_attributes
|
10
|
+
super.merge(
|
11
|
+
project: project, tracker: local_tracker, priority: local_issue_priority
|
12
|
+
)
|
14
13
|
end
|
15
14
|
|
16
15
|
def local_issue_uncached
|
17
|
-
remote_issue_by_remote_code.if_present
|
18
|
-
::Issue.new(
|
19
|
-
local_issue_provider_attributes.merge(
|
20
|
-
project: project, tracker: local_tracker, priority: local_issue_priority
|
21
|
-
)
|
22
|
-
)
|
16
|
+
remote_issue_by_remote_code.if_present(&:local_issue) || ::Issue.new
|
23
17
|
end
|
24
18
|
|
25
19
|
def local_issue_priority
|
@@ -11,14 +11,7 @@ module RedmineRemotes
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def local_tracker
|
14
|
-
local_issue.tracker
|
15
|
-
end
|
16
|
-
|
17
|
-
def update_local_issue_with_remote_data
|
18
|
-
return true if local_issue.update(local_issue_provider_attributes)
|
19
|
-
|
20
|
-
fetch_record_errors(local_issue, default_column: :issue_remote_code)
|
21
|
-
false
|
14
|
+
local_issue.if_present(&:tracker)
|
22
15
|
end
|
23
16
|
end
|
24
17
|
end
|
@@ -6,14 +6,14 @@ require 'validate_url'
|
|
6
6
|
|
7
7
|
class RemoteTracker < ActiveRecord::Base
|
8
8
|
include ::EacRubyUtils::Listable
|
9
|
-
include ::RemoteTracker::
|
9
|
+
include ::RemoteTracker::Remote
|
10
10
|
|
11
11
|
has_many :issues, class_name: 'RemoteIssue', inverse_of: :remote_tracker,
|
12
12
|
dependent: :restrict_with_error
|
13
13
|
has_many :settings, class_name: 'RemoteTrackerSetting', inverse_of: :remote_tracker,
|
14
14
|
dependent: :destroy
|
15
15
|
|
16
|
-
lists.add_string :profile, :jira
|
16
|
+
lists.add_string :profile, :esosti, :jira
|
17
17
|
|
18
18
|
has_many :issue_statuses, class_name: 'RemoteIssueStatus', inverse_of: :remote_tracker,
|
19
19
|
dependent: :destroy
|
@@ -31,12 +31,6 @@ class RemoteTracker < ActiveRecord::Base
|
|
31
31
|
"#{root_url} [#{profile_label}, #{username}]"
|
32
32
|
end
|
33
33
|
|
34
|
-
def find_remote_issue(issue_id)
|
35
|
-
raise 'Profile blank' if profile.blank?
|
36
|
-
|
37
|
-
send("#{profile}_find_remote_issue", issue_id)
|
38
|
-
end
|
39
|
-
|
40
34
|
def setting_value(name)
|
41
35
|
::RemoteTrackerSetting.where(remote_tracker: self, name: name).first.if_present(&:value)
|
42
36
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class RemoteTracker < ActiveRecord::Base
|
4
|
+
module Remote
|
5
|
+
def find_remote_issue(issue_id)
|
6
|
+
remote_instance.find_issue(issue_id)
|
7
|
+
end
|
8
|
+
|
9
|
+
def remote_instance
|
10
|
+
remote_instance_class.new(self, root_url, username, password)
|
11
|
+
end
|
12
|
+
|
13
|
+
def remote_instance_class
|
14
|
+
raise 'Profile blank' if profile.blank?
|
15
|
+
|
16
|
+
::RedmineRemotes.const_get(profile.capitalize).const_get('Instance')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/config/locales/en.yml
CHANGED
data/config/locales/pt-BR.yml
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RedmineRemotes
|
4
|
+
module Esosti
|
5
|
+
class << self
|
6
|
+
RICH_TEXT_COMMENT = /<!--\s*RICH\s+TEXT\s-->/i.freeze
|
7
|
+
|
8
|
+
def remote_text_to_local(remote_text)
|
9
|
+
::Redmine::WikiFormatting.html_parser.to_text(
|
10
|
+
remote_text.gsub(RICH_TEXT_COMMENT, '').each_line.map(&:strip).join(" \n")
|
11
|
+
).each_line.map(&:strip).join("\n").gsub(/\n+/, "\n")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avmtrf1/esosti/entities/issue'
|
4
|
+
|
5
|
+
module RedmineRemotes
|
6
|
+
module Esosti
|
7
|
+
module Entities
|
8
|
+
class Issue < ::Avmtrf1::Esosti::Entities::Issue
|
9
|
+
def author_login
|
10
|
+
attributes.fetch('CREATEDBY').if_present { |v| v.gsub(/@[^@]+\z/, '') }
|
11
|
+
end
|
12
|
+
|
13
|
+
def attributes
|
14
|
+
data.first.fetch('Attributes')
|
15
|
+
end
|
16
|
+
|
17
|
+
def code
|
18
|
+
attributes.fetch('TICKETID')
|
19
|
+
end
|
20
|
+
|
21
|
+
def created_on
|
22
|
+
attributes.fetch('CREATIONDATE')
|
23
|
+
end
|
24
|
+
|
25
|
+
def description
|
26
|
+
::RedmineRemotes::Esosti.remote_text_to_local(
|
27
|
+
related_mbos.fetch('LONGDESCRIPTION').first.fetch('Attributes').fetch('LDTEXT')
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
def related_mbos
|
32
|
+
data.first.fetch('RelatedMbos')
|
33
|
+
end
|
34
|
+
|
35
|
+
def status_name
|
36
|
+
attributes.fetch('STATUS')
|
37
|
+
end
|
38
|
+
|
39
|
+
def subject
|
40
|
+
attributes.fetch('DESCRIPTION')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RedmineRemotes
|
4
|
+
module Esosti
|
5
|
+
class Instance < ::RedmineRemotes::RestProvider::Instance
|
6
|
+
ISSUE_ID_PATTERN = /\A(?:ss|in)[0-9]+\z/i.freeze
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def parse_issue_id(global_issue_id)
|
10
|
+
m = ISSUE_ID_PATTERN.match(global_issue_id)
|
11
|
+
return nil unless m
|
12
|
+
|
13
|
+
::OpenStruct.new(provider_issue_id: m[0], project_id: nil, project_issue_id: nil)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def build_service_url(service_url_suffix)
|
18
|
+
"#{root_url}/maxrest/rest#{service_url_suffix}"
|
19
|
+
end
|
20
|
+
|
21
|
+
def issue_get_url_suffix(provider_issue_id)
|
22
|
+
"/os/MS_RMTICKET/?ticketid=#{provider_issue_id}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redmine_remotes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eduardo Henrique Bogoni
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aranha-parsers
|
@@ -30,20 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0.
|
34
|
-
- - ">="
|
35
|
-
- !ruby/object:Gem::Version
|
36
|
-
version: 0.27.1
|
33
|
+
version: '0.28'
|
37
34
|
type: :runtime
|
38
35
|
prerelease: false
|
39
36
|
version_requirements: !ruby/object:Gem::Requirement
|
40
37
|
requirements:
|
41
38
|
- - "~>"
|
42
39
|
- !ruby/object:Gem::Version
|
43
|
-
version: '0.
|
44
|
-
- - ">="
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: 0.27.1
|
40
|
+
version: '0.28'
|
47
41
|
- !ruby/object:Gem::Dependency
|
48
42
|
name: curb
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -145,7 +139,7 @@ files:
|
|
145
139
|
- app/models/remote_issue.rb
|
146
140
|
- app/models/remote_issue_status.rb
|
147
141
|
- app/models/remote_tracker.rb
|
148
|
-
- app/models/remote_tracker/
|
142
|
+
- app/models/remote_tracker/remote.rb
|
149
143
|
- app/models/remote_tracker_setting.rb
|
150
144
|
- app/models/remote_user.rb
|
151
145
|
- app/views/project_remote_issues/_issues.html.erb
|
@@ -170,6 +164,9 @@ files:
|
|
170
164
|
- db/migrate/20200505161002_add_timestamps_to_remote_users.rb
|
171
165
|
- init.rb
|
172
166
|
- lib/redmine_remotes.rb
|
167
|
+
- lib/redmine_remotes/esosti.rb
|
168
|
+
- lib/redmine_remotes/esosti/entities/issue.rb
|
169
|
+
- lib/redmine_remotes/esosti/instance.rb
|
173
170
|
- lib/redmine_remotes/jira/entities/issue.rb
|
174
171
|
- lib/redmine_remotes/jira/instance.rb
|
175
172
|
- lib/redmine_remotes/patches/issue.rb
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class RemoteTracker < ActiveRecord::Base
|
4
|
-
module Jira
|
5
|
-
def jira_find_remote_issue(issue_id)
|
6
|
-
jira_create_instance.find_issue(issue_id)
|
7
|
-
end
|
8
|
-
|
9
|
-
def jira_create_instance
|
10
|
-
::RedmineRemotes::Jira::Instance.new(self, root_url, username, password)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|