hanzo 0.4.4 → 0.4.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 95dcbdcf0dc439565c0e0e11fd23bbebb0af3019
4
- data.tar.gz: 4a3d79e25f7504b737e2bf040f3c7a04573b7381
3
+ metadata.gz: f674c358cb028c6d898cbfe965302cbebe29fc1e
4
+ data.tar.gz: 035ddff1d09974cc28cf2e34fd9d355bd6ccac55
5
5
  SHA512:
6
- metadata.gz: 84e4637277a29e7522827dcfeeb6618579c4674990aa1fab55237e8f6d651470663306f125f41ffe31eae2cc986dc5445dd221ad5180532347114f0324bba0bf
7
- data.tar.gz: 3b21fad59f6a83a2f36c2a877526a2dca37ef7661b41b58c5b7afdec262e8ae836ff7dc66a94e2e83bfadc92561a8fa2a05b808f3ee9f3df21a0210a1cfd200b
6
+ metadata.gz: eef2e1e94cd27dd9ee18d360011a68f9625c2c756809ecb806b460a630fc2bcab7b86813b51e224d5db69f288882b9f137458f3431bd5d5b0561a535bb958b4a
7
+ data.tar.gz: b4a635f8317df367ba83f8d87f68cb752103ee575ab3dce7589e4353463712bd0ad9f6e5d71405f12fc6b8d309257f27849b32c33bdfa0404c7e19ba25901f20
data/lib/hanzo/cli.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'hanzo/modules/deploy'
2
+ require 'hanzo/modules/diff'
2
3
  require 'hanzo/modules/install'
3
4
  require 'hanzo/modules/config'
4
5
 
@@ -31,6 +32,7 @@ module Hanzo
31
32
 
32
33
  Available actions:
33
34
  deploy - Deploy a branch or a tag
35
+ diff - Show the diff between HEAD and the current release
34
36
  install - Install Hanzo configuration
35
37
  config - Manage Heroku configuration variables
36
38
 
@@ -0,0 +1,51 @@
1
+ module Hanzo
2
+ class Diff < Base
3
+ # Classes
4
+ UnknownEnvironment = Class.new(StandardError)
5
+ UninstalledEnvironment = Class.new(StandardError)
6
+
7
+ protected
8
+
9
+ def initialize_variables
10
+ @env = extract_argument(1)
11
+ @env ||= Hanzo::Installers::Remotes.environments.keys.first
12
+ end
13
+
14
+ def initialize_cli
15
+ initialize_help && return if @env.nil?
16
+
17
+ diff
18
+ rescue UnknownEnvironment
19
+ Hanzo.unindent_print "Environment `#{@env}` doesn't exist. Add it to .heroku-remotes and run:\n hanzo install remotes", :red
20
+ Hanzo.unindent_print "\nFor more information, read https://github.com/mirego/hanzo#install-remotes", :red
21
+ rescue UninstalledEnvironment
22
+ Hanzo.unindent_print "Environment `#{@env}` has been found in your .heroku-remotes file. Before using it, you must install it:\n hanzo install remotes", :red
23
+ end
24
+
25
+ def initialize_help
26
+ @options.banner = <<-BANNER.unindent
27
+ Usage: hanzo diff ENVIRONMENT
28
+
29
+ Available environments
30
+ BANNER
31
+
32
+ Hanzo::Installers::Remotes.environments.each do |env|
33
+ @options.banner << " - #{env.first}\n"
34
+ end
35
+ end
36
+
37
+ def diff
38
+ validate_environment_existence!
39
+ Hanzo.run "git remote update #{@env} && git diff #{@env}/master...HEAD"
40
+ end
41
+
42
+ def validate_environment_existence!
43
+ raise UnknownEnvironment unless fetcher.exist?
44
+ raise UninstalledEnvironment unless fetcher.installed?
45
+ end
46
+
47
+ def fetcher
48
+ @fetcher ||= Hanzo::Fetchers::Environment.new(@env)
49
+ end
50
+ end
51
+ end
data/lib/hanzo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Hanzo
2
- VERSION = '0.4.4'
2
+ VERSION = '0.4.5'.freeze
3
3
  end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ describe Hanzo::CLI do
4
+ describe :diff do
5
+ let(:env) { 'production' }
6
+ let(:diff!) { Hanzo::CLI.new(['diff', env]) }
7
+ let(:heroku_remotes) { { 'production' => 'heroku-app-production' } }
8
+
9
+ let(:diff_cmd) { "git remote update #{env} && git diff #{env}/master...HEAD" }
10
+
11
+ before do
12
+ expect(Hanzo::Installers::Remotes).to receive(:environments).and_return(['production'])
13
+ expect(Hanzo::Installers::Remotes).to receive(:installed_environments).and_return(['production'])
14
+ end
15
+
16
+ context 'successful diff' do
17
+ let(:diff_result) { true }
18
+
19
+ before do
20
+ expect(Hanzo).to receive(:run).with(diff_cmd).once.and_return(diff_result)
21
+ end
22
+
23
+ it 'should update the right remote and run a diff' do
24
+ diff!
25
+ end
26
+ end
27
+ end
28
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanzo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Garneau
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-30 00:00:00.000000000 Z
11
+ date: 2016-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -119,12 +119,14 @@ files:
119
119
  - lib/hanzo/heroku.rb
120
120
  - lib/hanzo/modules/config.rb
121
121
  - lib/hanzo/modules/deploy.rb
122
+ - lib/hanzo/modules/diff.rb
122
123
  - lib/hanzo/modules/install.rb
123
124
  - lib/hanzo/modules/installers/labs.rb
124
125
  - lib/hanzo/modules/installers/remotes.rb
125
126
  - lib/hanzo/version.rb
126
127
  - spec/cli/config_spec.rb
127
128
  - spec/cli/deploy_spec.rb
129
+ - spec/cli/diff_spec.rb
128
130
  - spec/cli/install_spec.rb
129
131
  - spec/fetchers/environment_spec.rb
130
132
  - spec/spec_helper.rb
@@ -148,13 +150,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
150
  version: '0'
149
151
  requirements: []
150
152
  rubyforge_project:
151
- rubygems_version: 2.4.5
153
+ rubygems_version: 2.5.1
152
154
  signing_key:
153
155
  specification_version: 4
154
156
  summary: Hanzo is a tool to handle deployments in multiple environments on Heroku.
155
157
  test_files:
156
158
  - spec/cli/config_spec.rb
157
159
  - spec/cli/deploy_spec.rb
160
+ - spec/cli/diff_spec.rb
158
161
  - spec/cli/install_spec.rb
159
162
  - spec/fetchers/environment_spec.rb
160
163
  - spec/spec_helper.rb