gitsflow 0.2.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6f98f39375bce585ccac7ecc133bc3b12534030449a90ce5157b784bdcb57b9c
4
- data.tar.gz: 2a3c7c5d556fae0353f339a6505ef9258aa5d18b8132f84af24d887ef051759a
3
+ metadata.gz: ab581d802ba36fbbe4d333b427d5d2edfb2f94a17a7751a0c39e007653a7e5c4
4
+ data.tar.gz: 7a37a86e9265ab26a6e21f432610ca28dcd4d568a87d474f969a32832d218d24
5
5
  SHA512:
6
- metadata.gz: de9b16e875d6b6e1320bdb2c6d357544be747a8343ad4fe5d7345ca822033c16e844761fda0cf112605960d51efa690f52e8387753c2f71bd478ccbb8da2540d
7
- data.tar.gz: c668eeb23d3f568e0ed8512134abbe4d76ad37234b579cfeb6f10ec7f3ad5a6f1c4bd1e25e17ef491315be2965c41b1360e1793b2bbf192ae1c4b7638085cd54
6
+ metadata.gz: 8ad1d35eb966e4a404ece60ebea38261c55c949332bb3f7810efccfd02fe0a750fb3091bd6e85f000030aca6f6b38540347026c085e4e52fb1b95ce00beb09c8
7
+ data.tar.gz: f0e49b3325438b976178cf0bbe32cdba57ae8299f755b8f369817d375cebf8221ab584c08fc0910a4e433dbce24af5b7534eb719ef6133d91f80362ae836b094
data/.gitignore CHANGED
@@ -7,6 +7,7 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ .env
10
11
 
11
12
  # rspec failure tracking
