hu 1.2.5 → 1.3.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/hu.gemspec +1 -0
- data/lib/hu/deploy.rb +99 -15
- data/lib/hu/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b674ec9985e3ac991e88bcf451a44b13d1cd21b6
|
4
|
+
data.tar.gz: 3d0651f52053bf56a2806efc553d42d131ca158c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3cadd159b4da1444da1ce4fa4e96cc8805dd840efd11b79fd27ce5fe310e63e58355bf4ed7b6d41bcf1b5e780c9fe288bba1d98980dbba8e48c1b56323b7596e
|
7
|
+
data.tar.gz: 95801c40cb64d7428168098b123c0e0309701d2e1d956ff3b6f6ba30b5a6629814fe96dae61f6981ed53a62cf26efe2d9b3835aa40475e081c0611136f15446e
|
data/hu.gemspec
CHANGED
data/lib/hu/deploy.rb
CHANGED
@@ -12,6 +12,7 @@ require 'chronic_duration'
|
|
12
12
|
require 'tempfile'
|
13
13
|
require 'thread_safe'
|
14
14
|
require 'io/console'
|
15
|
+
require 'rugged'
|
15
16
|
|
16
17
|
module Hu
|
17
18
|
class Cli < Optix::Cli
|
@@ -35,23 +36,57 @@ module Hu
|
|
35
36
|
def deploy(cmd, opts, argv)
|
36
37
|
trap('INT') { shutdown; safe_abort; exit 1 }
|
37
38
|
at_exit {
|
38
|
-
if 130 == $!.status
|
39
|
+
if $!.class == SystemExit && 130 == $!.status
|
39
40
|
shutdown
|
40
41
|
puts
|
41
42
|
safe_abort
|
42
|
-
exit $!.status
|
43
43
|
end
|
44
44
|
}
|
45
45
|
|
46
|
-
|
46
|
+
begin
|
47
|
+
@git = Rugged::Repository.discover('.')
|
48
|
+
rescue Rugged::RepositoryError => e
|
47
49
|
puts
|
48
|
-
puts "
|
50
|
+
puts "Git error: #{e}".color(:red)
|
51
|
+
puts "You need to be inside the working copy of the app that you wish to deploy.".color(:red)
|
49
52
|
puts
|
50
53
|
safe_abort
|
51
54
|
print TTY::Cursor.prev_line
|
52
55
|
exit 1
|
53
56
|
end
|
54
57
|
|
58
|
+
Dir.chdir(@git.workdir)
|
59
|
+
|
60
|
+
if @git.config['branch.master.remote'] != 'origin'
|
61
|
+
puts
|
62
|
+
puts "ERROR: Remote of branch 'master' does not point to 'origin'.".color(:red)
|
63
|
+
puts
|
64
|
+
puts " Sorry, we need an origin here. We really do."
|
65
|
+
puts
|
66
|
+
exit 1
|
67
|
+
end
|
68
|
+
|
69
|
+
if @git.config['gitflow.branch.master'].nil?
|
70
|
+
puts
|
71
|
+
puts "ERROR: This repository doesn't seem to be git-flow enabled.".color(:red)
|
72
|
+
puts
|
73
|
+
puts " Please run 'git flow init'."
|
74
|
+
puts
|
75
|
+
exit 1
|
76
|
+
end
|
77
|
+
|
78
|
+
unless @git.config['gitflow.prefix.versiontag'].nil? ||
|
79
|
+
@git.config['gitflow.prefix.versiontag'].empty?
|
80
|
+
puts
|
81
|
+
puts "ERROR: git-flow version prefix configured.".color(:red)
|
82
|
+
puts
|
83
|
+
puts " Please use this command to remove the prefix:"
|
84
|
+
puts
|
85
|
+
puts " git config --add gitflow.prefix.versiontag ''".bright
|
86
|
+
puts
|
87
|
+
exit 1
|
88
|
+
end
|
89
|
+
|
55
90
|
push_url = get_heroku_git_remote
|
56
91
|
|
57
92
|
wc_update = Thread.new { update_working_copy }
|
@@ -60,7 +95,7 @@ module Hu
|
|
60
95
|
|
61
96
|
if app.nil?
|
62
97
|
puts
|
63
|
-
puts "
|
98
|
+
puts "ERROR: Found no heroku app for git remote #{push_url}".color(:red)
|
64
99
|
puts " Are you logged into the right heroku account?".color(:red)
|
65
100
|
puts
|
66
101
|
puts " Please run 'git remote rm heroku'. Then run 'hu deploy' again to select a new remote."
|
@@ -72,7 +107,7 @@ module Hu
|
|
72
107
|
|
73
108
|
if app['id'] != stag_app_id
|
74
109
|
puts
|
75
|
-
puts "
|
110
|
+
puts "ERROR: The git remote 'heroku' points to app '#{app['name']}'".color(:red)
|
76
111
|
puts " which is not in stage 'staging'".color(:red)+
|
77
112
|
" of pipeline '#{pipeline_name}'.".color(:red)
|
78
113
|
puts
|
@@ -94,9 +129,34 @@ module Hu
|
|
94
129
|
unbusy
|
95
130
|
|
96
131
|
highest_version = find_highest_version_tag
|
97
|
-
|
98
|
-
|
99
|
-
|
132
|
+
begin
|
133
|
+
highest_versionomy = Versionomy.parse(highest_version)
|
134
|
+
rescue
|
135
|
+
highest_versionomy = Versionomy.parse('v0.0.0')
|
136
|
+
end
|
137
|
+
|
138
|
+
all_tags = Set.new(@git.references.to_a("refs/tags/*").collect{|e| e.target.name})
|
139
|
+
|
140
|
+
tiny_bump = highest_versionomy.dup
|
141
|
+
minor_bump = highest_versionomy.dup
|
142
|
+
major_bump = highest_versionomy.dup
|
143
|
+
|
144
|
+
loop do
|
145
|
+
tiny_bump = tiny_bump.bump(:tiny)
|
146
|
+
break unless all_tags.include? tiny_bump.to_s
|
147
|
+
end
|
148
|
+
loop do
|
149
|
+
minor_bump = minor_bump.bump(:minor)
|
150
|
+
break unless all_tags.include? minor_bump.to_s
|
151
|
+
end
|
152
|
+
loop do
|
153
|
+
major_bump = major_bump.bump(:major)
|
154
|
+
break unless all_tags.include? tiny_bump.to_s
|
155
|
+
end
|
156
|
+
tiny_bump = tiny_bump.to_s
|
157
|
+
minor_bump = minor_bump.to_s
|
158
|
+
major_bump = major_bump.to_s
|
159
|
+
|
100
160
|
likely_next_version = tiny_bump
|
101
161
|
|
102
162
|
release_tag, branch_already_exists = prompt_for_release_tag(likely_next_version, likely_next_version, true)
|
@@ -114,7 +174,11 @@ module Hu
|
|
114
174
|
if release_branch_exists
|
115
175
|
puts "\nThis release will be "+release_tag.color(:red).bright
|
116
176
|
unless highest_version == 'v0.0.0'
|
117
|
-
|
177
|
+
env = {
|
178
|
+
'PREVIOUS_TAG' => highest_version,
|
179
|
+
'RELEASE_TAG' => release_tag
|
180
|
+
}
|
181
|
+
changelog=create_changelog(env) unless highest_version == 'v0.0.0'
|
118
182
|
unless changelog.empty?
|
119
183
|
puts "\nChanges since "+highest_version.bright+":"
|
120
184
|
puts changelog
|
@@ -166,7 +230,11 @@ module Hu
|
|
166
230
|
tf.write "#{release_tag}\n#{changelog}"
|
167
231
|
tf.close
|
168
232
|
ENV['EDITOR'] = "cp #{tf.path}"
|
169
|
-
|
233
|
+
env = {
|
234
|
+
'PREVIOUS_TAG' => highest_version,
|
235
|
+
'RELEASE_TAG' => release_tag
|
236
|
+
}
|
237
|
+
unless 0 == finish_release(release_tag, env)
|
170
238
|
abort_merge
|
171
239
|
puts "*** ERROR! Push did not complete. *** ".color(:red)
|
172
240
|
end
|
@@ -175,7 +243,6 @@ module Hu
|
|
175
243
|
when :push_to_staging
|
176
244
|
push_command = "git push #{push_url} release/#{release_tag}:master -f"
|
177
245
|
`#{push_command}`
|
178
|
-
puts
|
179
246
|
anykey
|
180
247
|
when :abort_ask
|
181
248
|
puts if delete_branch("release/#{release_tag}")
|
@@ -537,7 +604,15 @@ module Hu
|
|
537
604
|
EOS
|
538
605
|
end
|
539
606
|
|
540
|
-
def finish_release(release_tag)
|
607
|
+
def finish_release(release_tag, env)
|
608
|
+
env.each { |k,v| ENV[k] = v }
|
609
|
+
if File.executable? '.hu/hooks/pre_release'
|
610
|
+
run_each <<-EOS.strip_heredoc
|
611
|
+
# Run pre-release hook
|
612
|
+
.hu/hooks/pre_release
|
613
|
+
EOS
|
614
|
+
end
|
615
|
+
|
541
616
|
run_each <<-EOS.strip_heredoc
|
542
617
|
:return
|
543
618
|
# Finish release
|
@@ -563,6 +638,15 @@ module Hu
|
|
563
638
|
EOS
|
564
639
|
end
|
565
640
|
|
641
|
+
def create_changelog(env)
|
642
|
+
if File.executable? '.hu/hooks/changelog'
|
643
|
+
env.each { |k,v| ENV[k] = v }
|
644
|
+
`.hu/hooks/changelog`
|
645
|
+
else
|
646
|
+
`git log --pretty=format:" - %s" #{env['PREVIOUS_TAG']}..HEAD 2>/dev/null`
|
647
|
+
end
|
648
|
+
end
|
649
|
+
|
566
650
|
def shutdown
|
567
651
|
@@shutting_down = true
|
568
652
|
unbusy
|
@@ -577,7 +661,7 @@ module Hu
|
|
577
661
|
end
|
578
662
|
|
579
663
|
def unbusy
|
580
|
-
@@spinner
|
664
|
+
@@spinner&.stop
|
581
665
|
printf "\e[?25h"
|
582
666
|
end
|
583
667
|
|
@@ -589,7 +673,7 @@ module Hu
|
|
589
673
|
|
590
674
|
def anykey
|
591
675
|
puts TTY::Cursor.hide
|
592
|
-
print "--- Press any key
|
676
|
+
print "--- Press any key ---".color(:cyan)
|
593
677
|
STDIN.getch
|
594
678
|
print TTY::Cursor.clear_line + TTY::Cursor.show
|
595
679
|
end
|
data/lib/hu/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- moe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -248,6 +248,20 @@ dependencies:
|
|
248
248
|
- - ">="
|
249
249
|
- !ruby/object:Gem::Version
|
250
250
|
version: '0'
|
251
|
+
- !ruby/object:Gem::Dependency
|
252
|
+
name: rugged
|
253
|
+
requirement: !ruby/object:Gem::Requirement
|
254
|
+
requirements:
|
255
|
+
- - ">="
|
256
|
+
- !ruby/object:Gem::Version
|
257
|
+
version: '0'
|
258
|
+
type: :runtime
|
259
|
+
prerelease: false
|
260
|
+
version_requirements: !ruby/object:Gem::Requirement
|
261
|
+
requirements:
|
262
|
+
- - ">="
|
263
|
+
- !ruby/object:Gem::Version
|
264
|
+
version: '0'
|
251
265
|
description: Heroku Utility.
|
252
266
|
email:
|
253
267
|
- moe@busyloop.net
|