prima-twig 0.2.4 → 0.2.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 39893567ec05dd93e8792337c10983031d770899
4
- data.tar.gz: 659ad8ba77f0a8be66b6ec4db0121b1d71b6b526
3
+ metadata.gz: c7b49a95c43b880947a37b296a3ff8b6be29047e
4
+ data.tar.gz: 76da46ef24f1ff4ef4e32fb438346b61d26054c7
5
5
  SHA512:
6
- metadata.gz: 01f1bd379d93d0c8d0123d256d09a3da39510fdaa7953bc459960641702a480706aaca05de276d5a44566509bb1ac573bb0db33dc11716a4267af53da51af5eb
7
- data.tar.gz: b523a35adec9db583f1da36946e33c69f1c998e11cbcd109375fa03d99c6f722398e27a035b370598b8ea804d20e9b78fd60b5812922421a7c9f972a16bc1d9e
6
+ metadata.gz: 2abbb30d0b36d3b6347b815850ac3cb8da00217558320d9d391621e9d9beaca68edcd9525dbcdcdf4540bebb454810071d2259560a1253f105fc2d8c4042229a
7
+ data.tar.gz: f4d092aca806c4eb20363fa77358aba72be4df27e62be51a7f48a45211826d418d929c2d10777d096fdb700e3f3e6f750c00b8a8e91a54d0e3f45e18e1c9aae6
data/bin/twig-hotfix CHANGED
@@ -11,7 +11,7 @@ class Hotfix
11
11
  end
12
12
 
13
13
  def execute! args
14
- possible_args = ["start", "stop"]
14
+ possible_args = ["start", "finish"]
15
15
  stop_if args.empty?, [:wrong_args, possible_args]
16
16
  stop_if args.length > 1, [:wrong_args, possible_args]
17
17
 
@@ -21,7 +21,7 @@ class Hotfix
21
21
  case args[0]
22
22
  when "start"
23
23
  start_hotfix!
24
- when "stop"
24
+ when "finish"
25
25
  merge_hotfix!
26
26
  else
27
27
  stop_if true, [:wrong_args, possible_args]
@@ -29,35 +29,42 @@ class Hotfix
29
29
  end
30
30
 
31
31
  def start_hotfix!
32
- branch_name = @prima.clean_branch_name(ask('Nome del branch: '.blue))
33
- branch_name = "hotfix/" + branch_name
32
+
33
+ branch_name = @prima.clean_branch_name(ask('Inserisci il nome del branch (puoi omettere hotfix/): '.cyan))
34
+ stop_if branch_name.length, 'Devi inserire il nome del branch'
35
+ branch_name.prepend issue_type + '/' unless branch_name.include? issue_type
36
+
34
37
  output "Il nome del branch sarà " + branch_name.yellow
35
38
 
36
39
  exec_step "git checkout master"
40
+ exec_step "git pull origin master"
37
41
  exec_step "git checkout -b " + branch_name
38
42
  end
39
43
 
40
44
  def merge_hotfix!
41
45
  current_branch_name = @prima.twig.current_branch_name