12
13
  .rspec_status
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
- And then execute:
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
- Or install it yourself as:
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
- ```mermaid
26
- graph TB
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 hotfix start HOTFIX DESCRIPTION
76
- 9. git sflow hotfix [reintegration|finish] HOTFIX_BRANCH
77
- 10. git sflow release start RELEASE
78
- 11. git sflow push BRANCH\
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
 
@@ -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,7 +36,28 @@ module GitLab
36
36
 
37
37
 
38
38
 
39
- def self.exist_issue? (iid)
39
+ def self.create_labels
40
+ url = "projects/#{$GITLAB_PROJECT_ID}/labels"
41
+ params = [
42
+ {name: 'feature', color: "#5CB85C"},
43
+ {name: 'default_branch', color: "#34495E"},
44
+ {name: 'version', color: "#34495E"},
45
+ {name: 'hotfix', color: "#d9534f"},
46
+ {name: 'production', color: "#F45D43"},
47
+ {name: 'urgent', color: "#d9534f"},
48
+ {name: 'bugfix', color: "#D9534F"},
49
+ {name: 'changelog', color: "#0033CC"},
50
+ {name: 'Staging', color: "#FAD8C7"},
51
+ ]
52
+ $GIT_BRANCHES_STAGING.each do |staging|
53
+ params << {name: staging, color: '#FAD8C7'}
54
+ end
55
+
56
+ params << {name: $GITLAB_NEXT_RELEASE_LIST, color: '#34495E'}
57
+
58
+ params.each do |label_params|
59
+ self.request_post(url, label_params)
60
+ end
40
61
 
41
62
  end
42
63
 
@@ -59,7 +59,7 @@ class GitLab::Issue
59
59
  end
60
60
 
61
61
  def self.find_by(search)
62
- url = "issues?search=#{search.values[0]}&in=#{search.keys[0]}&state=opened"
62
+ url = "projects/#{$GITLAB_PROJECT_ID}/issues?search=#{search.values[0]}&in=#{search.keys[0]}&state=opened"
63
63
  issue_json = GitLab.request_get(url)[0]
64
64
  if issue_json
65
65
  issue = GitLab::Issue.new
@@ -70,7 +70,7 @@ class GitLab::Issue
70
70
  end
71
71
 
72
72
  def self.find_by_branch(branch)
73
- url = "issues?search=#{branch}"
73
+ url = "projects/#{$GITLAB_PROJECT_ID}/issues?search=#{branch}"
74
74
  issue_json = GitLab.request_get(url)[0]
75
75
  if issue_json
76
76
  issue = GitLab::Issue.new
@@ -81,13 +81,13 @@ class GitLab::Issue
81
81
  end
82
82
 
83
83
  def self.all
84
- url = "issues?state=opened"
84
+ url = "projects/#{$GITLAB_PROJECT_ID}/issues?state=opened"
85
85
  GitLab.request_get(url)
86
86
  end
87
87
 
88
88
 
89
89
  def self.from_list(list_name)
90
- url = "issues?labels=#{list_name}&state=opened"
90
+ url = "projects/#{$GITLAB_PROJECT_ID}/issues?labels=#{list_name}&state=opened"
91
91
  issues = []
92
92
  issues_gitlab = GitLab.request_get(url)
93
93
  issues_gitlab.each do |obj|
@@ -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
@@ -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.2.0"
18
+ VERSION = "0.2.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.feature_code_review
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.code_review()
97
+ self.codereview()
97
98
  end
98
99
 
99
- def self.bugfix_code_review
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.code_review()
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.bg_cyan
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.code_review
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 #{issues.size} issues\n".blue
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
- # mr_master = GitLab::MergeRequest.new(
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,47 +246,29 @@ 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
- print "Release version #{version}\n".blue
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.md\n".yellow
262
+ print "\nSetting changelog message in CHANGELOG\n".yellow
297
263
  sleep 2
298
- # option = STDIN.gets.chomp
299
-
300
- # if option != "ok"
301
- # raise "abort!"
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.md')
269
+ system('git add CHANGELOG')
308
270
  system("git commit -m 'update CHANGELOG version #{version}'")
309
- Git.push issue_release.branch
271
+ Git.push release_branch
310
272
 
311
273
  issue_release.description = "#{changelogs.join("")}\n * #{issues.map{|i| "##{i.iid},"}.join(' ')}"
312
274
 
@@ -327,8 +289,6 @@ class SFlow
327
289
 
328
290
  raise exception.message
329
291
  end
330
-
331
-
332
292
 
333
293
  end
334
294
 
@@ -393,6 +353,7 @@ class SFlow
393
353
  puts "\n\nInstalling git alias\n\n".yellow
394
354
  print " \u{1F611} git sflow alias"
395
355
  print " (instaling...) \r".yellow
356
+ GitLab.create_labels
396
357
  sleep 2
397
358
  system("git config --local alias.sflow '!sh -c \" sflow $1 $2 $3 $4\" - '")
398
359
  print " \u{1F601}\ git sflow alias"
@@ -406,6 +367,11 @@ class SFlow
406
367
 
407
368
  end
408
369
 
370
+
371
+ def push_
372
+
373
+ end
374
+
409
375
  private
410
376
 
411
377
  def self.config_
@@ -417,10 +383,12 @@ class SFlow
417
383
  print "GITLAB_TOKEN=\n".pink
418
384
  print "GITLAB_URL_API=\n".pink
419
385
  print "GITLAB_EMAIL=\n".pink
420
- print "GITLAB_LISTS=Do\n".pink
386
+ print "GITLAB_LISTS=To Do,Doing,Next Release,Staging\n".pink
387
+ print "GITLAB_NEXT_RELEASE_LIST=Next Release\n".pink
421
388
  print "GIT_BRANCH_MASTER=master\n".pink
422
389
  print "GIT_BRANCH_DEVELOP=develop\n".pink
423
390
  print "GIT_BRANCHES_STAGING=staging_1,staging_2\n".pink
391
+
424
392
  end
425
393
 
426
394
  def self.set_error(e)
@@ -429,11 +397,12 @@ class SFlow
429
397
  print "\n"
430
398
  print "#{e.message}".yellow.bg_red
431
399
  print "\n\n"
400
+ print "#{e.backtrace}".yellow.bg_red
401
+ print "\n\n"
432
402
  end
433
403
 
434
404
  def self.validates
435
405
  print "Running validations... \n\n".yellow
436
-
437
406
  if !$GITLAB_PROJECT_ID || !$GITLAB_TOKEN || !$GITLAB_URL_API ||
438
407
  !$GIT_BRANCH_MASTER || !$GIT_BRANCH_DEVELOP || !$GITLAB_LISTS || !$GITLAB_NEXT_RELEASE_LIST
439
408
  print "Variables not configured\n".yellow
@@ -459,10 +428,12 @@ class SFlow
459
428
  print "5 - git sflow bugfix start BUGFIX DESCRIPTION\n".yellow
460
429
  print "6 - git sflow bugfix [reintegration|finish] BUGFIX_BRANCH\n".yellow
461
430
  print "7 - git sflow bugfix codereview BUGFIX_BRANCH\n".yellow
462
- print "8 - git sflow hotfix start HOTFIX DESCRIPTION\n".yellow
463
- print "9 - git sflow hotfix [reintegration|finish] HOTFIX_BRANCH\n".yellow
464
- print "10 - git sflow release start RELEASE\n".yellow
465
- print "11 - git sflow push BRANCH\n".yellow
431
+ print "8 - git sflow bugfix staging BUGFIX_BRANCH\n".yellow
432
+ print "9 - git sflow hotfix start HOTFIX DESCRIPTION\n".yellow
433
+ print "10 - git sflow hotfix [reintegration|finish] HOTFIX_BRANCH\n".yellow
434
+ print "11 - git sflow release start RELEASE\n".yellow
435
+ print "12 - git sflow release finish RELEASE\n".yellow
436
+ print "13 - git sflow push BRANCH\n".yellow
466
437
 
467
438
  choice = -1
468
439
  question = "Choice a number for show a example or 0 for exit:\n\n".light_blue
@@ -485,9 +456,17 @@ class SFlow
485
456
  when '7'
486
457
  print "-> git sflow bugfix codereview 12-bugfix/Ticket#9999\n"
487
458
  when '8'
488
- print "-> git sflow hotfix start Ticket#9999 'Ticket#9999 Bug at production in...'\n\n"
459
+ print "-> git sflow bugfix staging 12-bugfix/Ticket#9999\n"
489
460
  when '9'
461
+ print "-> git sflow hotfix start Ticket#9999 'Ticket#9999 Bug at production in...'\n\n"
462
+ when '10'
490
463
  print "-> git sflow hotfix reintegration Ticket#9999'\n\n"
464
+ when '11'
465
+ print "-> git sflow release start v5.5.99'\n\n"
466
+ when '12'
467
+ print "-> git sflow release finish v5.5.99'\n\n"
468
+ when '13'
469
+ print "-> git sflow push BRANCH\n\n"
491
470
  when '0'
492
471
  else
493
472
  end
@@ -515,7 +494,7 @@ class SFlow
515
494
  else
516
495
  (!source_branch.match('feature') && !source_branch.match('bugfix')) rescue raise "invalid branch!"
517
496
  end
518
- remove_labels = $GIT_BRANCHES_STAGING + $GITLAB_LISTS
497
+ remove_labels = $GIT_BRANCHES_STAGING + $GITLAB_LISTS + ['Staging']
519
498
  new_labels << 'changelog'
520
499
  new_labels << $GITLAB_NEXT_RELEASE_LIST
521
500
  old_labels = issue.obj_gitlab["labels"]
@@ -547,7 +526,7 @@ class SFlow
547
526
  print "\nYou are on branch: #{branch}\n\n".yellow
548
527
  end
549
528
 
550
- def self.code_review
529
+ def self.codereview
551
530
  Git.fetch "develop"
552
531
  Git.checkout "develop"
553
532
  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.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos Wherbet
@@ -87,7 +87,6 @@ executables:
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
- - ".env"
91
90
  - ".gitignore"
92
91
  - CODE_OF_CONDUCT.md
93
92
  - Gemfile
@@ -100,6 +99,7 @@ files:
100
99
  - lib/Git/git.rb
101
100
  - lib/GitLab/gitlab.rb
102
101
  - lib/GitLab/issue.rb
102
+ - lib/GitLab/list.rb
103
103
  - lib/GitLab/merge_request.rb
104
104
  - lib/GitLab/user.rb
105
105
  - lib/config.rb
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