peoplegroup-connectors 0.1.25 → 0.1.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/peoplegroup/connectors/gitlab.rb +37 -23
- data/lib/peoplegroup/connectors/version.rb +1 -1
- 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: af55cdf2e86d5eb632c397ba7b67b0580aa1ced948006795a5983846f8c3a558
|
4
|
+
data.tar.gz: 4ddde46c0504d7ef17a390ff6331a685ac543c7f9590c7e16d14029f97b86ac9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b344ea96bd3bb6e40f7a5c94df47f52be8850b1fcd7a6887b938e0c49efd332f41953bbb7f47f20fe8b03c8e07e88865f80bcecf89898c34fcfdeaafa3db5f0
|
7
|
+
data.tar.gz: 7d9c28962044fe7e4cdbedfe88a26f5c5a7f958d9e29ccf016b1d15ce6b14f20eb58d5f45762ed15b767dd2157f08c9f9ac3cd8b519a9c5383de047b4a3b4de2
|
@@ -5,6 +5,8 @@ require 'gitlab'
|
|
5
5
|
module PeopleGroup
|
6
6
|
module Connectors
|
7
7
|
class GitLab
|
8
|
+
MAX_RETRIES = 3
|
9
|
+
|
8
10
|
API_URL = ENV['GITLAB_API_V4_URL'] || 'https://gitlab.com/api/v4'
|
9
11
|
|
10
12
|
def initialize(token: ENV['GITLAB_API_TOKEN'])
|
@@ -14,7 +16,7 @@ module PeopleGroup
|
|
14
16
|
def find_gitlabber(field, query)
|
15
17
|
return if !query || query.empty?
|
16
18
|
|
17
|
-
possible_members = @client.group_members('gitlab-com', query: query)
|
19
|
+
possible_members = retry_on_error { @client.group_members('gitlab-com', query: query) }
|
18
20
|
if field === :email
|
19
21
|
possible_members.first
|
20
22
|
else
|
@@ -23,30 +25,32 @@ module PeopleGroup
|
|
23
25
|
end
|
24
26
|
|
25
27
|
def create_issue(project, title, options = {})
|
26
|
-
|
28
|
+
retry_on_error do
|
29
|
+
@client.create_issue(project, title, options)
|
30
|
+
end
|
27
31
|
end
|
28
32
|
|
29
33
|
def create_issue_note(project, id, text)
|
30
|
-
@client.create_issue_note(project, id, text)
|
34
|
+
retry_on_error { @client.create_issue_note(project, id, text) }
|
31
35
|
end
|
32
36
|
|
33
37
|
def get_onboarding_issues(project, args)
|
34
|
-
@client.issues(project, args).auto_paginate
|
38
|
+
retry_on_error { @client.issues(project, args).auto_paginate }
|
35
39
|
end
|
36
40
|
|
37
41
|
def get_issues(project, args)
|
38
|
-
@client.issues(project, args).auto_paginate
|
42
|
+
retry_on_error { @client.issues(project, args).auto_paginate }
|
39
43
|
end
|
40
44
|
|
41
45
|
def find_or_create_epic(group_id, title, options = {})
|
42
46
|
epic = find_epic(group_id, title)
|
43
47
|
reopen_epic(epic) if epic && epic.state == 'closed'
|
44
48
|
options[:confidential] = true
|
45
|
-
epic || @client.create_epic(group_id, title, options)
|
49
|
+
epic || retry_on_error { @client.create_epic(group_id, title, options) }
|
46
50
|
end
|
47
51
|
|
48
52
|
def commit_new_files_to_new_merge_request(project_id, branch_name, new_files, commit_message, description = nil)
|
49
|
-
@client.create_branch(project_id, branch_name, 'master')
|
53
|
+
retry_on_error { @client.create_branch(project_id, branch_name, 'master') }
|
50
54
|
actions = []
|
51
55
|
new_files.each do |file|
|
52
56
|
actions << {
|
@@ -56,11 +60,11 @@ module PeopleGroup
|
|
56
60
|
}
|
57
61
|
end
|
58
62
|
|
59
|
-
@client.create_commit(project_id, branch_name, commit_message, actions)
|
63
|
+
retry_on_error { @client.create_commit(project_id, branch_name, commit_message, actions) }
|
60
64
|
|
61
65
|
options = { source_branch: branch_name, target_branch: 'master', remove_source_branch: true }
|
62
66
|
options[:description] = description if description
|
63
|
-
@client.create_merge_request(project_id, commit_message, options)
|
67
|
+
retry_on_error { @client.create_merge_request(project_id, commit_message, options) }
|
64
68
|
end
|
65
69
|
|
66
70
|
def commit_change_to_new_merge_request_v2(project_id, branch_name, commit_message, description = nil, files_to_delete = [], files_to_update = [])
|
@@ -85,16 +89,16 @@ module PeopleGroup
|
|
85
89
|
|
86
90
|
return unless actions.any?
|
87
91
|
|
88
|
-
@client.create_branch(project_id, branch_name, 'master')
|
89
|
-
@client.create_commit(project_id, branch_name, commit_message, actions)
|
92
|
+
retry_on_error { @client.create_branch(project_id, branch_name, 'master') }
|
93
|
+
retry_on_error { @client.create_commit(project_id, branch_name, commit_message, actions) }
|
90
94
|
|
91
95
|
options = { source_branch: branch_name, target_branch: 'master', remove_source_branch: true }
|
92
96
|
options[:description] = description if description
|
93
|
-
@client.create_merge_request(project_id, commit_message, options)
|
97
|
+
retry_on_error { @client.create_merge_request(project_id, commit_message, options) }
|
94
98
|
end
|
95
99
|
|
96
100
|
def commit_change_to_new_merge_request(project_id, branch_name, file_path, file_with_change, commit_message, description = nil)
|
97
|
-
@client.create_branch(project_id, branch_name, 'master')
|
101
|
+
retry_on_error { @client.create_branch(project_id, branch_name, 'master') }
|
98
102
|
actions = [
|
99
103
|
{
|
100
104
|
action: 'update',
|
@@ -102,49 +106,59 @@ module PeopleGroup
|
|
102
106
|
content: file_with_change
|
103
107
|
}
|
104
108
|
]
|
105
|
-
@client.create_commit(project_id, branch_name, commit_message, actions)
|
109
|
+
retry_on_error { @client.create_commit(project_id, branch_name, commit_message, actions) }
|
106
110
|
|
107
111
|
options = { source_branch: branch_name, target_branch: 'master', remove_source_branch: true }
|
108
112
|
options[:description] = description if description
|
109
|
-
@client.create_merge_request(project_id, commit_message, options)
|
113
|
+
retry_on_error { @client.create_merge_request(project_id, commit_message, options) }
|
110
114
|
end
|
111
115
|
|
112
116
|
def create_epic_note(group_id, epic_id, text)
|
113
|
-
@client.create_epic_note(group_id, epic_id, text)
|
117
|
+
retry_on_error { @client.create_epic_note(group_id, epic_id, text) }
|
114
118
|
end
|
115
119
|
|
116
120
|
def get_epics(group_id, options = {})
|
117
|
-
@client.epics(group_id, options).auto_paginate
|
121
|
+
retry_on_error { @client.epics(group_id, options).auto_paginate }
|
118
122
|
end
|
119
123
|
|
120
124
|
def get_issue_epics(group_id, epic_iid)
|
121
|
-
@client.epic_issues(group_id, epic_iid)
|
125
|
+
retry_on_error { @client.epic_issues(group_id, epic_iid) }
|
122
126
|
end
|
123
127
|
|
124
128
|
private
|
125
129
|
|
130
|
+
def retry_on_error
|
131
|
+
retries = 0
|
132
|
+
|
133
|
+
begin
|
134
|
+
yield
|
135
|
+
rescue Gitlab::Error::InternalServerError
|
136
|
+
retry if (retries += 1) < MAX_RETRIES
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
126
140
|
def find_epic(group_id, title)
|
127
141
|
args = {
|
128
142
|
search: title
|
129
143
|
}
|
130
|
-
epics = @client.epics(group_id, args).auto_paginate
|
144
|
+
epics = retry_on_error { @client.epics(group_id, args).auto_paginate }
|
131
145
|
epics.first
|
132
146
|
end
|
133
147
|
|
134
148
|
def create_branch(project_id, branch_name)
|
135
|
-
@client.create_branch(project_id, branch_name, 'master')
|
149
|
+
retry_on_error { @client.create_branch(project_id, branch_name, 'master') }
|
136
150
|
end
|
137
151
|
|
138
152
|
def create_merge_request(project_id, title, options = {})
|
139
|
-
@client.create_merge_request(project_id, title, options)
|
153
|
+
retry_on_error { @client.create_merge_request(project_id, title, options) }
|
140
154
|
end
|
141
155
|
|
142
156
|
def create_commit(project_id, branch, commit_message, actions)
|
143
|
-
@client.create_commit(project_id, branch, commit_message, actions, {})
|
157
|
+
retry_on_error { @client.create_commit(project_id, branch, commit_message, actions, {}) }
|
144
158
|
end
|
145
159
|
|
146
160
|
def reopen_epic(epic)
|
147
|
-
@client.edit_epic(epic.group_id, epic.iid, { state_event: 'reopen' })
|
161
|
+
retry_on_error { @client.edit_epic(epic.group_id, epic.iid, { state_event: 'reopen' }) }
|
148
162
|
end
|
149
163
|
end
|
150
164
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: peoplegroup-connectors
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.26
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lien van den steen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gitlab
|