gitsflow 0.4.4 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +7 -13
- data/lib/Git/git.rb +33 -12
- data/lib/GitLab/gitlab.rb +17 -1
- data/lib/GitLab/issue.rb +11 -1
- data/lib/GitLab/user.rb +9 -8
- data/lib/config.rb +4 -3
- data/lib/sflow.rb +102 -27
- 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: 04c67c4563202b190f6486858af820186e7c9e2eb1806d75f1be5c59f2223467
|
4
|
+
data.tar.gz: 853643113dc3d9d09a78958b1e1dd2488251fe16ab0dd50519de6ed2bd2223d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '008803af2e130b03178420aea6d3155fc24b3a1945d2214a6f4c52ba0f0560c9569f41e07b77fbbd800352787573cfde8b54ea79bfeafc6cbd75e7014942c118'
|
7
|
+
data.tar.gz: ee3294c8a10de03e446816178f6b9c75eb44a7e4e9cc63a30e313259508a1b4aff295651d1e98da5f057e39280d7d4e81f7252c8a8a0ecb0d0bd05bd8a455af3
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -9,14 +9,6 @@ GitSFlow is a tool that integrate Git custom commands with GitLab and it's inspi
|
|
9
9
|
gem 'gitsflow', group: :development
|
10
10
|
```
|
11
11
|
|
12
|
-
1 - Add this line to your application's Gemfile:
|
13
|
-
|
14
|
-
$ bundle install
|
15
|
-
$ sflow install
|
16
|
-
-> It will install the git alias
|
17
|
-
|
18
|
-
2 - install it yourself as:
|
19
|
-
|
20
12
|
$ gem install gitsflow
|
21
13
|
|
22
14
|
And in your application's:
|
@@ -46,6 +38,9 @@ GITLAB_NEXT_RELEASE_LIST=Next Release
|
|
46
38
|
GIT_BRANCH_MASTER=master
|
47
39
|
GIT_BRANCH_DEVELOP=develop
|
48
40
|
GIT_BRANCHES_STAGING=staging_1,staging_2
|
41
|
+
SFLOW_TEMPLATE_RELEASE=Version {version} - {date}
|
42
|
+
SFLOW_TEMPLATE_RELEASE_DATE_FORMAT=Y/m/d
|
43
|
+
|
49
44
|
```
|
50
45
|
|
51
46
|
## Usage
|
@@ -67,9 +62,10 @@ List of commands:
|
|
67
62
|
8. git sflow bugfix staging BUGFIX_BRANCH
|
68
63
|
9. git sflow hotfix start HOTFIX DESCRIPTION
|
69
64
|
10. git sflow hotfix [reintegration|finish] HOTFIX_BRANCH
|
70
|
-
11. git sflow
|
71
|
-
12. git sflow release
|
72
|
-
13. git sflow
|
65
|
+
11. git sflow hotfix staging HOTFIX_BRANCH
|
66
|
+
12. git sflow release start RELEASE
|
67
|
+
13. git sflow release finish RELEASE
|
68
|
+
14. git sflow push origin BRANCH or git sflow push
|
73
69
|
|
74
70
|
|
75
71
|
|
@@ -78,8 +74,6 @@ List of commands:
|
|
78
74
|
or
|
79
75
|
$ sflow uninstall
|
80
76
|
|
81
|
-
TODO: Write usage instructions here
|
82
|
-
|
83
77
|
|
84
78
|
## Get a GitLab Token
|
85
79
|
|
data/lib/Git/git.rb
CHANGED
@@ -1,20 +1,44 @@
|
|
1
1
|
module Git
|
2
|
-
def self.checkout
|
3
|
-
|
2
|
+
def self.checkout(branch, options = :with_fetch)
|
3
|
+
fetch(branch) if options == :with_fetch
|
4
4
|
print "checkout: ".yellow
|
5
5
|
print "#{branch}\n\n".green
|
6
|
-
|
6
|
+
execute {"git checkout #{branch}"}
|
7
7
|
self.pull branch
|
8
8
|
end
|
9
9
|
|
10
10
|
def self.merge from, to
|
11
11
|
# self.checkout(from)
|
12
|
-
|
12
|
+
checkout(to, :local)
|
13
13
|
print "Merge ".yellow
|
14
14
|
print "#{from} ".green
|
15
15
|
print "into ".yellow
|
16
16
|
print "#{to} \n\n".green
|
17
|
-
|
17
|
+
processs, stderr , stdout= Open3.popen3("git pull origin #{from}") do |i, o, stderr, wait_thr|
|
18
|
+
[wait_thr.value, stderr.read, o.read]
|
19
|
+
end
|
20
|
+
if processs.success?
|
21
|
+
return stdout
|
22
|
+
else
|
23
|
+
print "Conflicts on merge!".yellow.bg_red
|
24
|
+
print "\n\nResolve conflicts and commit. \n"
|
25
|
+
print "After type '1' for to continue or '0' for abort\n".yellow
|
26
|
+
choice = STDIN.gets.chomp
|
27
|
+
print "\n#{choice}, "
|
28
|
+
print "ok!\n".green
|
29
|
+
|
30
|
+
case choice
|
31
|
+
when '1'
|
32
|
+
print "Continuing...\n\n"
|
33
|
+
else
|
34
|
+
print "Aborting merge...\n\n"
|
35
|
+
system ('git merge --abort')
|
36
|
+
raise 'Aborting...'
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
# execute {"git pull origin #{from}"}
|
18
42
|
end
|
19
43
|
|
20
44
|
def self.delete_branch branch
|
@@ -25,10 +49,9 @@ module Git
|
|
25
49
|
|
26
50
|
def self.reset_hard from, to
|
27
51
|
self.fetch from
|
28
|
-
self.fetch to
|
29
52
|
self.checkout(to)
|
30
53
|
print "Reset --hard: #{to} is equal: ".yellow
|
31
|
-
print "
|
54
|
+
print "origin/#{from}\n".green
|
32
55
|
system "git reset --hard origin/#{from}\n\n"
|
33
56
|
end
|
34
57
|
|
@@ -56,7 +79,7 @@ module Git
|
|
56
79
|
|
57
80
|
def self.fetch branch
|
58
81
|
print "Fetch: ".yellow
|
59
|
-
print "
|
82
|
+
print "origin/#{branch}\n\n".green
|
60
83
|
system "git fetch origin #{branch}"
|
61
84
|
end
|
62
85
|
|
@@ -77,13 +100,11 @@ module Git
|
|
77
100
|
|
78
101
|
def self.execute
|
79
102
|
processs, stderr , stdout= Open3.popen3(yield) do |i, o, stderr, wait_thr|
|
80
|
-
|
103
|
+
[wait_thr.value, stderr.read, o.read]
|
81
104
|
end
|
82
105
|
if processs.success?
|
83
106
|
return stdout
|
84
|
-
else
|
85
|
-
raise "#{stderr}"
|
86
107
|
end
|
108
|
+
raise "#{stderr}"
|
87
109
|
end
|
88
|
-
|
89
110
|
end
|
data/lib/GitLab/gitlab.rb
CHANGED
@@ -14,6 +14,8 @@ module GitLab
|
|
14
14
|
req['PRIVATE-TOKEN'] = $GITLAB_TOKEN
|
15
15
|
req.set_form_data(params)
|
16
16
|
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) {|http| http.request(req) }
|
17
|
+
check_authorized res
|
18
|
+
check_errors_404 res
|
17
19
|
JSON.parse(res.body)
|
18
20
|
end
|
19
21
|
|
@@ -24,6 +26,8 @@ module GitLab
|
|
24
26
|
req['PRIVATE-TOKEN'] = $GITLAB_TOKEN
|
25
27
|
req.set_form_data(params)
|
26
28
|
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) {|http| http.request(req) }
|
29
|
+
check_authorized res
|
30
|
+
check_errors_404 res
|
27
31
|
JSON.parse(res.body)
|
28
32
|
end
|
29
33
|
|
@@ -33,10 +37,22 @@ module GitLab
|
|
33
37
|
req = Net::HTTP::Get.new(uri)
|
34
38
|
req['PRIVATE-TOKEN'] = $GITLAB_TOKEN
|
35
39
|
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) {|http| http.request(req) }
|
40
|
+
check_authorized res
|
41
|
+
check_errors_404 res
|
36
42
|
JSON.parse(res.body)
|
37
43
|
end
|
38
44
|
|
45
|
+
def self.check_errors_404 res
|
46
|
+
if res.code == "404"
|
47
|
+
raise "Project: #{$GITLAB_PROJECT_ID} \n#{JSON.parse(res.body)['message']}"
|
48
|
+
end
|
49
|
+
end
|
39
50
|
|
51
|
+
def self.check_authorized res
|
52
|
+
if res.code == "401"
|
53
|
+
raise "Unauthorized. Check GITLAB_TOKEN and file .env"
|
54
|
+
end
|
55
|
+
end
|
40
56
|
|
41
57
|
def self.create_labels
|
42
58
|
url = "projects/#{$GITLAB_PROJECT_ID}/labels"
|
@@ -50,6 +66,7 @@ module GitLab
|
|
50
66
|
{name: 'bugfix', color: "#D9534F"},
|
51
67
|
{name: 'changelog', color: "#0033CC"},
|
52
68
|
{name: 'Staging', color: "#FAD8C7"},
|
69
|
+
{name: 'tasks', color: "#F0AD4E"},
|
53
70
|
]
|
54
71
|
$GIT_BRANCHES_STAGING.each do |staging|
|
55
72
|
params << {name: staging, color: '#FAD8C7'}
|
@@ -62,6 +79,5 @@ module GitLab
|
|
62
79
|
end
|
63
80
|
|
64
81
|
end
|
65
|
-
|
66
82
|
|
67
83
|
end
|
data/lib/GitLab/issue.rb
CHANGED
@@ -87,7 +87,7 @@ class GitLab::Issue
|
|
87
87
|
issue = GitLab::Issue.new
|
88
88
|
issue.set_data issue_json
|
89
89
|
else
|
90
|
-
raise "Issue not found #{branch}"
|
90
|
+
raise "Issue not found #{branch}. \nCheck if exist the label default_branch in the body description"
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
@@ -96,6 +96,11 @@ class GitLab::Issue
|
|
96
96
|
GitLab.request_get(url)
|
97
97
|
end
|
98
98
|
|
99
|
+
def self.ping
|
100
|
+
url = "projects/#{$GITLAB_PROJECT_ID}/issues?"
|
101
|
+
issue_json = GitLab.request_get(url)&.first
|
102
|
+
end
|
103
|
+
|
99
104
|
def self.from_list(list_name)
|
100
105
|
url = "projects/#{$GITLAB_PROJECT_ID}/issues?labels=#{list_name}&state=opened"
|
101
106
|
issues = []
|
@@ -119,6 +124,11 @@ class GitLab::Issue
|
|
119
124
|
description.match(/\* \~changelog .*\n?/).to_s.gsub('* ~changelog ', '') rescue nil
|
120
125
|
end
|
121
126
|
|
127
|
+
def list_tasks
|
128
|
+
# a.description.match(/(\* \~changelog .*\n)+/).to_a
|
129
|
+
description.match(/\* \~tasks .*\n?/).to_s.gsub('* ~tasks ', '') rescue nil
|
130
|
+
end
|
131
|
+
|
122
132
|
def add_comment note
|
123
133
|
comment = GitLab::Comment.new(issue_iid: @iid, body: note)
|
124
134
|
@comments << comment
|
data/lib/GitLab/user.rb
CHANGED
@@ -1,20 +1,21 @@
|
|
1
|
-
class GitLab::User
|
1
|
+
class GitLab::User
|
2
2
|
attr_accessor :id, :email, :name
|
3
3
|
|
4
4
|
def initialize(params = {})
|
5
5
|
@name = params[:name]
|
6
6
|
end
|
7
7
|
|
8
|
-
def self.me
|
9
|
-
GitLab.request_get(
|
8
|
+
def self.me
|
9
|
+
user = GitLab.request_get('user')
|
10
|
+
|
11
|
+
return user if user
|
12
|
+
|
13
|
+
raise "Who are you?! \nVerify your data em .env"
|
10
14
|
end
|
11
15
|
|
12
16
|
def self.all
|
13
17
|
GitLab.request_get("projects/#{$GITLAB_PROJECT_ID}/users")
|
14
18
|
end
|
15
19
|
|
16
|
-
def to_s
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
20
|
+
def to_s; end
|
21
|
+
end
|
data/lib/config.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
begin
|
3
2
|
require 'dotenv'
|
4
3
|
Dotenv.load(File.join( Dir.pwd, ".env"))
|
@@ -8,9 +7,11 @@ end
|
|
8
7
|
$GITLAB_PROJECT_ID = ENV['GITLAB_PROJECT_ID']
|
9
8
|
$GITLAB_TOKEN = ENV['GITLAB_TOKEN']
|
10
9
|
$GITLAB_URL_API = ENV['GITLAB_URL_API']
|
11
|
-
$GITLAB_EMAIL = ENV['GITLAB_EMAIL']
|
10
|
+
$GITLAB_EMAIL = ENV['GITLAB_EMAIL'].to_s.empty? ? Open3.popen3("git config --local user.email") { |i, o| o.read }.chomp : ENV['GITLAB_EMAIL']
|
12
11
|
$GITLAB_LISTS = ENV['GITLAB_LISTS'].split(',') rescue nil
|
13
12
|
$GITLAB_NEXT_RELEASE_LIST = ENV['GITLAB_NEXT_RELEASE_LIST']
|
14
13
|
$GIT_BRANCH_MASTER= ENV["GIT_BRANCH_MASTER"]
|
15
14
|
$GIT_BRANCH_DEVELOP= ENV["GIT_BRANCH_DEVELOP"]
|
16
|
-
$GIT_BRANCHES_STAGING= ENV["GIT_BRANCHES_STAGING"].split(',') rescue nil
|
15
|
+
$GIT_BRANCHES_STAGING= ENV["GIT_BRANCHES_STAGING"].split(',') rescue nil
|
16
|
+
$SFLOW_TEMPLATE_RELEASE= ENV["SFLOW_TEMPLATE_RELEASE"].to_s.empty? ? "Release version {version} - {date}" : ENV["SFLOW_TEMPLATE_RELEASE"]
|
17
|
+
$SFLOW_TEMPLATE_RELEASE_DATE_FORMAT= ENV['SFLOW_TEMPLATE_RELEASE_DATE_FORMAT'].to_s.empty? ? 'Y/m/d': ENV['SFLOW_TEMPLATE_RELEASE_DATE_FORMAT']
|
data/lib/sflow.rb
CHANGED
@@ -8,6 +8,7 @@ end
|
|
8
8
|
require 'net/http'
|
9
9
|
|
10
10
|
require "open3"
|
11
|
+
require "date"
|
11
12
|
require 'uri'
|
12
13
|
load 'config.rb'
|
13
14
|
load 'string.rb'
|
@@ -17,7 +18,7 @@ load 'Git/git.rb'
|
|
17
18
|
# require './lib/gitlab/issue.rb'
|
18
19
|
# require './lib/gitlab/merge_request.rb'
|
19
20
|
class SFlow
|
20
|
-
VERSION = "0.
|
21
|
+
VERSION = "0.6.3"
|
21
22
|
$TYPE = ARGV[0]
|
22
23
|
$ACTION = ARGV[1]
|
23
24
|
|
@@ -26,7 +27,11 @@ class SFlow
|
|
26
27
|
|
27
28
|
def self.call
|
28
29
|
begin
|
30
|
+
print "GitSflow #{VERSION}\n".green
|
29
31
|
print "Loading...\n".yellow
|
32
|
+
git_branch = Git.execute { "git branch --show-current" }
|
33
|
+
print "\nYou are on branch:".yellow
|
34
|
+
print " #{git_branch}\n".green
|
30
35
|
validates if !['config_', 'help_'].include? ("#{$TYPE}_#{$ACTION}")
|
31
36
|
#
|
32
37
|
send("#{$TYPE}_#{$ACTION}")
|
@@ -107,6 +112,13 @@ class SFlow
|
|
107
112
|
self.codereview()
|
108
113
|
end
|
109
114
|
|
115
|
+
def self.hotfix_staging
|
116
|
+
if (!$PARAM1.match(/\-hotfix\//))
|
117
|
+
raise "This branch is not a hotfix"
|
118
|
+
end
|
119
|
+
self.staging
|
120
|
+
end
|
121
|
+
|
110
122
|
def self.bugfix_staging
|
111
123
|
if (!$PARAM1.match(/\-bugfix\//))
|
112
124
|
raise "This branch is not a bugfix"
|
@@ -130,7 +142,7 @@ class SFlow
|
|
130
142
|
issues_total = issues.size
|
131
143
|
|
132
144
|
if issues_total == 0
|
133
|
-
raise "Not exist issues
|
145
|
+
raise "Not exist ready issues for start release"
|
134
146
|
end
|
135
147
|
|
136
148
|
issues_urgent = issues.select{|i| i.labels.include? 'urgent'}
|
@@ -140,7 +152,7 @@ class SFlow
|
|
140
152
|
issue_release = GitLab::Issue.find_by(title: issue_title) rescue nil
|
141
153
|
|
142
154
|
if issue_release
|
143
|
-
print "This
|
155
|
+
print "This card was created previously. Do you want to continue using it? (y/n):".yellow.bg_red
|
144
156
|
|
145
157
|
print"\n If you choose 'n', a new issue will be created!\n"
|
146
158
|
print "\n"
|
@@ -191,13 +203,10 @@ class SFlow
|
|
191
203
|
issues_urgent.each do |issue|
|
192
204
|
print " -> #{issue.title}\n"
|
193
205
|
end
|
194
|
-
|
195
206
|
issues_urgent.each do |issue|
|
196
|
-
|
197
207
|
Git.merge(issue.branch, release_branch)
|
198
208
|
changelogs << "* ~changelog #{issue.msg_changelog} \n"
|
199
209
|
new_labels << 'hotfix'
|
200
|
-
|
201
210
|
end
|
202
211
|
issues = issues_urgent
|
203
212
|
when "1"
|
@@ -210,13 +219,15 @@ class SFlow
|
|
210
219
|
issues.each do |issue|
|
211
220
|
Git.merge(issue.branch, release_branch)
|
212
221
|
changelogs << "* ~changelog #{issue.msg_changelog} \n"
|
213
|
-
|
214
222
|
end
|
215
223
|
else
|
216
224
|
raise "option invalid!"
|
217
225
|
end
|
218
226
|
print "Changelog messages:\n\n".yellow
|
219
|
-
|
227
|
+
d_split = $SFLOW_TEMPLATE_RELEASE_DATE_FORMAT.split('/')
|
228
|
+
date = Date.today.strftime("%#{d_split[0]}/%#{d_split[1]}/%#{d_split[2]}")
|
229
|
+
version_header = "#{$SFLOW_TEMPLATE_RELEASE.gsub("{version}", version).gsub("{date}",date)}\n"
|
230
|
+
|
220
231
|
print version_header.blue
|
221
232
|
msgs_changelog = []
|
222
233
|
changelogs.each do |clog|
|
@@ -224,9 +235,10 @@ class SFlow
|
|
224
235
|
msgs_changelog << msg_changelog
|
225
236
|
print msg_changelog.light_blue
|
226
237
|
end
|
238
|
+
msgs_changelog << "\n"
|
227
239
|
print "\nSetting changelog message in CHANGELOG\n".yellow
|
228
240
|
sleep 2
|
229
|
-
|
241
|
+
|
230
242
|
system('touch CHANGELOG')
|
231
243
|
file_changelog = IO.read 'CHANGELOG'
|
232
244
|
IO.write 'CHANGELOG', version_header + msgs_changelog.join('') + file_changelog
|
@@ -235,17 +247,43 @@ class SFlow
|
|
235
247
|
system("git commit -m 'update CHANGELOG version #{version}'")
|
236
248
|
Git.push release_branch
|
237
249
|
|
238
|
-
issue_release.description = "#{changelogs.join("")}\n
|
250
|
+
issue_release.description = "#{changelogs.join("")}\n"
|
239
251
|
|
240
252
|
issue_release.labels = ['ready_to_deploy', 'Next Release']
|
241
253
|
issue_release.set_default_branch(release_branch)
|
242
|
-
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
print "\n\nTasks list:\n\n".yellow
|
258
|
+
|
259
|
+
tasks = []
|
260
|
+
issues.each do |issue|
|
261
|
+
if issue.description.match(/(\* \~tasks .*)+/)
|
262
|
+
tasks << "* ~tasks #{issue.list_tasks} \n"
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
if tasks.size > 0
|
267
|
+
new_labels << 'tasks'
|
268
|
+
|
269
|
+
tasks.each do |task|
|
270
|
+
task = "#{task.strip.chomp.gsub('* ~tasks ', ' - ')}\n"
|
271
|
+
print task.light_blue
|
272
|
+
end
|
273
|
+
issue_release.description += "#{tasks.join("")}\n"
|
274
|
+
end
|
275
|
+
|
243
276
|
issues.each do |issue|
|
244
277
|
issue.labels = (issue.labels + new_labels).uniq
|
245
278
|
issue.close
|
246
279
|
end
|
280
|
+
|
247
281
|
print "\nYou are on branch: #{release_branch}\n".yellow
|
248
282
|
print "\nRelease #{version} created with success!\n\n".yellow
|
283
|
+
|
284
|
+
issue_release.description += "* #{issues.map{|i| "##{i.iid},"}.join(' ')}"
|
285
|
+
|
286
|
+
issue_release.update
|
249
287
|
|
250
288
|
|
251
289
|
rescue => exception
|
@@ -269,13 +307,12 @@ class SFlow
|
|
269
307
|
Git.merge issue_release.branch, 'develop'
|
270
308
|
Git.push 'develop'
|
271
309
|
|
272
|
-
|
273
310
|
type = issue_release.labels.include?('hotfix') ? 'hotfix' : nil
|
274
311
|
mr_master = GitLab::MergeRequest.new(
|
275
312
|
source_branch: issue_release.branch,
|
276
313
|
target_branch: $GIT_BRANCH_MASTER,
|
277
314
|
issue_iid: issue_release.iid,
|
278
|
-
title: "Reintegration release #{version}: #{issue_release.branch} into
|
315
|
+
title: "Reintegration release #{version}: #{issue_release.branch} into #{$GIT_BRANCH_MASTER}",
|
279
316
|
description: "Closes ##{issue_release.iid}",
|
280
317
|
type: type
|
281
318
|
)
|
@@ -337,9 +374,13 @@ class SFlow
|
|
337
374
|
|
338
375
|
end
|
339
376
|
|
377
|
+
def self.push_
|
378
|
+
self.push_origin
|
379
|
+
end
|
340
380
|
|
341
381
|
def self.push_origin
|
342
|
-
branch = $PARAM1
|
382
|
+
branch = !$PARAM1 ? Git.execute { 'git branch --show-current' } : $PARAM1
|
383
|
+
branch.delete!("\n")
|
343
384
|
log_messages = Git.log_last_changes branch
|
344
385
|
issue = GitLab::Issue.find_by_branch branch
|
345
386
|
Git.push branch
|
@@ -373,7 +414,9 @@ class SFlow
|
|
373
414
|
print "GIT_BRANCH_MASTER=master\n".pink
|
374
415
|
print "GIT_BRANCH_DEVELOP=develop\n".pink
|
375
416
|
print "GIT_BRANCHES_STAGING=staging_1,staging_2\n".pink
|
376
|
-
|
417
|
+
print "SFLOW_TEMPLATE_RELEASE=Version {version} - {date}\n".pink
|
418
|
+
print "SFLOW_TEMPLATE_RELEASE_DATE_FORMAT=d/m/Y\n".pink
|
419
|
+
|
377
420
|
end
|
378
421
|
|
379
422
|
def self.set_error(e)
|
@@ -382,7 +425,8 @@ class SFlow
|
|
382
425
|
print "\n"
|
383
426
|
print "#{e.message}".yellow.bg_red
|
384
427
|
print "\n\n"
|
385
|
-
print "#{
|
428
|
+
e.backtrace.each { |line| print "#{line}\n" }
|
429
|
+
|
386
430
|
print "\n\n"
|
387
431
|
end
|
388
432
|
|
@@ -401,6 +445,9 @@ class SFlow
|
|
401
445
|
branchs_validations = $GIT_BRANCHES_STAGING + [$GIT_BRANCH_MASTER, $GIT_BRANCH_DEVELOP]
|
402
446
|
Git.exist_branch?(branchs_validations.join(' ')) rescue raise "You need to create branches #{branchs_validations.join(', ')}"
|
403
447
|
|
448
|
+
GitLab::Issue.ping
|
449
|
+
|
450
|
+
|
404
451
|
end
|
405
452
|
|
406
453
|
def self.help_
|
@@ -416,9 +463,10 @@ class SFlow
|
|
416
463
|
print "8 - git sflow bugfix staging BUGFIX_BRANCH\n".yellow
|
417
464
|
print "9 - git sflow hotfix start HOTFIX DESCRIPTION\n".yellow
|
418
465
|
print "10 - git sflow hotfix [reintegration|finish] HOTFIX_BRANCH\n".yellow
|
419
|
-
print "11 - git sflow
|
420
|
-
print "12 - git sflow release
|
421
|
-
print "13 - git sflow
|
466
|
+
print "11 - git sflow hotfix staging HOTFIX_BRANCH\n".yellow
|
467
|
+
print "12 - git sflow release start RELEASE\n".yellow
|
468
|
+
print "13 - git sflow release finish RELEASE\n".yellow
|
469
|
+
print "14 - git sflow push origin BRANCH or git sflow push\n".yellow
|
422
470
|
|
423
471
|
choice = -1
|
424
472
|
question = "Choice a number for show a example or 0 for exit:\n\n".light_blue
|
@@ -443,14 +491,16 @@ class SFlow
|
|
443
491
|
when '8'
|
444
492
|
print "-> git sflow bugfix staging 12-bugfix/Ticket#9999\n"
|
445
493
|
when '9'
|
446
|
-
print "-> git sflow hotfix start Ticket#9999 'Ticket#9999 Bug at production
|
494
|
+
print "-> git sflow hotfix start Ticket#9999 'Ticket#9999 Bug at production ...'\n\n"
|
447
495
|
when '10'
|
448
|
-
print "-> git sflow hotfix reintegration Ticket#9999'\n\n"
|
496
|
+
print "-> git sflow hotfix reintegration 11-hotfix/Ticket#9999'\n\n"
|
449
497
|
when '11'
|
450
|
-
print "-> git sflow
|
498
|
+
print "-> git sflow hotfix staging 11-hotfix/Ticket#9999'\n\n"
|
451
499
|
when '12'
|
452
|
-
print "-> git sflow release
|
500
|
+
print "-> git sflow release start v9.9.99'\n\n"
|
453
501
|
when '13'
|
502
|
+
print "-> git sflow release finish v9.9.99'\n\n"
|
503
|
+
when '14'
|
454
504
|
print "-> git sflow push BRANCH\n\n"
|
455
505
|
when '0'
|
456
506
|
else
|
@@ -467,8 +517,10 @@ class SFlow
|
|
467
517
|
# Git.pull ref_branch
|
468
518
|
source_branch = $PARAM1
|
469
519
|
issue = GitLab::Issue.find_by_branch(source_branch)
|
520
|
+
|
521
|
+
# Setting Changelog
|
470
522
|
print "Title: #{issue.title}\n\n"
|
471
|
-
print "
|
523
|
+
print "CHANGELOG message:\n--> ".yellow
|
472
524
|
message_changelog = STDIN.gets.chomp
|
473
525
|
print "\n ok!\n\n".green
|
474
526
|
new_labels = []
|
@@ -491,6 +543,20 @@ class SFlow
|
|
491
543
|
print "#{message_changelog}\n".green
|
492
544
|
print "Moving issue to list: ".yellow
|
493
545
|
print "#{$GITLAB_NEXT_RELEASE_LIST}\n".green
|
546
|
+
|
547
|
+
# Setting Tasks
|
548
|
+
print "\n\nIf there are any tasks to be run, list them below separated by spaces, otherwise press Enter:\n"
|
549
|
+
print "\n Tasks:\n--> ".yellow
|
550
|
+
tasks = STDIN.gets.chomp
|
551
|
+
print "\n ok!\n\n".green
|
552
|
+
if tasks != "" and tasks != nil
|
553
|
+
issue.description.gsub!(/\* \~tasks .*\n?/,'')
|
554
|
+
issue.description = "#{issue.description} \n* ~tasks #{tasks}"
|
555
|
+
print "Setting tasks: ".yellow
|
556
|
+
end
|
557
|
+
print "#{tasks}\n".green
|
558
|
+
|
559
|
+
|
494
560
|
issue.update
|
495
561
|
|
496
562
|
end
|
@@ -553,14 +619,22 @@ class SFlow
|
|
553
619
|
print "\n#{option_merge}, "
|
554
620
|
print "ok!\n".green
|
555
621
|
|
556
|
-
if option_merge ==
|
622
|
+
if option_merge == '0'
|
623
|
+
issues_staging = GitLab::Issue.from_list(target_branch).select{|i| i.branch != branch}
|
624
|
+
issues_staging.each do |i|
|
625
|
+
i.labels.delete(target_branch)
|
626
|
+
i.labels.delete('Staging')
|
627
|
+
i.labels.push('Doing')
|
628
|
+
i.update
|
629
|
+
end
|
557
630
|
Git.reset_hard branch, target_branch
|
558
631
|
Git.push_force target_branch
|
559
|
-
elsif option_merge ==
|
632
|
+
elsif option_merge == '1'
|
633
|
+
Git.reset_hard target_branch, target_branch
|
560
634
|
Git.merge branch, target_branch
|
561
635
|
Git.push target_branch
|
562
636
|
else
|
563
|
-
raise
|
637
|
+
raise 'Wrong choice'
|
564
638
|
end
|
565
639
|
|
566
640
|
new_labels = [target_branch, 'Staging']
|
@@ -571,6 +645,7 @@ class SFlow
|
|
571
645
|
issue.update
|
572
646
|
|
573
647
|
self.codereview
|
648
|
+
Git.checkout(branch)
|
574
649
|
end
|
575
650
|
end
|
576
651
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitsflow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carlos Wherbet
|
@@ -142,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
142
|
- !ruby/object:Gem::Version
|
143
143
|
version: '0'
|
144
144
|
requirements: []
|
145
|
-
rubygems_version: 3.1.
|
145
|
+
rubygems_version: 3.1.4
|
146
146
|
signing_key:
|
147
147
|
specification_version: 4
|
148
148
|
summary: GitSFlow is a tool that integrate Git custom commands with GitLab and it's
|