prima-twig 1.0.43 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/twig-feature +35 -144
- data/lib/prima_twig.rb +1 -6
- metadata +3 -15
- data/bin/twig-circle +0 -51
- data/bin/twig-deploy +0 -248
- data/bin/twig-hotfix +0 -105
- data/bin/twig-open-pr +0 -115
- data/bin/twig-pick-issue +0 -108
- data/bin/twig-review +0 -76
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c85bc796545f4a0f38fa6be4380dec88e6c2fb771e8fe39d5044c57e9c0a6ee
|
4
|
+
data.tar.gz: 4eef557dba95dc99c88f3f07951bb6219aa2fe63eb928c12e9c6a743954400e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d2472dfc0c866aab6563b9cca251fd606256dc05c55bd450abbd65e5db86371327626bbb8001b06a3e15f50355f6d9a26fb1760513bc3a04698c043b9cbf572
|
7
|
+
data.tar.gz: 4e86ab32ba1df95732055f29da69469fdd2c71d197233c5db726e18780910141206e9eb6ab5d94d2db621b3be8199d0bf22bc69bc8fdc24c26204eef6a0f1c19
|
data/bin/twig-feature
CHANGED
@@ -8,6 +8,7 @@ require 'json'
|
|
8
8
|
require 'launchy'
|
9
9
|
require 'pp'
|
10
10
|
require 'redis'
|
11
|
+
require 'octokit'
|
11
12
|
|
12
13
|
class Release
|
13
14
|
include Command
|
@@ -24,7 +25,6 @@ class Release
|
|
24
25
|
end
|
25
26
|
@dns_record_identifier = nil
|
26
27
|
@ecs_cluster_name = nil
|
27
|
-
@deploy_update = false
|
28
28
|
@projects = {
|
29
29
|
'prima' => {},
|
30
30
|
'urania' => {},
|
@@ -33,7 +33,6 @@ class Release
|
|
33
33
|
'hal9000' => {},
|
34
34
|
'fidaty' => {},
|
35
35
|
'peano' => {},
|
36
|
-
# 'rogoreport' => {},
|
37
36
|
'assange' => {},
|
38
37
|
'borat' => {},
|
39
38
|
'crash' => {},
|
@@ -42,7 +41,6 @@ class Release
|
|
42
41
|
'roger' => {},
|
43
42
|
'rachele' => {},
|
44
43
|
'leftorium' => {},
|
45
|
-
'pyxis-npm' => {},
|
46
44
|
'starsky' => {},
|
47
45
|
'hutch' => {},
|
48
46
|
'maia' => {},
|
@@ -53,16 +51,13 @@ class Release
|
|
53
51
|
}
|
54
52
|
@base_stack_name_alb = 'ecs-alb-http-public-qa-'
|
55
53
|
@base_stack_name_alb_ws = 'ecs-alb-ws-public-qa-'
|
56
|
-
@git_branch = ''
|
57
54
|
@cloudflare = Rubyflare.connect_with(ENV['CLOUDFLARE_EMAIL'], ENV['CLOUDFLARE_APIKEY'])
|
55
|
+
@config = YAML.load_file 'twig.yml'
|
56
|
+
@gh = Octokit::Client.new(:access_token => @config['github'])
|
58
57
|
end
|
59
58
|
|
60
59
|
def execute!(args)
|
61
60
|
case args[0]
|
62
|
-
when 'start'
|
63
|
-
start_feature!
|
64
|
-
when 'finish'
|
65
|
-
finish_feature!
|
66
61
|
when 'qainit'
|
67
62
|
abort('Non sei nella cartella di qainit') unless Dir.pwd.match 'qainit$' or Dir.pwd.match '/drone/src'
|
68
63
|
if ['terminate', 'stop', 'shutdown', 'halt', 'destroy'].include? args[1]
|
@@ -80,11 +75,10 @@ class Release
|
|
80
75
|
when 'suite'
|
81
76
|
abort('Non sei nella cartella di qainit') unless Dir.pwd.match 'qainit$'
|
82
77
|
if 'deploy' == args[1]
|
83
|
-
suite_py_branches(
|
78
|
+
suite_py_branches()
|
84
79
|
qainit_deploy!(true)
|
85
80
|
end
|
86
81
|
when 'deploy'
|
87
|
-
abort('Non sei nella cartella di artemide') unless Dir.pwd.match 'artemide$'
|
88
82
|
if 'lock' == args[1]
|
89
83
|
deploy_lock!
|
90
84
|
end
|
@@ -106,18 +100,6 @@ class Release
|
|
106
100
|
stop_if true, [:wrong_args, ['start', 'finish', 'deploy', 'deploy project_name', 'deploy stop', 'deploy update', 'aggregator enable', 'aggregator disable']]
|
107
101
|
end
|
108
102
|
|
109
|
-
def start_feature!
|
110
|
-
branch_name = @prima.clean_branch_name(ask('Inserisci il nome del branch (puoi omettere feature/): '.cyan))
|
111
|
-
stop_unless !branch_name.empty?, 'Devi inserire il nome del branch'
|
112
|
-
branch_name.prepend 'feature/' unless branch_name.include? 'feature'
|
113
|
-
|
114
|
-
output "Il nome del branch sarà " + branch_name.yellow
|
115
|
-
|
116
|
-
exec_step "git checkout master"
|
117
|
-
exec_step "git pull origin master"
|
118
|
-
exec_step "git checkout -b " + branch_name
|
119
|
-
end
|
120
|
-
|
121
103
|
def aggregator_disable!
|
122
104
|
output 'Disable aggregator'
|
123
105
|
|
@@ -247,25 +229,6 @@ class Release
|
|
247
229
|
end
|
248
230
|
end
|
249
231
|
|
250
|
-
def finish_feature!
|
251
|
-
current_branch_name = @prima.twig.current_branch_name
|
252
|
-
stop_unless (current_branch_name =~ /^feature\//), "Non sei su un branch di feature, non posso mergiare nulla"
|
253
|
-
|
254
|
-
# Mergia la PR
|
255
|
-
pr = @prima.get_pr
|
256
|
-
stop_unless pr, 'Pull Request not found'
|
257
|
-
@prima.merge_pull_request pr
|
258
|
-
|
259
|
-
output "La Pull Request e' stata mergiata!".green
|
260
|
-
|
261
|
-
# Chiude la issue
|
262
|
-
issue_number = @prima.twig.get_branch_property(current_branch_name, 'issue')
|
263
|
-
@prima.close_issue(issue_number) if issue_number
|
264
|
-
|
265
|
-
# Rimuove il branch remoto
|
266
|
-
exec_step "git push origin :#{current_branch_name}" if @prima.yesno "Vuoi eliminare il branch remoto #{current_branch_name}?".blue
|
267
|
-
end
|
268
|
-
|
269
232
|
def deploy_shutdown!
|
270
233
|
output "Recupero le informazioni sui QA attivi..."
|
271
234
|
stack_list, envs = get_stacks
|
@@ -332,9 +295,7 @@ class Release
|
|
332
295
|
|
333
296
|
def deploy_lock!
|
334
297
|
output "Deploy update menu"
|
335
|
-
`git pull
|
336
|
-
|
337
|
-
@deploy_update = true
|
298
|
+
`git pull`
|
338
299
|
|
339
300
|
output "Recupero le informazioni sui QA attivi..."
|
340
301
|
stack_list, envs = get_clusters()
|
@@ -372,9 +333,7 @@ class Release
|
|
372
333
|
|
373
334
|
def deploy_update!
|
374
335
|
output "Deploy update menu"
|
375
|
-
`git pull
|
376
|
-
|
377
|
-
@deploy_update = true
|
336
|
+
`git pull`
|
378
337
|
|
379
338
|
output "Recupero le informazioni sui QA attivi..."
|
380
339
|
stack_list, envs = get_stacks()
|
@@ -414,14 +373,18 @@ class Release
|
|
414
373
|
end
|
415
374
|
end
|
416
375
|
|
417
|
-
def suite_py_branches(
|
418
|
-
|
376
|
+
def suite_py_branches()
|
377
|
+
if File.exist?("suitepy-projects.yml")
|
378
|
+
arg_projects = YAML.load(File.read("suitepy-projects.yml"))
|
419
379
|
|
420
|
-
|
380
|
+
@projects.merge!(arg_projects)
|
421
381
|
|
422
|
-
|
423
|
-
|
424
|
-
|
382
|
+
`rm suitepy-projects.yml`
|
383
|
+
|
384
|
+
@projects.each_key do |project|
|
385
|
+
if @projects[project].empty?
|
386
|
+
@projects[project] = choose_branch_to_deploy(project, true)
|
387
|
+
end
|
425
388
|
end
|
426
389
|
end
|
427
390
|
end
|
@@ -435,7 +398,7 @@ class Release
|
|
435
398
|
end
|
436
399
|
|
437
400
|
def qainit_deploy!(quiet = false)
|
438
|
-
`git checkout master && git pull && git
|
401
|
+
`git checkout master && git pull && git remote prune origin`
|
439
402
|
|
440
403
|
`git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | xargs git branch -D`
|
441
404
|
|
@@ -454,14 +417,11 @@ class Release
|
|
454
417
|
`git checkout -b #{branch_name}`
|
455
418
|
end
|
456
419
|
|
457
|
-
@git_branch = branch_name
|
458
|
-
|
459
420
|
File.open("projects.yml", "w") { |file| file.write(@projects.to_yaml) }
|
460
421
|
|
461
422
|
update_drone_yml!
|
462
423
|
|
463
|
-
`git add projects && \
|
464
|
-
git add projects.yml .drone.yml && \
|
424
|
+
`git add projects.yml .drone.yml && \
|
465
425
|
git commit -m '#{branch_name}' && \
|
466
426
|
git push -f --set-upstream origin #{branch_name} && \
|
467
427
|
git checkout master`
|
@@ -611,89 +571,29 @@ class Release
|
|
611
571
|
|
612
572
|
def get_alb_host(stack_name)
|
613
573
|
case
|
614
|
-
when stack_name.include?('web')
|
615
|
-
logical_resource_id = 'EcsApplicationLoadBalancerPublic'
|
616
|
-
when stack_name.include?('urania')
|
617
|
-
logical_resource_id = 'EcsApplicationLoadBalancerInternal'
|
618
|
-
when stack_name.include?('backoffice')
|
619
|
-
logical_resource_id = 'EcsApplicationLoadBalancerPublic'
|
620
|
-
when stack_name.include?('bburago')
|
621
|
-
logical_resource_id = 'EcsApplicationLoadBalancerInternal'
|
622
|
-
when stack_name.include?('hal9000')
|
623
|
-
logical_resource_id = 'EcsApplicationLoadBalancerInternal'
|
624
|
-
when stack_name.include?('fidaty')
|
625
|
-
logical_resource_id = 'EcsApplicationLoadBalancerInternal'
|
626
|
-
when stack_name.include?('activia')
|
627
|
-
logical_resource_id = 'EcsApplicationLoadBalancerInternal'
|
628
|
-
when stack_name.include?('skynet')
|
629
|
-
logical_resource_id = 'EcsApplicationLoadBalancerInternal'
|
630
|
-
when stack_name.include?('roger')
|
631
|
-
logical_resource_id = 'EcsApplicationLoadBalancerInternal'
|
632
574
|
when stack_name.include?('alb-http-public')
|
633
575
|
logical_resource_id = 'EcsApplicationLoadBalancerPublic'
|
634
576
|
when stack_name.include?('alb-ws-public')
|
635
577
|
logical_resource_id = 'EcsApplicationLoadBalancerPublic'
|
636
|
-
when stack_name.include?('peano')
|
637
|
-
logical_resource_id = 'EcsApplicationLoadBalancerInternal'
|
638
|
-
when stack_name.include?('leftorium')
|
639
|
-
logical_resource_id = 'EcsApplicationLoadBalancerInternal'
|
640
|
-
when stack_name.include?('assange')
|
641
|
-
logical_resource_id = 'EcsApplicationLoadBalancerPublic'
|
642
|
-
when stack_name.include?('borat')
|
643
|
-
logical_resource_id = 'EcsApplicationLoadBalancerPublic'
|
644
|
-
when stack_name.include?('crash')
|
645
|
-
logical_resource_id = 'EcsApplicationLoadBalancerPublic'
|
646
|
-
when stack_name.include?('rachele')
|
647
|
-
logical_resource_id = 'EcsApplicationLoadBalancerInternal'
|
648
|
-
when stack_name.include?('starsky')
|
649
|
-
logical_resource_id = 'EcsApplicationLoadBalancerPublic'
|
650
|
-
when stack_name.include?('hutch')
|
651
|
-
logical_resource_id = 'EcsApplicationLoadBalancerPublic'
|
652
|
-
when stack_name.include?('maia')
|
653
|
-
logical_resource_id = 'EcsApplicationLoadBalancerPublic'
|
654
|
-
when stack_name.include?('legion')
|
655
|
-
logical_resource_id = 'EcsApplicationLoadBalancerInternal'
|
656
578
|
end
|
657
579
|
resp = describe_stack_resource(stack_name, logical_resource_id)
|
658
580
|
resp = describe_load_balancers([resp.stack_resource_detail.physical_resource_id])
|
659
581
|
resp.load_balancers[0].dns_name
|
660
582
|
end
|
661
583
|
|
662
|
-
def deploy_pyxis?
|
663
|
-
if defined? @deploy_pyxis
|
664
|
-
@deploy_pyxis
|
665
|
-
else
|
666
|
-
pyxis_updated = `git log -p -1 --unified=0 | grep pyxis-npm:`.length > 0
|
667
|
-
|
668
|
-
update_pyxis = !@projects['pyxis-npm'].empty? && @projects['pyxis-npm']['name'] != 'master' && pyxis_updated
|
669
|
-
|
670
|
-
@deploy_pyxis = update_pyxis
|
671
|
-
return update_pyxis
|
672
|
-
end
|
673
|
-
end
|
674
|
-
|
675
584
|
def update_cluster_stack(stack_name, tags = [])
|
676
|
-
stack_body =
|
585
|
+
stack_body = get_stack_template(stack_name)
|
677
586
|
update_stack(stack_name, stack_body, [], tags)
|
678
587
|
end
|
679
588
|
|
680
589
|
def choose_branch_to_deploy(project_name, select_master = false)
|
681
|
-
|
590
|
+
# chiamare api octokit per recuperare i branch/commit
|
682
591
|
output "Recupero la lista dei branch del progetto #{project_name}..."
|
683
|
-
|
684
|
-
|
685
|
-
branches = %x[ git for-each-ref --sort=-committerdate refs/remotes/ --format='%(refname) %(objectname) %(committeremail)' | sed 's/refs\\/remotes\\/origin\\///g' ]
|
686
|
-
.split("\n").delete_if { |b| b.include?('HEAD') }[0..49]
|
687
|
-
|
688
|
-
master_branch = nil
|
689
|
-
|
690
|
-
branches.each do |branch|
|
691
|
-
master_branch = branch if branch.match(/^master\s+/)
|
692
|
-
break unless master_branch.nil?
|
693
|
-
end
|
592
|
+
branches = @gh.branches("primait/#{project_name}", {per_page: 100})
|
593
|
+
master_branch = branches.select {|branch| branch[:name] == 'master'}[0]
|
694
594
|
|
695
595
|
if select_master || branches.length == 1
|
696
|
-
branch_name =
|
596
|
+
branch_name = 'master'
|
697
597
|
else
|
698
598
|
branches.insert(0, branches.delete(master_branch))
|
699
599
|
branch_name = choose do |menu|
|
@@ -703,36 +603,27 @@ class Release
|
|
703
603
|
git_mail = get_git_mail
|
704
604
|
|
705
605
|
branches.each_with_index do |branch, index|
|
706
|
-
title = @prima.reduce_size(branch, 100)
|
606
|
+
title = @prima.reduce_size(branch[:name], 100)
|
707
607
|
msg = index.odd? ? title.white : title.light_yellow # uno bianco e uno giallo alternati
|
708
|
-
msg = branch.include?(git_mail) ? msg.on_blue : msg.on_black # i branch aggiornati da chi lancia la creazione sono su sfondo blu
|
709
|
-
menu.choice(msg) { branch }
|
710
|
-
menu.default = branch if branch == master_branch
|
608
|
+
# msg = branch.include?(git_mail) ? msg.on_blue : msg.on_black # i branch aggiornati da chi lancia la creazione sono su sfondo blu
|
609
|
+
menu.choice(msg) { branch[:name] }
|
610
|
+
menu.default = branch[:name] if branch == master_branch
|
711
611
|
end
|
712
612
|
end
|
713
613
|
end
|
714
614
|
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
committer_email = branch_name.split(' ')[2].tr('<>', '')
|
720
|
-
{ 'name' => name, 'revision' => revision[0..14], 'committer' => committer_email, 'default_branch' => select_master }
|
615
|
+
chosen_branch = branches.select {|branch| branch[:name] == branch_name}[0]
|
616
|
+
name = branch_name
|
617
|
+
revision = chosen_branch[:commit][:sha]
|
618
|
+
{ 'name' => name, 'revision' => revision[0..14], 'default_branch' => select_master }
|
721
619
|
end
|
722
620
|
|
723
621
|
def select_branch_to_deploy(project_name, branch_name)
|
724
|
-
Dir.chdir "projects/#{project_name}"
|
725
622
|
output "Recupero il branch #{project_name}:#{branch_name} ..."
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
.first
|
731
|
-
|
732
|
-
Dir.chdir "../../"
|
733
|
-
name = branch_name.split(' ')[0]
|
734
|
-
revision = branch_name.split(' ')[1]
|
735
|
-
committer_email = branch_name.split(' ')[2].tr('<>', '')
|
623
|
+
branch = @gh.branch("primait/#{project_name}", branch_name)
|
624
|
+
name = branch[:name]
|
625
|
+
revision = branch[:commit][:sha]
|
626
|
+
committer_email = branch[:commit][:commit][:author][:email]
|
736
627
|
{ 'name' => name, 'revision' => revision[0..14], 'committer' => committer_email }
|
737
628
|
end
|
738
629
|
|
data/lib/prima_twig.rb
CHANGED
@@ -8,12 +8,7 @@ require 'aws-sdk-core'
|
|
8
8
|
require 'rubyflare'
|
9
9
|
|
10
10
|
class Prima
|
11
|
-
|
12
|
-
LABEL_WIP='wip'
|
13
|
-
LABEL_HOTFIX='hotfix'
|
14
|
-
LABEL_NEXT_RELEASE='next release'
|
15
|
-
LABEL_IN_STAGING='in staging'
|
16
|
-
CONFIG_KEYS=['github', 'mandrill', 'sparkpost', 'cloudflare_email', 'cloudflare_apikey', 'aws_username', 'aws_password', 'prima_apikey']
|
11
|
+
CONFIG_KEYS=['github', 'cloudflare_email', 'cloudflare_apikey', 'aws_username', 'aws_password', 'prima_apikey']
|
17
12
|
attr_reader :gh, :twig, :config, :rugged, :aws
|
18
13
|
|
19
14
|
def initialize
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prima-twig
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matteo Giachino
|
@@ -14,7 +14,7 @@ authors:
|
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
|
-
date: 2020-07-
|
17
|
+
date: 2020-07-21 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: aws-sdk-autoscaling
|
@@ -285,24 +285,12 @@ dependencies:
|
|
285
285
|
description: Our tools to manage git and github
|
286
286
|
email: matteo.giachino@prima.it
|
287
287
|
executables:
|
288
|
-
- twig-circle
|
289
|
-
- twig-deploy
|
290
288
|
- twig-feature
|
291
|
-
- twig-hotfix
|
292
|
-
- twig-open-pr
|
293
|
-
- twig-pick-issue
|
294
|
-
- twig-review
|
295
289
|
- twig-update-ami
|
296
290
|
extensions: []
|
297
291
|
extra_rdoc_files: []
|
298
292
|
files:
|
299
|
-
- bin/twig-circle
|
300
|
-
- bin/twig-deploy
|
301
293
|
- bin/twig-feature
|
302
|
-
- bin/twig-hotfix
|
303
|
-
- bin/twig-open-pr
|
304
|
-
- bin/twig-pick-issue
|
305
|
-
- bin/twig-review
|
306
294
|
- bin/twig-update-ami
|
307
295
|
- lib/command.rb
|
308
296
|
- lib/prima_aws_client.rb
|
@@ -326,7 +314,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
326
314
|
- !ruby/object:Gem::Version
|
327
315
|
version: '0'
|
328
316
|
requirements: []
|
329
|
-
rubygems_version: 3.0.
|
317
|
+
rubygems_version: 3.0.3
|
330
318
|
signing_key:
|
331
319
|
specification_version: 4
|
332
320
|
summary: The Prima twig toolbelt
|
data/bin/twig-circle
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require_relative '../lib/prima_twig.rb'
|
5
|
-
require 'colorize'
|
6
|
-
require 'highline/import'
|
7
|
-
require 'launchy'
|
8
|
-
|
9
|
-
|
10
|
-
def help_content
|
11
|
-
<<-HELP
|
12
|
-
|
13
|
-
twig-circle
|
14
|
-
===========
|
15
|
-
|
16
|
-
Opens circleci contextual to the current branch
|
17
|
-
|
18
|
-
Synopsis
|
19
|
-
--------
|
20
|
-
|
21
|
-
twig circle [-b|--branch <branch>]
|
22
|
-
|
23
|
-
Description
|
24
|
-
-----------
|
25
|
-
|
26
|
-
Opens circleci contextual to the current branch
|
27
|
-
|
28
|
-
Subcommand for Twig: <http://rondevera.github.io/twig/>
|
29
|
-
Author: Matteo Giachino <https://github.com/matteosister>
|
30
|
-
|
31
|
-
HELP
|
32
|
-
end
|
33
|
-
|
34
|
-
args = ARGV.dup
|
35
|
-
|
36
|
-
if args.include?('--help')
|
37
|
-
puts help_content
|
38
|
-
exit
|
39
|
-
end
|
40
|
-
|
41
|
-
class Circle
|
42
|
-
def initialize
|
43
|
-
@prima = Prima.new
|
44
|
-
end
|
45
|
-
|
46
|
-
def execute!
|
47
|
-
Launchy.open("https://circleci.com/gh/#{ @prima.repo_name }/tree/#{ @prima.current_branch_name }")
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
Circle.new.execute!
|
data/bin/twig-deploy
DELETED
@@ -1,248 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require_relative '../lib/prima_twig.rb'
|
5
|
-
require_relative '../lib/prima_aws_client.rb'
|
6
|
-
require 'colorize'
|
7
|
-
require 'highline/import'
|
8
|
-
require 'aws-sdk-batch'
|
9
|
-
require 'aws-sdk-cloudformation'
|
10
|
-
require 'aws-sdk-ecs'
|
11
|
-
require 'aws-sdk-s3'
|
12
|
-
require 'redcarpet'
|
13
|
-
require 'mail'
|
14
|
-
require 'erb'
|
15
|
-
require 'base64'
|
16
|
-
require 'rubyflare'
|
17
|
-
require 'pp'
|
18
|
-
|
19
|
-
def help_content
|
20
|
-
<<-HELP
|
21
|
-
|
22
|
-
twig-deploy
|
23
|
-
===========
|
24
|
-
|
25
|
-
Deploys prima in production
|
26
|
-
|
27
|
-
Synopsis
|
28
|
-
--------
|
29
|
-
|
30
|
-
twig deploy
|
31
|
-
|
32
|
-
Description
|
33
|
-
-----------
|
34
|
-
|
35
|
-
It will ask you which artifact you want to deploy, run bin/deploy script and then send an email to the team when it's done.
|
36
|
-
|
37
|
-
Subcommand for Twig: <http://rondevera.github.io/twig/>
|
38
|
-
Author: Andrea Usuelli <https://github.com/andreausu>
|
39
|
-
|
40
|
-
HELP
|
41
|
-
end
|
42
|
-
|
43
|
-
args = ARGV.dup
|
44
|
-
|
45
|
-
if args.include?('--help')
|
46
|
-
puts help_content
|
47
|
-
exit
|
48
|
-
end
|
49
|
-
|
50
|
-
class Review
|
51
|
-
include Command
|
52
|
-
include PrimaAwsClient
|
53
|
-
|
54
|
-
def initialize
|
55
|
-
@prima = Prima.new
|
56
|
-
output "Controllo se ci sono aggiornamenti da fare..."
|
57
|
-
exec "gem update prima-twig && twig deploy #{ARGV.join ' '}" unless `gem outdated`.lines.grep(/^prima-twig \(.*\)/).empty?
|
58
|
-
@cf = Aws::CloudFormation::Client.new
|
59
|
-
@ecs = Aws::ECS::Client.new
|
60
|
-
@s3 = Aws::S3::Client.new
|
61
|
-
@batch = Aws::Batch::Client.new
|
62
|
-
@s3_bucket = "prima-artifacts-encrypted"
|
63
|
-
end
|
64
|
-
|
65
|
-
def execute! args
|
66
|
-
unless args.empty?
|
67
|
-
case args[0]
|
68
|
-
when "parameters"
|
69
|
-
reload_parameters!
|
70
|
-
else
|
71
|
-
stop_if true, [:wrong_args, ['parameters']]
|
72
|
-
end
|
73
|
-
else
|
74
|
-
deploy_revision!
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def deploy_revision!
|
79
|
-
stop_if @prima.head_detached?, :detached_head
|
80
|
-
stop_if @prima.repo_has_modified_files?, "Non posso deployare con file non commitati"
|
81
|
-
|
82
|
-
output "Recupero degli artifacts in corso, attendi qualche secondo...".yellow
|
83
|
-
artifacts = get_artifacts[0..49]
|
84
|
-
|
85
|
-
artifact_rev = choose do |menu|
|
86
|
-
menu.prompt = 'Scegli la release da deployare: '.cyan
|
87
|
-
menu.shell = true
|
88
|
-
|
89
|
-
artifacts.each do |v|
|
90
|
-
title = @prima.reduce_size(v[:branch], 100)
|
91
|
-
commit_msg = @prima.reduce_size(v[:commit_msg], 250)
|
92
|
-
msg = "#{title} #{v[:created_at].strftime('%d/%m/%Y %H:%M:%S')} #{v[:rev]} #{commit_msg}".light_blue
|
93
|
-
menu.choice(msg) {v[:rev]}
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
user = `git config user.name`.delete "\n"
|
98
|
-
artifact = artifacts.select {|v| v[:rev] == artifact_rev}.first
|
99
|
-
|
100
|
-
do_deploy! artifact_rev
|
101
|
-
|
102
|
-
mail = Mail.new do
|
103
|
-
from 'deploy@prima.it'
|
104
|
-
to 'deploy@prima.it'
|
105
|
-
subject "#{user} ha effettuato il deploy della revision #{artifact[:rev]}"
|
106
|
-
end
|
107
|
-
|
108
|
-
commit_msg = clean_commit_message(artifact[:commit_msg])
|
109
|
-
|
110
|
-
body = "## Deploy in produzione effettuato con successo\n\n"
|
111
|
-
body << "Data: #{Time.now.strftime('%d/%m/%Y %H:%M:%S')}\n\n"
|
112
|
-
body << "Utente: #{user}\n\n"
|
113
|
-
body << "Revision: [#{artifact[:rev]}](https://github.com/primait/prima/commit/#{artifact[:rev]}) del #{artifact[:created_at].strftime('%d/%m/%Y %H:%M:%S')}\n\n"
|
114
|
-
body << "Branch: [#{artifact[:branch]}](https://github.com/primait/prima/tree/#{artifact[:branch]})\n\n"
|
115
|
-
body << "Commit: #{commit_msg.gsub(/_/, '\_')}\n\n"
|
116
|
-
|
117
|
-
htmlBody = Redcarpet::Markdown.new(Redcarpet::Render::HTML.new).render body
|
118
|
-
|
119
|
-
html_part = Mail::Part.new do
|
120
|
-
content_type 'text/html; charset=UTF-8'
|
121
|
-
body htmlBody
|
122
|
-
end
|
123
|
-
text_part = Mail::Part.new do
|
124
|
-
body htmlBody.gsub(/<br\s?\/?>/, "\r\n").gsub(/<\/?[^>]*>/, '')
|
125
|
-
end
|
126
|
-
|
127
|
-
mail.html_part = html_part
|
128
|
-
mail.text_part = text_part
|
129
|
-
|
130
|
-
opts = {address: 'email-smtp.eu-west-1.amazonaws.com', port: '587'}
|
131
|
-
opts[:user_name] = @prima.config['aws_username']
|
132
|
-
opts[:password] = @prima.config['aws_password']
|
133
|
-
|
134
|
-
exec_step "git checkout master"
|
135
|
-
|
136
|
-
mail.delivery_method(:smtp, opts)
|
137
|
-
mail.deliver
|
138
|
-
|
139
|
-
invalidate_prismic_cache
|
140
|
-
|
141
|
-
launch_crawler
|
142
|
-
|
143
|
-
exec_step "terminal-notifier -message 'Deploy terminato'" if which 'terminal-notifier'
|
144
|
-
end
|
145
|
-
|
146
|
-
def invalidate_prismic_cache
|
147
|
-
[
|
148
|
-
"guarantee",
|
149
|
-
"glossary",
|
150
|
-
"guide",
|
151
|
-
"faq"
|
152
|
-
].each do |page|
|
153
|
-
|
154
|
-
exec_step "curl -X POST -H \"Content-Type: application/json\" https://www.prima.it/api/cms/update/#{page}?apikey=#{@prima.config['prima_apikey']}"
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
def reload_parameters!
|
159
|
-
artifact_rev = ''
|
160
|
-
resp = @cf.describe_stacks({
|
161
|
-
stack_name: "ecs-task-web-vpc-production"
|
162
|
-
})
|
163
|
-
resp.stacks[0].parameters.each do |param|
|
164
|
-
if param.parameter_key == 'ReleaseVersion'
|
165
|
-
artifact_rev = param.parameter_value
|
166
|
-
break
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
do_deploy!(artifact_rev, true)
|
171
|
-
|
172
|
-
output "\nFinito di aggiornare i parameters.yml\n".green
|
173
|
-
end
|
174
|
-
|
175
|
-
def do_deploy!(artifact_rev, reload_parameters=false)
|
176
|
-
deploy_command = "bin/deploy #{artifact_rev}"
|
177
|
-
deploy_command << " reloadparameters" if reload_parameters
|
178
|
-
|
179
|
-
output "Il comando per il deploy sara': #{deploy_command}".yellow
|
180
|
-
confirm_message = "Sei sicuro di voler effettuare "
|
181
|
-
reload_parameters ? (confirm_message << "il reload dei parameters ") : (confirm_message << " il deploy ")
|
182
|
-
confirm_message << "in produzione?"
|
183
|
-
|
184
|
-
exit unless @prima.yesno confirm_message.blue
|
185
|
-
|
186
|
-
exec_step "git fetch"
|
187
|
-
exec_step "git checkout #{artifact_rev}"
|
188
|
-
exec_step deploy_command
|
189
|
-
|
190
|
-
stack_name_web = 'ecs-task-web-vpc-production'
|
191
|
-
stack_name_consumer = 'ecs-task-consumer-vpc-production'
|
192
|
-
stack_name_cron = 'ecs-task-consumer-vpc-production'
|
193
|
-
stack_name_job = 'batch-job-php-production'
|
194
|
-
wait_for_stack_ready(stack_name_web) unless stack_ready?(stack_name_web)
|
195
|
-
wait_for_stack_ready(stack_name_consumer) unless stack_ready?(stack_name_consumer)
|
196
|
-
wait_for_stack_ready(stack_name_cron) unless stack_ready?(stack_name_cron)
|
197
|
-
wait_for_stack_ready(stack_name_job) unless stack_ready?(stack_name_job)
|
198
|
-
end
|
199
|
-
|
200
|
-
def get_artifacts
|
201
|
-
artifacts = []
|
202
|
-
resp = @s3.list_objects(bucket: @s3_bucket, prefix: 'prima')
|
203
|
-
resp.contents.each do |l|
|
204
|
-
# aggiungiamo solo gli artefatti prodotti a partire dal branch master, riconosciuti tramite i metadata
|
205
|
-
rev = l.key.match(/^prima\/(\w{15}).tar.gz$/).captures.first if l.key.match(/^prima\/(\w{15}).tar.gz$/)
|
206
|
-
if rev
|
207
|
-
object = @s3.head_object(bucket: @s3_bucket, key: l.key)
|
208
|
-
commit_msg = ''
|
209
|
-
commit_msg = Base64.decode64(object.metadata['commit_msg']).strip if object.metadata.has_key? 'commit_msg'
|
210
|
-
artifacts << {rev: rev, created_at: object.last_modified, branch: object.metadata['branch'], commit_msg: commit_msg } if (object.metadata.has_key? 'branch') && (object.metadata['branch'] == 'master')
|
211
|
-
end
|
212
|
-
end
|
213
|
-
artifacts.sort_by { |v| v[:created_at] }.reverse
|
214
|
-
end
|
215
|
-
|
216
|
-
def launch_crawler()
|
217
|
-
resp = describe_stack_resource('batch-job-crawler-production', 'JobDefinition')
|
218
|
-
|
219
|
-
@batch.submit_job({
|
220
|
-
job_name: "crawler", # required
|
221
|
-
job_queue: "tools-production", # required
|
222
|
-
job_definition: resp.stack_resource_detail.physical_resource_id # required
|
223
|
-
})
|
224
|
-
|
225
|
-
output "Crawler lanciato con successo!\n".green
|
226
|
-
end
|
227
|
-
|
228
|
-
end
|
229
|
-
|
230
|
-
def clean_commit_message(commit_msg)
|
231
|
-
commit_msg.gsub! /Merge pull request /i, ''
|
232
|
-
commit_msg.gsub! /from primait\/feature\//i, ''
|
233
|
-
commit_msg = commit_msg[/.+?\(#\d+\)/m] unless commit_msg[/.+?\(#\d+\)/m].nil? # rimuove tutto quello che sta dopo la fine del numero di issue
|
234
|
-
commit_msg[0..99]
|
235
|
-
end
|
236
|
-
|
237
|
-
def which(cmd)
|
238
|
-
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
|
239
|
-
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
|
240
|
-
exts.each { |ext|
|
241
|
-
exe = File.join(path, "#{cmd}#{ext}")
|
242
|
-
return exe if File.executable?(exe) && !File.directory?(exe)
|
243
|
-
}
|
244
|
-
end
|
245
|
-
return nil
|
246
|
-
end
|
247
|
-
|
248
|
-
Review.new.execute! args
|
data/bin/twig-hotfix
DELETED
@@ -1,105 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require_relative '../lib/prima_twig.rb'
|
5
|
-
|
6
|
-
class Hotfix
|
7
|
-
include Command
|
8
|
-
|
9
|
-
def initialize
|
10
|
-
@prima = Prima.new
|
11
|
-
end
|
12
|
-
|
13
|
-
def execute! args
|
14
|
-
possible_args = ["start", "finish"]
|
15
|
-
stop_if args.empty?, [:wrong_args, possible_args]
|
16
|
-
stop_if args.length > 1, [:wrong_args, possible_args]
|
17
|
-
|
18
|
-
stop_if @prima.head_detached?, :detached_head
|
19
|
-
stop_unless @prima.is_clean?, :clean
|
20
|
-
|
21
|
-
case args[0]
|
22
|
-
when "start"
|
23
|
-
start_hotfix!
|
24
|
-
when "finish"
|
25
|
-
merge_hotfix!
|
26
|
-
else
|
27
|
-
stop_if true, [:wrong_args, possible_args]
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def start_hotfix!
|
32
|
-
|
33
|
-
branch_name = @prima.clean_branch_name(ask('Inserisci il nome del branch (puoi omettere hotfix/): '.cyan))
|
34
|
-
stop_unless branch_name.length > 0, 'Devi inserire il nome del branch'
|
35
|
-
branch_name.prepend 'hotfix/' unless branch_name.include? 'hotfix'
|
36
|
-
|
37
|
-
output "Il nome del branch sarà " + branch_name.yellow
|
38
|
-
|
39
|
-
exec_step "git checkout master"
|
40
|
-
exec_step "git pull origin master"
|
41
|
-
exec_step "git checkout -b " + branch_name
|
42
|
-
end
|
43
|
-
|
44
|
-
def merge_hotfix!
|
45
|
-
current_branch_name = @prima.twig.current_branch_name
|
46
|
-
stop_unless (current_branch_name =~ /^hotfix\//), "Non sei su un branch di hotfix, non posso mergiare nulla"
|
47
|
-
|
48
|
-
# Mergia la PR
|
49
|
-
pr = @prima.get_pr
|
50
|
-
stop_unless pr, 'Pull Request not found'
|
51
|
-
@prima.merge_pull_request pr
|
52
|
-
|
53
|
-
output "La Pull Request e' stata mergiata!".green
|
54
|
-
|
55
|
-
# Mergia il branch su dev e pusha
|
56
|
-
exec_step 'git fetch'
|
57
|
-
exec_step 'git checkout dev'
|
58
|
-
exec_step 'git merge origin/dev'
|
59
|
-
exec_step "git merge --no-ff #{current_branch_name}"
|
60
|
-
|
61
|
-
exec_step 'git push origin dev' if @prima.yesno 'Vuoi effettuare il push di dev?'.blue
|
62
|
-
|
63
|
-
# Chiude la issue
|
64
|
-
issue_number = @prima.twig.get_branch_property(current_branch_name, 'issue')
|
65
|
-
@prima.close_issue(issue_number) if issue_number
|
66
|
-
|
67
|
-
# Rimuove il branch remoto
|
68
|
-
exec_step "git push origin :#{current_branch_name}" if @prima.yesno "Vuoi eliminare il branch remoto #{current_branch_name}?".blue
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def help_content
|
73
|
-
<<-HELP
|
74
|
-
|
75
|
-
twig-hotfix
|
76
|
-
===========
|
77
|
-
|
78
|
-
Manage hotfix creation and merging
|
79
|
-
|
80
|
-
Synopsis
|
81
|
-
--------
|
82
|
-
|
83
|
-
twig hotfix start
|
84
|
-
twig hotfix close
|
85
|
-
|
86
|
-
Description
|
87
|
-
-----------
|
88
|
-
|
89
|
-
start creates an hotfix from master branch
|
90
|
-
close closes the actual hotfix by merging to dev and master
|
91
|
-
|
92
|
-
Subcommand for Twig: <http://rondevera.github.io/twig/>
|
93
|
-
Author: Matteo Giachino <https://github.com/matteosister>
|
94
|
-
|
95
|
-
HELP
|
96
|
-
end
|
97
|
-
|
98
|
-
args = ARGV.dup
|
99
|
-
|
100
|
-
if args.include?('--help')
|
101
|
-
puts help_content
|
102
|
-
exit
|
103
|
-
end
|
104
|
-
|
105
|
-
Hotfix.new.execute!(args)
|
data/bin/twig-open-pr
DELETED
@@ -1,115 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require_relative '../lib/prima_twig.rb'
|
5
|
-
require 'colorize'
|
6
|
-
require 'highline/import'
|
7
|
-
require 'launchy'
|
8
|
-
|
9
|
-
|
10
|
-
def help_content
|
11
|
-
<<-HELP
|
12
|
-
|
13
|
-
twig-open-pr
|
14
|
-
============
|
15
|
-
|
16
|
-
Opens a PR on github for this branch, if not already opened
|
17
|
-
|
18
|
-
Synopsis
|
19
|
-
--------
|
20
|
-
|
21
|
-
twig open-pr
|
22
|
-
|
23
|
-
Description
|
24
|
-
-----------
|
25
|
-
|
26
|
-
Checks if a pr is already opened for this branch, if not opens it, otherwise do nothing
|
27
|
-
|
28
|
-
Subcommand for Twig: <http://rondevera.github.io/twig/>
|
29
|
-
Author: Matteo Giachino <https://github.com/matteosister>
|
30
|
-
|
31
|
-
HELP
|
32
|
-
end
|
33
|
-
|
34
|
-
args = ARGV.dup
|
35
|
-
|
36
|
-
if args.include?('--help')
|
37
|
-
puts help_content
|
38
|
-
exit
|
39
|
-
end
|
40
|
-
|
41
|
-
class OpenPR
|
42
|
-
def initialize
|
43
|
-
@prima = Prima.new
|
44
|
-
end
|
45
|
-
|
46
|
-
def execute!
|
47
|
-
unless @prima.gh.user_authenticated?
|
48
|
-
puts 'Non autenticato'
|
49
|
-
exit 1
|
50
|
-
end
|
51
|
-
|
52
|
-
unless @prima.is_a_valid_branch?
|
53
|
-
puts "Non puoi creare una pull request dal branch #{ @prima.current_branch_name }".red
|
54
|
-
exit 1
|
55
|
-
end
|
56
|
-
|
57
|
-
unless is_on_github?
|
58
|
-
puts "Il branch #{ @prima.current_branch_name } non è su github".red
|
59
|
-
push = @prima.yesno 'Vuoi effettuare il push su github'.blue
|
60
|
-
if push
|
61
|
-
cmd = %{ git push -u origin "#{ @prima.current_branch_name }"}
|
62
|
-
system(cmd)
|
63
|
-
else
|
64
|
-
exit 1
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
unless @prima.get_pr_url.nil?
|
69
|
-
puts "Esiste già una pull request per il branch #{ @prima.current_branch_name }. url: #{ @prima.get_pr_url }".yellow
|
70
|
-
pr_property = @prima.twig.get_branch_property(@prima.current_branch_name, 'pr')
|
71
|
-
if pr_property.nil?
|
72
|
-
cmd = %{ twig pr "#{ @prima.get_pr.number }"}
|
73
|
-
exec(cmd)
|
74
|
-
end
|
75
|
-
open = @prima.yesno 'Vuoi aprirla nel browser'.blue
|
76
|
-
if open
|
77
|
-
Launchy.open(@prima.get_pr.html_url)
|
78
|
-
end
|
79
|
-
exit 0
|
80
|
-
end
|
81
|
-
|
82
|
-
pr = create_pull_request('master')
|
83
|
-
puts "Pull Request ##{ pr.number } creata".green
|
84
|
-
cmd = %{ twig pr "#{ pr.number }"}
|
85
|
-
exec(cmd)
|
86
|
-
@prima.update_issue_with_label(@prima.get_property('pr'), Prima::LABEL_WIP)
|
87
|
-
puts "Aggiunta label \"#{ Prima::LABEL_WIP }\" sulla pull request ##{ pr.number }".green
|
88
|
-
puts pr.html_url
|
89
|
-
exit 0
|
90
|
-
end
|
91
|
-
|
92
|
-
def is_on_github?
|
93
|
-
begin
|
94
|
-
@prima.gh.branch @prima.repo_name, @prima.current_branch_name
|
95
|
-
true
|
96
|
-
rescue Octokit::NotFound
|
97
|
-
return false
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
def create_pull_request(base_branch)
|
102
|
-
current_branch_name = @prima.current_branch_name
|
103
|
-
puts "Creazione pull request sul branch #{ base_branch }"
|
104
|
-
title = ask('Titolo: ')
|
105
|
-
head = @prima.current_branch_name
|
106
|
-
body = ask('Body: ')
|
107
|
-
unless @prima.twig.get_branch_property(current_branch_name, 'issue').nil?
|
108
|
-
body << " Issue di riferimento: primait/board##{@prima.twig.get_branch_property(current_branch_name, 'issue')}"
|
109
|
-
end
|
110
|
-
pr = @prima.create_pull_request base_branch, head, title, body
|
111
|
-
@prima.assign_pull_request_to_me(pr.number)
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
OpenPR.new.execute!
|
data/bin/twig-pick-issue
DELETED
@@ -1,108 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require_relative '../lib/prima_twig.rb'
|
5
|
-
require 'colorize'
|
6
|
-
require 'highline/import'
|
7
|
-
require 'pp'
|
8
|
-
|
9
|
-
def help_content
|
10
|
-
<<-HELP
|
11
|
-
|
12
|
-
twig-pick-issue
|
13
|
-
===============
|
14
|
-
|
15
|
-
Picks an issue from github and open a branch for it
|
16
|
-
|
17
|
-
Synopsis
|
18
|
-
--------
|
19
|
-
|
20
|
-
twig pick-issue
|
21
|
-
|
22
|
-
|
23
|
-
Subcommand for Twig: <http://rondevera.github.io/twig/>
|
24
|
-
Author: Matteo Giachino <https://github.com/matteosister>
|
25
|
-
|
26
|
-
HELP
|
27
|
-
end
|
28
|
-
|
29
|
-
args = ARGV.dup
|
30
|
-
|
31
|
-
if args.include?('--help')
|
32
|
-
puts help_content
|
33
|
-
exit
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
|
-
class PickIssue
|
38
|
-
include Command
|
39
|
-
|
40
|
-
def initialize
|
41
|
-
@prima = Prima.new
|
42
|
-
end
|
43
|
-
|
44
|
-
def execute!
|
45
|
-
unless @prima.is_clean?
|
46
|
-
puts 'hai dei file non committati...non posso continuare'.red
|
47
|
-
exit(1)
|
48
|
-
end
|
49
|
-
|
50
|
-
issues = @prima.list_issues
|
51
|
-
|
52
|
-
issue_number = nil
|
53
|
-
args = ARGV.dup
|
54
|
-
if args[0] && args[0].to_i > 0
|
55
|
-
issues.keep_if do |issue|
|
56
|
-
issue.number == args[0].to_i
|
57
|
-
end
|
58
|
-
stop_if issues.empty?, "Issue #{args[0].to_i} non trovata!"
|
59
|
-
issue_number = args[0].to_i
|
60
|
-
else
|
61
|
-
issues.delete_if do |issue|
|
62
|
-
issue.pull_request?
|
63
|
-
end
|
64
|
-
issue_number = choose_issue issues
|
65
|
-
end
|
66
|
-
|
67
|
-
issue_type = 'feature'
|
68
|
-
base_branch_name_default = 'master'
|
69
|
-
branch_name = ask('Inserisci il nome del branch (puoi omettere feature/): '.cyan)
|
70
|
-
if branch_name.length == 0
|
71
|
-
puts 'Devi inserire il nome del branch'.red
|
72
|
-
exit 1
|
73
|
-
end
|
74
|
-
branch_name.prepend issue_type + '/' unless branch_name.include? issue_type
|
75
|
-
branch_name << "-#{issue_number}"
|
76
|
-
|
77
|
-
base_branch_name = ask('from which branch?'.cyan) { |q| q.default = base_branch_name_default }
|
78
|
-
|
79
|
-
puts "creo branch con nome #{branch_name} partendo da #{base_branch_name}"
|
80
|
-
@prima.rugged.branches.create(branch_name, base_branch_name)
|
81
|
-
|
82
|
-
@prima.twig.set_branch_property(branch_name, 'issue', issue_number)
|
83
|
-
@prima.twig.set_branch_property(branch_name, 'diff-branch', base_branch_name)
|
84
|
-
@prima.rugged.checkout(branch_name)
|
85
|
-
@prima.update_issue_with_label(issue_number, Prima::LABEL_WIP)
|
86
|
-
puts "Aggiunta label \"#{ Prima::LABEL_WIP }\" sulla issue primait/board##{ issue_number }".green
|
87
|
-
@prima.assign_issue_to_me(issue_number)
|
88
|
-
puts "Issue primait/board##{ issue_number } assegnata a #{ @prima.user_login }".green
|
89
|
-
end
|
90
|
-
|
91
|
-
def choose_issue(issues)
|
92
|
-
choose do |menu|
|
93
|
-
menu.prompt = 'Pick an issue: '.cyan
|
94
|
-
menu.shell = true
|
95
|
-
|
96
|
-
issues.each do |issue|
|
97
|
-
milestone = issue.milestone
|
98
|
-
issue_number = "##{issue.number}".green
|
99
|
-
title = @prima.reduce_size(issue.title, 100).light_blue
|
100
|
-
msg = "#{issue_number} - #{title}"
|
101
|
-
msg << " [#{milestone.title}]".blue unless milestone.nil?
|
102
|
-
menu.choice(msg) {issue.number}
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
PickIssue.new.execute!
|
data/bin/twig-review
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require_relative '../lib/prima_twig.rb'
|
5
|
-
require 'colorize'
|
6
|
-
require 'highline/import'
|
7
|
-
|
8
|
-
|
9
|
-
def help_content
|
10
|
-
<<-HELP
|
11
|
-
|
12
|
-
twig-review
|
13
|
-
===========
|
14
|
-
|
15
|
-
Puts the pull request for the current branch in review
|
16
|
-
|
17
|
-
Synopsis
|
18
|
-
--------
|
19
|
-
|
20
|
-
twig review
|
21
|
-
|
22
|
-
Description
|
23
|
-
-----------
|
24
|
-
|
25
|
-
Puts the current branch pr in review
|
26
|
-
|
27
|
-
Subcommand for Twig: <http://rondevera.github.io/twig/>
|
28
|
-
Author: Matteo Giachino <https://github.com/matteosister>
|
29
|
-
|
30
|
-
HELP
|
31
|
-
end
|
32
|
-
|
33
|
-
args = ARGV.dup
|
34
|
-
|
35
|
-
if args.include?('--help')
|
36
|
-
puts help_content
|
37
|
-
exit
|
38
|
-
end
|
39
|
-
|
40
|
-
class Review
|
41
|
-
def initialize
|
42
|
-
@prima = Prima.new
|
43
|
-
end
|
44
|
-
|
45
|
-
def execute!
|
46
|
-
unless @prima.is_a_valid_branch?
|
47
|
-
puts "Il branch #{ @prima.current_branch_name } non può essere in review".red
|
48
|
-
exit 1
|
49
|
-
end
|
50
|
-
|
51
|
-
unless @prima.has_property?('pr')
|
52
|
-
puts 'Il branch attuale non ha la proprietà PR'.red
|
53
|
-
exit 1
|
54
|
-
end
|
55
|
-
|
56
|
-
unless @prima.is_already_a_pr?
|
57
|
-
puts 'Il branch attuale non è una pull request'.red
|
58
|
-
exit 1
|
59
|
-
end
|
60
|
-
|
61
|
-
puts "Pull request ##{@prima.get_property('pr')}".cyan
|
62
|
-
puts "Issue ##{@prima.get_property('issue')}".cyan if @prima.has_property?('issue')
|
63
|
-
|
64
|
-
@prima.put_issue_in_review(@prima.get_property('pr'))
|
65
|
-
puts "La pull request #{ @prima.get_property('pr') } è ora in review".green
|
66
|
-
|
67
|
-
if @prima.has_property?('issue')
|
68
|
-
@prima.put_issue_in_review(@prima.get_property('issue'))
|
69
|
-
puts "La issue #{ @prima.get_property('issue') } è ora in review".green
|
70
|
-
end
|
71
|
-
|
72
|
-
exit 0
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
Review.new.execute!
|