prima-twig 1.0.42 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/twig-feature +34 -142
- data/lib/prima_twig.rb +1 -6
- metadata +2 -14
- 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: cac5201db54aab9c3ca72d6730d6d367bfff6fb49f8450b9a8b01556461d901e
|
|
4
|
+
data.tar.gz: 85d5192cbeb4317411f6d15de30bd5849f4c076911252cb3212bbce0972e4080
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: aa3aa668188a7d6fe4c47308d373eea8b70912909c3f48aae81d3f4b900c7c79845beb50c5a762fb399600bd389d16c7ede5d5fc301680e0c4ad3188ccbf305a
|
|
7
|
+
data.tar.gz: 5ed3ffc9d7748ff2817a3894489539ad253954c49fcfd35d81771f2e0212661efab521a0febd42eee6aa7b19cd81109ffbd647bef77419fff50f6748d08e8caa
|
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,7 +75,7 @@ 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'
|
|
@@ -106,18 +101,6 @@ class Release
|
|
|
106
101
|
stop_if true, [:wrong_args, ['start', 'finish', 'deploy', 'deploy project_name', 'deploy stop', 'deploy update', 'aggregator enable', 'aggregator disable']]
|
|
107
102
|
end
|
|
108
103
|
|
|
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
104
|
def aggregator_disable!
|
|
122
105
|
output 'Disable aggregator'
|
|
123
106
|
|
|
@@ -247,25 +230,6 @@ class Release
|
|
|
247
230
|
end
|
|
248
231
|
end
|
|
249
232
|
|
|
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
233
|
def deploy_shutdown!
|
|
270
234
|
output "Recupero le informazioni sui QA attivi..."
|
|
271
235
|
stack_list, envs = get_stacks
|
|
@@ -332,9 +296,7 @@ class Release
|
|
|
332
296
|
|
|
333
297
|
def deploy_lock!
|
|
334
298
|
output "Deploy update menu"
|
|
335
|
-
`git pull
|
|
336
|
-
|
|
337
|
-
@deploy_update = true
|
|
299
|
+
`git pull`
|
|
338
300
|
|
|
339
301
|
output "Recupero le informazioni sui QA attivi..."
|
|
340
302
|
stack_list, envs = get_clusters()
|
|
@@ -372,9 +334,7 @@ class Release
|
|
|
372
334
|
|
|
373
335
|
def deploy_update!
|
|
374
336
|
output "Deploy update menu"
|
|
375
|
-
`git pull
|
|
376
|
-
|
|
377
|
-
@deploy_update = true
|
|
337
|
+
`git pull`
|
|
378
338
|
|
|
379
339
|
output "Recupero le informazioni sui QA attivi..."
|
|
380
340
|
stack_list, envs = get_stacks()
|
|
@@ -414,14 +374,18 @@ class Release
|
|
|
414
374
|
end
|
|
415
375
|
end
|
|
416
376
|
|
|
417
|
-
def suite_py_branches(
|
|
418
|
-
|
|
377
|
+
def suite_py_branches()
|
|
378
|
+
if File.exist?("suitepy-projects.yml")
|
|
379
|
+
arg_projects = YAML.load(File.read("suitepy-projects.yml"))
|
|
419
380
|
|
|
420
|
-
|
|
381
|
+
@projects.merge!(arg_projects)
|
|
421
382
|
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
383
|
+
`rm suitepy-projects.yml`
|
|
384
|
+
|
|
385
|
+
@projects.each_key do |project|
|
|
386
|
+
if @projects[project].empty?
|
|
387
|
+
@projects[project] = choose_branch_to_deploy(project, true)
|
|
388
|
+
end
|
|
425
389
|
end
|
|
426
390
|
end
|
|
427
391
|
end
|
|
@@ -435,7 +399,7 @@ class Release
|
|
|
435
399
|
end
|
|
436
400
|
|
|
437
401
|
def qainit_deploy!(quiet = false)
|
|
438
|
-
`git checkout master && git pull && git
|
|
402
|
+
`git checkout master && git pull && git remote prune origin`
|
|
439
403
|
|
|
440
404
|
`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
405
|
|
|
@@ -454,14 +418,11 @@ class Release
|
|
|
454
418
|
`git checkout -b #{branch_name}`
|
|
455
419
|
end
|
|
456
420
|
|
|
457
|
-
@git_branch = branch_name
|
|
458
|
-
|
|
459
421
|
File.open("projects.yml", "w") { |file| file.write(@projects.to_yaml) }
|
|
460
422
|
|
|
461
423
|
update_drone_yml!
|
|
462
424
|
|
|
463
|
-
`git add projects && \
|
|
464
|
-
git add projects.yml .drone.yml && \
|
|
425
|
+
`git add projects.yml .drone.yml && \
|
|
465
426
|
git commit -m '#{branch_name}' && \
|
|
466
427
|
git push -f --set-upstream origin #{branch_name} && \
|
|
467
428
|
git checkout master`
|
|
@@ -611,89 +572,29 @@ class Release
|
|
|
611
572
|
|
|
612
573
|
def get_alb_host(stack_name)
|
|
613
574
|
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
575
|
when stack_name.include?('alb-http-public')
|
|
633
576
|
logical_resource_id = 'EcsApplicationLoadBalancerPublic'
|
|
634
577
|
when stack_name.include?('alb-ws-public')
|
|
635
578
|
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
579
|
end
|
|
657
580
|
resp = describe_stack_resource(stack_name, logical_resource_id)
|
|
658
581
|
resp = describe_load_balancers([resp.stack_resource_detail.physical_resource_id])
|
|
659
582
|
resp.load_balancers[0].dns_name
|
|
660
583
|
end
|
|
661
584
|
|
|
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
585
|
def update_cluster_stack(stack_name, tags = [])
|
|
676
586
|
stack_body = IO.read('cloudformation/stacks/ecs-cluster.yml')
|
|
677
587
|
update_stack(stack_name, stack_body, [], tags)
|
|
678
588
|
end
|
|
679
589
|
|
|
680
590
|
def choose_branch_to_deploy(project_name, select_master = false)
|
|
681
|
-
|
|
591
|
+
# chiamare api octokit per recuperare i branch/commit
|
|
682
592
|
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
|
|
593
|
+
branches = @gh.branches("primait/#{project_name}", {per_page: 100})
|
|
594
|
+
master_branch = branches.select {|branch| branch[:name] == 'master'}[0]
|
|
694
595
|
|
|
695
596
|
if select_master || branches.length == 1
|
|
696
|
-
branch_name =
|
|
597
|
+
branch_name = 'master'
|
|
697
598
|
else
|
|
698
599
|
branches.insert(0, branches.delete(master_branch))
|
|
699
600
|
branch_name = choose do |menu|
|
|
@@ -703,36 +604,27 @@ class Release
|
|
|
703
604
|
git_mail = get_git_mail
|
|
704
605
|
|
|
705
606
|
branches.each_with_index do |branch, index|
|
|
706
|
-
title = @prima.reduce_size(branch, 100)
|
|
607
|
+
title = @prima.reduce_size(branch[:name], 100)
|
|
707
608
|
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
|
|
609
|
+
# msg = branch.include?(git_mail) ? msg.on_blue : msg.on_black # i branch aggiornati da chi lancia la creazione sono su sfondo blu
|
|
610
|
+
menu.choice(msg) { branch[:name] }
|
|
611
|
+
menu.default = branch[:name] if branch == master_branch
|
|
711
612
|
end
|
|
712
613
|
end
|
|
713
614
|
end
|
|
714
615
|
|
|
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 }
|
|
616
|
+
chosen_branch = branches.select {|branch| branch[:name] == branch_name}[0]
|
|
617
|
+
name = branch_name
|
|
618
|
+
revision = chosen_branch[:commit][:sha]
|
|
619
|
+
{ 'name' => name, 'revision' => revision[0..14], 'default_branch' => select_master }
|
|
721
620
|
end
|
|
722
621
|
|
|
723
622
|
def select_branch_to_deploy(project_name, branch_name)
|
|
724
|
-
Dir.chdir "projects/#{project_name}"
|
|
725
623
|
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('<>', '')
|
|
624
|
+
branch = @gh.branch("primait/#{project_name}", branch_name)
|
|
625
|
+
name = branch[:name]
|
|
626
|
+
revision = branch[:commit][:sha]
|
|
627
|
+
committer_email = branch[:commit][:commit][:author][:email]
|
|
736
628
|
{ 'name' => name, 'revision' => revision[0..14], 'committer' => committer_email }
|
|
737
629
|
end
|
|
738
630
|
|
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.0
|
|
4
|
+
version: 1.2.0
|
|
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
|
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!
|