42
46
  stop_unless (current_branch_name =~ /^hotfix\//), "Non sei su un branch di hotfix, non posso mergiare nulla"
43
- exec_step "git fetch"
44
- exec_step "git checkout master"
45
- exec_step "git rebase origin/master"
46
- exec_step "git merge #{current_branch_name}"
47
- exec_step "git checkout dev"
48
- exec_step "git rebase origin/dev"
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'
49
59
  exec_step "git merge #{current_branch_name}"
50
- delete_local = @prima.yesno "elimino il branch #{current_branch_name}".blue
51
- if delete_local
52
- exec_step "git branch -d #{current_branch_name}"
53
- end
54
- push = @prima.yesno 'vuoi effettuare il push di dev e master'.blue
55
- if push
56
- exec_step "git checkout master"
57
- exec_step "git push origin master"
58
- exec_step "git checkout dev"
59
- exec_step "git push origin dev"
60
- end
60
+
61
+ exec_step 'git push origin dev' if @prima.yesno 'Vuoi effettuare il push di dev?'.blue
62
+
63
+ # Chiude la issue
64
+ @prima.close_issue(@prima.twig.get_branch_property(current_branch_name, 'issue'))
65
+
66
+ # Rimuove il branch remoto
67
+ exec_step "git push origin :#{current_branch_name}" if @prima.yesno "Vuoi eliminare il branch remoto #{current_branch_name}?".blue
61
68
  end
62
69
  end
63
70
 
data/bin/twig-pick-issue CHANGED
@@ -49,12 +49,18 @@ class PickIssue
49
49
  issue.pull_request?
50
50
  end
51
51
 
52
- issue_number = choose_issue(issues)
53
- branch_name = ask('branch name: '.cyan)
52
+ issue_number = choose_issue issues
53
+ issue_type = select_issue_type issue_number
54
+ base_branch_name_default = issue_type == 'hotfix' ? 'master' : 'dev'
55
+ branch_name = ask('Inserisci il nome del branch (puoi omettere feature/ o hotfix/): '.cyan)
56
+ if branch_name.length == 0
57
+ puts 'Devi inserire il nome del branch'.red
58
+ exit 1
59
+ end
60
+ branch_name.prepend issue_type + '/' unless branch_name.include? issue_type
54
61
  branch_name << "-#{issue_number}"
55
- branch_name = @prima.clean_branch_name branch_name
56
62
 
57
- base_branch_name = ask('from which branch?'.cyan) { |q| q.default = 'dev' }
63
+ base_branch_name = ask('from which branch?'.cyan) { |q| q.default = base_branch_name_default }
58
64
 
59
65
  puts "creo branch con nome #{branch_name} partendo da #{base_branch_name}"
60
66
  @prima.rugged.branches.create(branch_name, base_branch_name)
@@ -83,6 +89,29 @@ class PickIssue
83
89
  end
84
90
  end
85
91
  end
92
+
93
+ def select_issue_type(issue_number)
94
+ has_hotfix_label = @prima.issue_has_label?(issue_number, Prima::LABEL_HOTFIX)
95
+
96
+ if has_hotfix_label
97
+ continue_hotfix = @prima.yesno 'La issue ha la label hotfix, sei sicuro di procedere come hotfix?'.cyan # ask('La issue ha la label hotfix, sei sicuro di procedere come hotfix? (y/n)'.cyan) { |q| q.default = 'y' }
98
+ issue_type = continue_hotfix ? 'hotfix' : 'feature'
99
+ else
100
+ issue_type = choose do |menu|
101
+ menu.prompt = 'Seleziona se la issue dev\'essere trattata come feature oppure hotfix'.cyan
102
+ menu.shell = true
103
+
104
+ menu.choice('feature') {'feature'}
105
+ menu.choice('hotfix') {'hotfix'}
106
+ end
107
+
108
+ if issue_type == 'hotfix'
109
+ puts "Aggiungo la label #{Prima::LABEL_HOTFIX} alla issue".green
110
+ @prima.update_issue_with_label issue_number, Prima::LABEL_HOTFIX
111
+ end
112
+ end
113
+ issue_type
114
+ end
86
115
  end
87
116
 
88
117
  PickIssue.new.execute!
data/lib/prima_twig.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  require_relative 'command.rb'
2
2
  require 'twig'
3
3
  require 'octokit'
4
- require 'trello'
5
4
  require 'yaml'
6
5
  require 'rugged'
7
6
  require 'highline/import'
@@ -9,8 +8,8 @@ require 'highline/import'
9
8
  class Prima
10
9
  LABEL_REVIEW='review'
11
10
  LABEL_WIP='wip'
11
+ LABEL_HOTFIX='hotfix'
12
12
  GITHUB='github'
13
- TRELLO='trello'
14
13
  attr_reader :gh, :twig, :config, :rugged
15
14
 
16
15
  def initialize
@@ -31,10 +30,8 @@ class Prima
31
30
  puts 'Progetto non inizializzato'.red
32
31
  puts 'Creazione del file di configurazione'.yellow
33
32
  github_token = ask 'github token: '
34
- trello_token = ask 'trello token: '
35
33
  conf = {
36
- GITHUB => github_token.to_s,
37
- TRELLO => trello_token.to_s
34
+ GITHUB => github_token.to_s
38
35
  }
39
36
  File.open('twig.yml', 'w') { |file|
40
37
  file.write conf.to_yaml
@@ -74,8 +71,13 @@ class Prima
74
71
  `git config --get remote.origin.url`.split(':').last.chomp.chomp('.git')
75
72
  end
76
73
 
74
+ def repo_user
75
+ repo_url.chomp.split(':').last.split('/').first
76
+ end
77
+
77
78
  def current_branch_ref
78
- "primait:#{ current_branch_name }"
79
+ repo = repo_user
80
+ "#{repo}:#{current_branch_name}"
79
81
  end
80
82
 
81
83
  def clean_branch_name(branch_name)
@@ -163,6 +165,20 @@ class Prima
163
165
  results
164
166
  end
165
167
 
168
+ def merge_pull_request(pr, commit_message='')
169
+ raise "Invalid Pull Request" unless pr
170
+ pr_number = pr[:number]
171
+ @gh.merge_pull_request(repo_name, pr_number, commit_message)
172
+ end
173
+
174
+ def close_issue(issue_number)
175
+ @gh.close_issue(repo_name, issue_number)
176
+ end
177
+
178
+ def repo_url
179
+ `git config remote.origin.url`
180
+ end
181
+
166
182
  def yesno(prompt = 'Continue?', default = true)
167
183
  a = ''
168
184
  s = default ? '[Y/n]' : '[y/N]'
metadata CHANGED
@@ -1,16 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prima-twig
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matteo Giachino
8
8
  - Antonio Murdaca
9
9
  - Alessandro Nuzzo
10
+ - Andrea Usuelli
10
11
  autorequire:
11
12
  bindir: bin
12
13
  cert_chain: []
13
- date: 2015-11-09 00:00:00.000000000 Z
14
+ date: 2015-11-19 00:00:00.000000000 Z
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
17
  name: twig
@@ -68,20 +69,6 @@ dependencies:
68
69
  - - "~>"
69
70
  - !ruby/object:Gem::Version
70
71
  version: '1.6'
71
- - !ruby/object:Gem::Dependency
72
- name: ruby-trello
73
- requirement: !ruby/object:Gem::Requirement
74
- requirements:
75
- - - "~>"
76
- - !ruby/object:Gem::Version
77
- version: '1.1'
78
- type: :runtime
79
- prerelease: false
80
- version_requirements: !ruby/object:Gem::Requirement
81
- requirements:
82
- - - "~>"
83
- - !ruby/object:Gem::Version
84
- version: '1.1'
85
72
  - !ruby/object:Gem::Dependency
86
73
  name: launchy
87
74
  requirement: !ruby/object:Gem::Requirement
@@ -110,7 +97,7 @@ dependencies:
110
97
  - - "~>"
111
98
  - !ruby/object:Gem::Version
112
99
  version: '0.22'
113
- description: Our tools to manage git, github and trello
100
+ description: Our tools to manage git and github
114
101
  email: matteo.giachino@prima.it
115
102
  executables:
116
103
  - twig-circle