gitsflow 0.2.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of gitsflow might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +3 -2
- data/README.md +15 -23
- data/gitsflow.gemspec +2 -1
- data/lib/Git/git.rb +8 -3
- data/lib/GitLab/comment.rb +20 -0
- data/lib/GitLab/gitlab.rb +24 -1
- data/lib/GitLab/issue.rb +22 -6
- data/lib/GitLab/list.rb +22 -0
- data/lib/sflow.rb +76 -77
- metadata +32 -4
- data/.env +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a490296f500d1def1cc52746e4b76929007cd0182619c08a2bfa000b458d0ea
|
4
|
+
data.tar.gz: c73307ca48222d3dac05246f31d473c850f59c365ec829228b0e39ca8588472d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 960cf298859190dec0b3df9519bbcb8a877f806f7871e911701847a13fed2635e6e749a847b324ca8db1c00e2f426842dd861ca16e25cfb59dd557c7e61de865
|
7
|
+
data.tar.gz: 4d011cd37e2b1c36a282dc65bde56a3e1283d9f13e58486aa3e1cd55b2c5dea477586b5f45512e2face880bcfe641000defe3eabdec641967d5e9c514a9f9838
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -2,42 +2,30 @@
|
|
2
2
|
GitSFlow is a tool that integrate Git custom commands with GitLab and it's inspired GitFlow
|
3
3
|
## Installation
|
4
4
|
|
5
|
-
Add this line to your application's Gemfile:
|
6
5
|
|
7
6
|
```ruby
|
8
7
|
gem 'gitsflow', group: :development
|
9
8
|
```
|
10
9
|
|
11
|
-
|
10
|
+
1 - Add this line to your application's Gemfile:
|
12
11
|
|
13
12
|
$ bundle install
|
14
13
|
$ sflow install
|
15
14
|
-> It will install the git alias
|
16
15
|
|
17
|
-
|
16
|
+
2 - install it yourself as:
|
18
17
|
|
19
18
|
$ gem install gitsflow
|
19
|
+
|
20
|
+
And in your application's:
|
21
|
+
|
20
22
|
$ sflow install
|
21
23
|
-> It will install the git alias
|
22
24
|
|
23
25
|
|
24
26
|
## Flow Sugestion
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
SubGraph1 --> SubGraph1Flow
|
29
|
-
subgraph "SubGraph 1 Flow"
|
30
|
-
SubGraph1Flow(SubNode 1)
|
31
|
-
SubGraph1Flow -- Choice1 --> DoChoice1
|
32
|
-
SubGraph1Flow -- Choice2 --> DoChoice2
|
33
|
-
end
|
34
|
-
|
35
|
-
subgraph "Main Graph"
|
36
|
-
Node1[Node 1] --> Node2[Node 2]
|
37
|
-
Node2 --> SubGraph1[Jump to SubGraph1]
|
38
|
-
SubGraph1 --> FinalThing[Final Thing]
|
39
|
-
end
|
40
|
-
```
|
27
|
+
|
28
|
+
|
41
29
|
## Config
|
42
30
|
|
43
31
|
$ git sflow config
|
@@ -51,6 +39,8 @@ GITLAB_PROJECT_ID=
|
|
51
39
|
GITLAB_TOKEN=
|
52
40
|
GITLAB_URL_API=https://gitlab.com/api/v4
|
53
41
|
GITLAB_EMAIL=
|
42
|
+
GITLAB_LISTS=To Do,Doing,Next Release,Staging
|
43
|
+
GITLAB_NEXT_RELEASE_LIST=Next Release
|
54
44
|
GIT_BRANCH_MASTER=master
|
55
45
|
GIT_BRANCH_DEVELOP=develop
|
56
46
|
GIT_BRANCHES_STAGING=staging_1,staging_2
|
@@ -72,10 +62,12 @@ List of commands:
|
|
72
62
|
5. git sflow bugfix start BUGFIX DESCRIPTION
|
73
63
|
6. git sflow bugfix [reintegration|finish] BUGFIX_BRANCH
|
74
64
|
7. git sflow bugfix codereview BUGFIX_BRANCH
|
75
|
-
8. git sflow
|
76
|
-
9. git sflow hotfix
|
77
|
-
10. git sflow
|
78
|
-
11. git sflow
|
65
|
+
8. git sflow bugfix staging BUGFIX_BRANCH
|
66
|
+
9. git sflow hotfix start HOTFIX DESCRIPTION
|
67
|
+
10. git sflow hotfix [reintegration|finish] HOTFIX_BRANCH
|
68
|
+
11. git sflow release start RELEASE
|
69
|
+
12. git sflow release finish RELEASE
|
70
|
+
13. git sflow push BRANCH
|
79
71
|
|
80
72
|
|
81
73
|
|
data/gitsflow.gemspec
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
lib = File.expand_path("../lib", __FILE__)
|
2
2
|
$LOAD_PATH.push(lib)
|
3
|
-
|
4
3
|
require "sflow"
|
5
4
|
|
6
5
|
Gem::Specification.new do |s|
|
@@ -29,6 +28,8 @@ Gem::Specification.new do |s|
|
|
29
28
|
f.match(%r{^(test|spec|features)/})
|
30
29
|
end
|
31
30
|
s.add_dependency "dotenv", "~> 0"
|
31
|
+
s.add_dependency "pry", "~> 0"
|
32
|
+
s.add_development_dependency "dotenv", "~> 0"
|
32
33
|
s.add_development_dependency "pry", "~> 0"
|
33
34
|
s.add_development_dependency "bundler", "~> 1.16"
|
34
35
|
s.add_development_dependency "rake", "~> 12.3"
|
data/lib/Git/git.rb
CHANGED
@@ -3,6 +3,7 @@ module Git
|
|
3
3
|
print "checkout: ".yellow
|
4
4
|
print "#{branch}\n\n".green
|
5
5
|
system "git checkout #{branch}"
|
6
|
+
self.pull branch
|
6
7
|
end
|
7
8
|
|
8
9
|
def self.merge from, to
|
@@ -36,6 +37,10 @@ module Git
|
|
36
37
|
execute {"git push origin #{branch}"}
|
37
38
|
end
|
38
39
|
|
40
|
+
def self.log_last_changes branch
|
41
|
+
execute {"git log origin/#{branch}..HEAD --oneline --format='%ad - %B'"}
|
42
|
+
end
|
43
|
+
|
39
44
|
def self.pull branch
|
40
45
|
print "Pull: ".yellow
|
41
46
|
print "#{branch}\n\n".green
|
@@ -64,11 +69,11 @@ module Git
|
|
64
69
|
private
|
65
70
|
|
66
71
|
def self.execute
|
67
|
-
processs, stderr = Open3.popen3(yield) do |i, o, stderr, wait_thr|
|
68
|
-
[wait_thr.value, stderr.read]
|
72
|
+
processs, stderr , stdout= Open3.popen3(yield) do |i, o, stderr, wait_thr|
|
73
|
+
[wait_thr.value, stderr.read, o.read]
|
69
74
|
end
|
70
75
|
if processs.success?
|
71
|
-
|
76
|
+
return stdout
|
72
77
|
else
|
73
78
|
raise "#{stderr}"
|
74
79
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class GitLab::Comment
|
2
|
+
attr_accessor :id, :issue_iid, :body
|
3
|
+
|
4
|
+
def initialize(params = {})
|
5
|
+
@issue_iid = params[:issue_iid]
|
6
|
+
@body = params[:body]
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
def create
|
11
|
+
url = "projects/#{$GITLAB_PROJECT_ID}/issues/#{@issue_iid}/notes"
|
12
|
+
params = {
|
13
|
+
issue_iid: @issue_iid,
|
14
|
+
body: @body
|
15
|
+
}
|
16
|
+
GitLab.request_post(url, params)
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
end
|
data/lib/GitLab/gitlab.rb
CHANGED
@@ -4,7 +4,9 @@ module GitLab
|
|
4
4
|
autoload :User, 'GitLab/user.rb'
|
5
5
|
autoload :Issue, 'GitLab/issue.rb'
|
6
6
|
autoload :MergeRequest, 'GitLab/merge_request.rb'
|
7
|
+
autoload :Comment, 'GitLab/comment.rb'
|
7
8
|
autoload :List, 'GitLab/list.rb'
|
9
|
+
|
8
10
|
def self.request_post url, params
|
9
11
|
request = "#{$GITLAB_URL_API}/#{url}"
|
10
12
|
uri = URI(request)
|
@@ -36,7 +38,28 @@ module GitLab
|
|
36
38
|
|
37
39
|
|
38
40
|
|
39
|
-
def self.
|
41
|
+
def self.create_labels
|
42
|
+
url = "projects/#{$GITLAB_PROJECT_ID}/labels"
|
43
|
+
params = [
|
44
|
+
{name: 'feature', color: "#5CB85C"},
|
45
|
+
{name: 'default_branch', color: "#34495E"},
|
46
|
+
{name: 'version', color: "#34495E"},
|
47
|
+
{name: 'hotfix', color: "#d9534f"},
|
48
|
+
{name: 'production', color: "#F45D43"},
|
49
|
+
{name: 'urgent', color: "#d9534f"},
|
50
|
+
{name: 'bugfix', color: "#D9534F"},
|
51
|
+
{name: 'changelog', color: "#0033CC"},
|
52
|
+
{name: 'Staging', color: "#FAD8C7"},
|
53
|
+
]
|
54
|
+
$GIT_BRANCHES_STAGING.each do |staging|
|
55
|
+
params << {name: staging, color: '#FAD8C7'}
|
56
|
+
end
|
57
|
+
|
58
|
+
params << {name: $GITLAB_NEXT_RELEASE_LIST, color: '#34495E'}
|
59
|
+
|
60
|
+
params.each do |label_params|
|
61
|
+
self.request_post(url, label_params)
|
62
|
+
end
|
40
63
|
|
41
64
|
end
|
42
65
|
|
data/lib/GitLab/issue.rb
CHANGED
@@ -1,12 +1,23 @@
|
|
1
|
+
|
1
2
|
class GitLab::Issue
|
2
3
|
attr_accessor :title, :labels, :assignee_id, :description, :branch, :iid, :obj_gitlab, :status
|
3
|
-
@
|
4
|
+
@comments = []
|
5
|
+
@labels = []
|
6
|
+
|
7
|
+
def comments
|
8
|
+
@comments
|
9
|
+
end
|
10
|
+
|
11
|
+
def comments=obj
|
12
|
+
@comments << obj
|
13
|
+
end
|
4
14
|
|
5
15
|
def initialize(params = {})
|
6
16
|
@title = params[:title]
|
7
17
|
@labels = params[:labels] || []
|
8
18
|
@description = params[:description]
|
9
19
|
@branch = params[:branch]
|
20
|
+
@comments = []
|
10
21
|
@assignee_id = GitLab::User.me["id"]
|
11
22
|
end
|
12
23
|
|
@@ -59,7 +70,7 @@ class GitLab::Issue
|
|
59
70
|
end
|
60
71
|
|
61
72
|
def self.find_by(search)
|
62
|
-
url = "issues?search=#{search.values[0]}&in=#{search.keys[0]}&state=opened"
|
73
|
+
url = "projects/#{$GITLAB_PROJECT_ID}/issues?search=#{search.values[0]}&in=#{search.keys[0]}&state=opened"
|
63
74
|
issue_json = GitLab.request_get(url)[0]
|
64
75
|
if issue_json
|
65
76
|
issue = GitLab::Issue.new
|
@@ -70,7 +81,7 @@ class GitLab::Issue
|
|
70
81
|
end
|
71
82
|
|
72
83
|
def self.find_by_branch(branch)
|
73
|
-
url = "issues?search=#{branch}"
|
84
|
+
url = "projects/#{$GITLAB_PROJECT_ID}/issues?search=#{branch}"
|
74
85
|
issue_json = GitLab.request_get(url)[0]
|
75
86
|
if issue_json
|
76
87
|
issue = GitLab::Issue.new
|
@@ -81,13 +92,12 @@ class GitLab::Issue
|
|
81
92
|
end
|
82
93
|
|
83
94
|
def self.all
|
84
|
-
url = "issues?state=opened"
|
95
|
+
url = "projects/#{$GITLAB_PROJECT_ID}/issues?state=opened"
|
85
96
|
GitLab.request_get(url)
|
86
97
|
end
|
87
98
|
|
88
|
-
|
89
99
|
def self.from_list(list_name)
|
90
|
-
url = "issues?labels=#{list_name}&state=opened"
|
100
|
+
url = "projects/#{$GITLAB_PROJECT_ID}/issues?labels=#{list_name}&state=opened"
|
91
101
|
issues = []
|
92
102
|
issues_gitlab = GitLab.request_get(url)
|
93
103
|
issues_gitlab.each do |obj|
|
@@ -109,6 +119,12 @@ class GitLab::Issue
|
|
109
119
|
description.match(/\* \~changelog .*\n?/).to_s.gsub('* ~changelog ', '') rescue nil
|
110
120
|
end
|
111
121
|
|
122
|
+
def add_comment note
|
123
|
+
comment = GitLab::Comment.new(issue_iid: @iid, body: note)
|
124
|
+
@comments << comment
|
125
|
+
comment.create
|
126
|
+
end
|
127
|
+
|
112
128
|
def set_data obj
|
113
129
|
@iid = obj["iid"]
|
114
130
|
@title = obj["title"]
|
data/lib/GitLab/list.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
class GitLab::List
|
2
|
+
attr_accessor :id, :email, :name
|
3
|
+
|
4
|
+
def initialize(params = {})
|
5
|
+
@name = params[:name]
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.get_next_release_list
|
9
|
+
self.all.select{|list| list["label"]["name"] == $GITLAB_NEXT_RELEASE_LIST} end
|
10
|
+
|
11
|
+
def self.all
|
12
|
+
board_id = GitLab.request_get("projects/#{$GITLAB_PROJECT_ID}/boards")[0]["id"] rescue nil
|
13
|
+
if board_id
|
14
|
+
return GitLab.request_get("projects/#{$GITLAB_PROJECT_ID}/boards/#{board_id}/lists")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_s
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
end
|
data/lib/sflow.rb
CHANGED
@@ -15,7 +15,7 @@ load 'Git/git.rb'
|
|
15
15
|
# require './lib/gitlab/issue.rb'
|
16
16
|
# require './lib/gitlab/merge_request.rb'
|
17
17
|
class SFlow
|
18
|
-
VERSION = "0.
|
18
|
+
VERSION = "0.3.1"
|
19
19
|
$TYPE = ARGV[0]
|
20
20
|
$ACTION = ARGV[1]
|
21
21
|
$PARAM1 = ARGV[2]
|
@@ -40,6 +40,7 @@ class SFlow
|
|
40
40
|
self.start(branch, issue)
|
41
41
|
end
|
42
42
|
|
43
|
+
|
43
44
|
def self.bugfix_start
|
44
45
|
title = $PARAM2 == "" ? $PARAM1 : $PARAM2
|
45
46
|
issue = GitLab::Issue.new(title: title, labels: ['bugfix'])
|
@@ -89,18 +90,22 @@ class SFlow
|
|
89
90
|
self.hotfix_reintegration
|
90
91
|
end
|
91
92
|
|
92
|
-
def self.
|
93
|
+
def self.feature_codereview
|
93
94
|
if (!$PARAM1.match(/\-feature\//))
|
94
95
|
raise "This branch is not a feature"
|
95
96
|
end
|
96
|
-
self.
|
97
|
+
self.codereview()
|
97
98
|
end
|
98
99
|
|
99
|
-
def self.
|
100
|
+
def self.bugfix_codereview
|
100
101
|
if (!$PARAM1.match(/\-bugfix\//))
|
101
102
|
raise "This branch is not a bugfix"
|
102
103
|
end
|
103
|
-
self.
|
104
|
+
self.codereview()
|
105
|
+
end
|
106
|
+
|
107
|
+
def bugfix_staging
|
108
|
+
self.feature_staging
|
104
109
|
end
|
105
110
|
|
106
111
|
def self.feature_staging
|
@@ -123,7 +128,7 @@ class SFlow
|
|
123
128
|
print "ok!\n".green
|
124
129
|
|
125
130
|
|
126
|
-
print "\nAttention: \n".yellow.
|
131
|
+
print "\nAttention: \n".yellow.bg_red
|
127
132
|
print "Do you want clean first the target branch or only merge?\n\n".yellow
|
128
133
|
print "----------------------------\n".blue
|
129
134
|
print "0 - Clean it first, then do merge #{branch} into #{target_branch}\n".blue
|
@@ -141,14 +146,14 @@ class SFlow
|
|
141
146
|
else
|
142
147
|
raise "Wrong choice"
|
143
148
|
end
|
144
|
-
new_labels = [target_branch]
|
149
|
+
new_labels = [target_branch, 'Staging']
|
145
150
|
remove_labels = $GITLAB_LISTS
|
146
151
|
old_labels = issue.obj_gitlab["labels"]
|
147
152
|
old_labels.delete_if{|label| remove_labels.include? label}
|
148
153
|
issue.labels = (old_labels + new_labels).uniq
|
149
154
|
issue.update
|
150
155
|
|
151
|
-
self.
|
156
|
+
self.codereview
|
152
157
|
end
|
153
158
|
|
154
159
|
def self.release_start
|
@@ -190,11 +195,9 @@ class SFlow
|
|
190
195
|
release_branch = "#{issue_release.iid}-release/#{version}"
|
191
196
|
print "Creating release version #{version}\n"
|
192
197
|
|
193
|
-
|
194
198
|
begin
|
195
199
|
|
196
200
|
Git.delete_branch(release_branch)
|
197
|
-
Git.fetch 'develop'
|
198
201
|
Git.checkout 'develop'
|
199
202
|
Git.new_branch release_branch
|
200
203
|
|
@@ -209,7 +212,7 @@ class SFlow
|
|
209
212
|
print "\n\nChoose an option for merge:\n".yellow
|
210
213
|
print "----------------------------\n".blue
|
211
214
|
print "#{"0".ljust(10)} - Only #{issues_urgent_total} hotfix/urgent issues\n".blue if issues_urgent_total > 0
|
212
|
-
print "#{"1".ljust(10)} - All #{
|
215
|
+
print "#{"1".ljust(10)} - All #{issues_total} issues\n".blue
|
213
216
|
print "----------------------------\n".blue
|
214
217
|
print "Choice a number:\n".yellow
|
215
218
|
option = STDIN.gets.chomp
|
@@ -229,30 +232,7 @@ class SFlow
|
|
229
232
|
Git.merge(issue.branch, release_branch)
|
230
233
|
changelogs << "* ~changelog #{issue.msg_changelog} \n"
|
231
234
|
new_labels << 'hotfix'
|
232
|
-
|
233
|
-
# source_branch: issue.branch,
|
234
|
-
# target_branch: 'master',
|
235
|
-
# issue_iid: issue.iid,
|
236
|
-
# title: "##{issue.iid} - #{version} - Reintegration #{issue.branch} into master",
|
237
|
-
# type: 'hotfix'
|
238
|
-
# )
|
239
|
-
# mr_master.create
|
240
|
-
# mr_develop = GitLab::MergeRequest.new(
|
241
|
-
# source_branch: issue.branch,
|
242
|
-
# target_branch: 'develop',
|
243
|
-
# issue_iid: issue.iid,
|
244
|
-
# title: "##{issue.iid} - #{version} - Reintegration #{issue.branch} into develop",
|
245
|
-
# type: 'hotfix'
|
246
|
-
# )
|
247
|
-
# mr_develop.create
|
248
|
-
|
249
|
-
# new_labels << 'merge_request'
|
250
|
-
# remove_labels = $GIT_BRANCHES_STAGING + $GITLAB_LISTS
|
251
|
-
# new_labels << $GITLAB_NEXT_RELEASE_LIST
|
252
|
-
# old_labels = issue.obj_gitlab["labels"]
|
253
|
-
# old_labels.delete_if{|label| remove_labels.include? label}
|
254
|
-
# issue.labels = (old_labels + new_labels).uniq
|
255
|
-
# issue.update
|
235
|
+
|
256
236
|
end
|
257
237
|
issues = issues_urgent
|
258
238
|
when "1"
|
@@ -266,54 +246,35 @@ class SFlow
|
|
266
246
|
Git.merge(issue.branch, release_branch)
|
267
247
|
changelogs << "* ~changelog #{issue.msg_changelog} \n"
|
268
248
|
|
269
|
-
# mr_develop = GitLab::MergeRequest.new(
|
270
|
-
# source_branch: issue.branch,
|
271
|
-
# target_branch: 'develop',
|
272
|
-
# issue_iid: issue.iid,
|
273
|
-
# title: "##{issue.iid} - #{version} - Reintegration #{issue.branch} into develop"
|
274
|
-
# )
|
275
|
-
# mr_develop.create
|
276
|
-
|
277
|
-
# new_labels << 'merge_request'
|
278
|
-
# remove_labels = $GIT_BRANCHES_STAGING + $GITLAB_LISTS
|
279
|
-
# new_labels << $GITLAB_NEXT_RELEASE_LIST
|
280
|
-
# old_labels = issue.obj_gitlab["labels"]
|
281
|
-
# old_labels.delete_if{|label| remove_labels.include? label}
|
282
|
-
# issue.labels = (old_labels + new_labels).uniq
|
283
|
-
# issue.update
|
284
249
|
end
|
285
250
|
else
|
286
251
|
raise "option invalid!"
|
287
252
|
end
|
288
253
|
print "Changelog messages:\n\n".yellow
|
289
|
-
|
254
|
+
version_header = "Release version #{version}\n"
|
255
|
+
print version_header.blue
|
290
256
|
msgs_changelog = []
|
291
257
|
changelogs.each do |clog|
|
292
258
|
msg_changelog = "#{clog.strip.chomp.gsub('* ~changelog ', ' - ')}\n"
|
293
259
|
msgs_changelog << msg_changelog
|
294
260
|
print msg_changelog.light_blue
|
295
261
|
end
|
296
|
-
print "\nSetting changelog message in CHANGELOG
|
262
|
+
print "\nSetting changelog message in CHANGELOG\n".yellow
|
297
263
|
sleep 2
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
# end
|
303
|
-
|
304
|
-
file_changelog = IO.read 'CHANGELOG.md'
|
305
|
-
IO.write 'CHANGELOG.md', msgs_changelog.join('') + file_changelog
|
264
|
+
|
265
|
+
system('touch CHANGELOG')
|
266
|
+
file_changelog = IO.read 'CHANGELOG'
|
267
|
+
IO.write 'CHANGELOG', version_header + msgs_changelog.join('') + file_changelog
|
306
268
|
|
307
|
-
system('git add CHANGELOG
|
269
|
+
system('git add CHANGELOG')
|
308
270
|
system("git commit -m 'update CHANGELOG version #{version}'")
|
309
|
-
Git.push
|
271
|
+
Git.push release_branch
|
310
272
|
|
311
273
|
issue_release.description = "#{changelogs.join("")}\n * #{issues.map{|i| "##{i.iid},"}.join(' ')}"
|
312
274
|
|
313
275
|
issue_release.labels = ['ready_to_deploy', 'Next Release']
|
314
276
|
issue_release.set_default_branch(release_branch)
|
315
277
|
issue_release.update
|
316
|
-
Git.push release_branch
|
317
278
|
issues.each do |issue|
|
318
279
|
issue.labels = (issue.labels + new_labels).uniq
|
319
280
|
issue.close
|
@@ -327,8 +288,6 @@ class SFlow
|
|
327
288
|
|
328
289
|
raise exception.message
|
329
290
|
end
|
330
|
-
|
331
|
-
|
332
291
|
|
333
292
|
end
|
334
293
|
|
@@ -342,12 +301,16 @@ class SFlow
|
|
342
301
|
release_branch = "-release/#{version}"
|
343
302
|
issue_release = GitLab::Issue.find_by_branch(release_branch)
|
344
303
|
|
304
|
+
Git.merge issue_release.branch, 'develop'
|
305
|
+
Git.push 'develop'
|
306
|
+
|
307
|
+
|
345
308
|
type = issue_release.labels.include?('hotfix') ? 'hotfix' : nil
|
346
309
|
mr_master = GitLab::MergeRequest.new(
|
347
310
|
source_branch: issue_release.branch,
|
348
311
|
target_branch: 'master',
|
349
312
|
issue_iid: issue_release.iid,
|
350
|
-
title: "
|
313
|
+
title: "Reintegration release #{version}: #{issue_release.branch} into master",
|
351
314
|
description: "Closes ##{issue_release.iid}",
|
352
315
|
type: type
|
353
316
|
)
|
@@ -363,7 +326,7 @@ class SFlow
|
|
363
326
|
# )
|
364
327
|
# mr_develop.create
|
365
328
|
|
366
|
-
|
329
|
+
|
367
330
|
|
368
331
|
# remove_labels = [$GITLAB_NEXT_RELEASE_LIST]
|
369
332
|
remove_labels = []
|
@@ -371,6 +334,8 @@ class SFlow
|
|
371
334
|
old_labels.delete_if{|label| remove_labels.include? label}
|
372
335
|
issue_release.labels = (old_labels + new_labels).uniq
|
373
336
|
issue_release.update
|
337
|
+
print "\nRelease #{version} finished with success!\n\n".yellow
|
338
|
+
|
374
339
|
|
375
340
|
end
|
376
341
|
|
@@ -393,6 +358,7 @@ class SFlow
|
|
393
358
|
puts "\n\nInstalling git alias\n\n".yellow
|
394
359
|
print " \u{1F611} git sflow alias"
|
395
360
|
print " (instaling...) \r".yellow
|
361
|
+
GitLab.create_labels
|
396
362
|
sleep 2
|
397
363
|
system("git config --local alias.sflow '!sh -c \" sflow $1 $2 $3 $4\" - '")
|
398
364
|
print " \u{1F601}\ git sflow alias"
|
@@ -400,12 +366,32 @@ class SFlow
|
|
400
366
|
print "\n\n"
|
401
367
|
print "git sflow help\n\n"
|
402
368
|
print "git sflow config\n\n"
|
403
|
-
print "
|
369
|
+
print "GitSFlow installed with success!\n\n".green
|
404
370
|
# self.help_
|
405
371
|
# self.config_
|
406
372
|
|
407
373
|
end
|
408
374
|
|
375
|
+
|
376
|
+
def self.push_origin
|
377
|
+
branch = $PARAM1
|
378
|
+
log_messages = Git.log_last_changes branch
|
379
|
+
issue = GitLab::Issue.find_by_branch branch
|
380
|
+
Git.push branch
|
381
|
+
if (log_messages != "")
|
382
|
+
print "Send messages commit for issue\n".yellow
|
383
|
+
issue.add_comment(log_messages)
|
384
|
+
end
|
385
|
+
|
386
|
+
remove_labels = $GIT_BRANCHES_STAGING + ['Staging', $GITLAB_NEXT_RELEASE_LIST]
|
387
|
+
old_labels = issue.obj_gitlab["labels"]
|
388
|
+
old_labels.delete_if{|label| remove_labels.include? label}
|
389
|
+
|
390
|
+
issue.labels = old_labels + ['Doing']
|
391
|
+
issue.update
|
392
|
+
print "Success!\n\n".yellow
|
393
|
+
end
|
394
|
+
|
409
395
|
private
|
410
396
|
|
411
397
|
def self.config_
|
@@ -417,10 +403,12 @@ class SFlow
|
|
417
403
|
print "GITLAB_TOKEN=\n".pink
|
418
404
|
print "GITLAB_URL_API=\n".pink
|
419
405
|
print "GITLAB_EMAIL=\n".pink
|
420
|
-
print "GITLAB_LISTS=Do\n".pink
|
406
|
+
print "GITLAB_LISTS=To Do,Doing,Next Release,Staging\n".pink
|
407
|
+
print "GITLAB_NEXT_RELEASE_LIST=Next Release\n".pink
|
421
408
|
print "GIT_BRANCH_MASTER=master\n".pink
|
422
409
|
print "GIT_BRANCH_DEVELOP=develop\n".pink
|
423
410
|
print "GIT_BRANCHES_STAGING=staging_1,staging_2\n".pink
|
411
|
+
|
424
412
|
end
|
425
413
|
|
426
414
|
def self.set_error(e)
|
@@ -429,11 +417,12 @@ class SFlow
|
|
429
417
|
print "\n"
|
430
418
|
print "#{e.message}".yellow.bg_red
|
431
419
|
print "\n\n"
|
420
|
+
print "#{e.backtrace}".yellow.bg_red
|
421
|
+
print "\n\n"
|
432
422
|
end
|
433
423
|
|
434
424
|
def self.validates
|
435
425
|
print "Running validations... \n\n".yellow
|
436
|
-
|
437
426
|
if !$GITLAB_PROJECT_ID || !$GITLAB_TOKEN || !$GITLAB_URL_API ||
|
438
427
|
!$GIT_BRANCH_MASTER || !$GIT_BRANCH_DEVELOP || !$GITLAB_LISTS || !$GITLAB_NEXT_RELEASE_LIST
|
439
428
|
print "Variables not configured\n".yellow
|
@@ -459,10 +448,12 @@ class SFlow
|
|
459
448
|
print "5 - git sflow bugfix start BUGFIX DESCRIPTION\n".yellow
|
460
449
|
print "6 - git sflow bugfix [reintegration|finish] BUGFIX_BRANCH\n".yellow
|
461
450
|
print "7 - git sflow bugfix codereview BUGFIX_BRANCH\n".yellow
|
462
|
-
print "8 - git sflow
|
463
|
-
print "9 - git sflow hotfix
|
464
|
-
print "10 - git sflow
|
465
|
-
print "11 - git sflow
|
451
|
+
print "8 - git sflow bugfix staging BUGFIX_BRANCH\n".yellow
|
452
|
+
print "9 - git sflow hotfix start HOTFIX DESCRIPTION\n".yellow
|
453
|
+
print "10 - git sflow hotfix [reintegration|finish] HOTFIX_BRANCH\n".yellow
|
454
|
+
print "11 - git sflow release start RELEASE\n".yellow
|
455
|
+
print "12 - git sflow release finish RELEASE\n".yellow
|
456
|
+
print "13 - git sflow push BRANCH\n".yellow
|
466
457
|
|
467
458
|
choice = -1
|
468
459
|
question = "Choice a number for show a example or 0 for exit:\n\n".light_blue
|
@@ -485,9 +476,17 @@ class SFlow
|
|
485
476
|
when '7'
|
486
477
|
print "-> git sflow bugfix codereview 12-bugfix/Ticket#9999\n"
|
487
478
|
when '8'
|
488
|
-
print "-> git sflow
|
479
|
+
print "-> git sflow bugfix staging 12-bugfix/Ticket#9999\n"
|
489
480
|
when '9'
|
481
|
+
print "-> git sflow hotfix start Ticket#9999 'Ticket#9999 Bug at production in...'\n\n"
|
482
|
+
when '10'
|
490
483
|
print "-> git sflow hotfix reintegration Ticket#9999'\n\n"
|
484
|
+
when '11'
|
485
|
+
print "-> git sflow release start v5.5.99'\n\n"
|
486
|
+
when '12'
|
487
|
+
print "-> git sflow release finish v5.5.99'\n\n"
|
488
|
+
when '13'
|
489
|
+
print "-> git sflow push BRANCH\n\n"
|
491
490
|
when '0'
|
492
491
|
else
|
493
492
|
end
|
@@ -515,7 +514,7 @@ class SFlow
|
|
515
514
|
else
|
516
515
|
(!source_branch.match('feature') && !source_branch.match('bugfix')) rescue raise "invalid branch!"
|
517
516
|
end
|
518
|
-
remove_labels = $GIT_BRANCHES_STAGING + $GITLAB_LISTS
|
517
|
+
remove_labels = $GIT_BRANCHES_STAGING + $GITLAB_LISTS + ['Staging']
|
519
518
|
new_labels << 'changelog'
|
520
519
|
new_labels << $GITLAB_NEXT_RELEASE_LIST
|
521
520
|
old_labels = issue.obj_gitlab["labels"]
|
@@ -547,7 +546,7 @@ class SFlow
|
|
547
546
|
print "\nYou are on branch: #{branch}\n\n".yellow
|
548
547
|
end
|
549
548
|
|
550
|
-
def self.
|
549
|
+
def self.codereview
|
551
550
|
Git.fetch "develop"
|
552
551
|
Git.checkout "develop"
|
553
552
|
Git.pull "develop"
|
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.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carlos Wherbet
|
@@ -24,6 +24,34 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pry
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: dotenv
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
27
55
|
- !ruby/object:Gem::Dependency
|
28
56
|
name: pry
|
29
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -87,7 +115,6 @@ executables:
|
|
87
115
|
extensions: []
|
88
116
|
extra_rdoc_files: []
|
89
117
|
files:
|
90
|
-
- ".env"
|
91
118
|
- ".gitignore"
|
92
119
|
- CODE_OF_CONDUCT.md
|
93
120
|
- Gemfile
|
@@ -98,8 +125,10 @@ files:
|
|
98
125
|
- bin/sflow
|
99
126
|
- gitsflow.gemspec
|
100
127
|
- lib/Git/git.rb
|
128
|
+
- lib/GitLab/comment.rb
|
101
129
|
- lib/GitLab/gitlab.rb
|
102
130
|
- lib/GitLab/issue.rb
|
131
|
+
- lib/GitLab/list.rb
|
103
132
|
- lib/GitLab/merge_request.rb
|
104
133
|
- lib/GitLab/user.rb
|
105
134
|
- lib/config.rb
|
@@ -126,8 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
155
|
- !ruby/object:Gem::Version
|
127
156
|
version: '0'
|
128
157
|
requirements: []
|
129
|
-
|
130
|
-
rubygems_version: 2.7.6
|
158
|
+
rubygems_version: 3.1.2
|
131
159
|
signing_key:
|
132
160
|
specification_version: 4
|
133
161
|
summary: GitSFlow is a tool that integrate Git custom commands with GitLab and it's
|
data/.env
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
GITLAB_PROJECT_ID=17864326
|
2
|
-
GITLAB_TOKEN=LmbjqDbZ_hfNywSpLuUd
|
3
|
-
GITLAB_URL_API=https://gitlab.com/api/v4
|
4
|
-
GITLAB_EMAIL=
|
5
|
-
GITLAB_LISTS=To Do,Doing,Next Release,Staging
|
6
|
-
GITLAB_NEXT_RELEASE_LIST=Next Release
|
7
|
-
GIT_BRANCH_MASTER=master
|
8
|
-
GIT_BRANCH_DEVELOP=develop
|
9
|
-
GIT_BRANCHES_STAGING=staging_1,staging_2
|