auto_tagger 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ 2010-09-16
2
+ - fixed bug where capistrano task set_branch would not set the proper branch
3
+ - fixed bug where capistratno task print_latest_tags would blow up (thanks to Ian Zabel for help in debugging)
4
+ - fixed bug where capistrano would not write the text file to the server if an explicit branch was not set
5
+ - fixed bug where passing -v to autotag would show the help, not the version
6
+
1
7
  2010-08-10
2
8
 
3
9
  - Added the following commands
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
data/auto_tagger.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{auto_tagger}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jeff Dean", "Brian Takita", "Mike Grafton", "Bruce Krysiak", "Pat Nakajima", "Jay Zeschin", "Mike Barinek", "Sarah Mei"]
12
- s.date = %q{2010-09-10}
12
+ s.date = %q{2010-09-16}
13
13
  s.default_executable = %q{autotag}
14
14
  s.email = %q{jeff@zilkey.com}
15
15
  s.executables = ["autotag"]
@@ -32,6 +32,7 @@ Gem::Specification.new do |s|
32
32
  "features/deployment.feature",
33
33
  "features/step_definitions/autotag_steps.rb",
34
34
  "features/step_definitions/deployment_steps.rb",
35
+ "features/step_definitions/shared_steps.rb",
35
36
  "features/support/env.rb",
36
37
  "features/support/step_helpers.rb",
37
38
  "features/templates/cap_ext_deploy.erb",
@@ -16,6 +16,7 @@ Feature: Deployment
16
16
  |production |
17
17
  When I deploy
18
18
  Then a "production" tag should be added to git
19
+ But I should not see "no branch available"
19
20
 
20
21
  @0.1.5
21
22
  Scenario: user deploys with single file deploy.rb stages with dashes in the name
@@ -31,3 +32,10 @@ Feature: Deployment
31
32
  And a ci tag
32
33
  When I deploy to staging
33
34
  Then a tag should be added to git
35
+
36
+ @0.1.5
37
+ Scenario: user sees latest tags
38
+ Given a three-stage app using cap-multistage
39
+ And a ci tag
40
+ When I deploy to staging
41
+ Then I should see "release tag history is:"
@@ -25,10 +25,6 @@ When /^I run autotag with "([^\"]*)"$/ do |args|
25
25
  end
26
26
  end
27
27
 
28
- Then /^I should see "([^\"]*)"$/ do |text|
29
- @output.should =~ /#{Regexp.escape(text)}/
30
- end
31
-
32
28
  Then /^the exit code should be "(\d+)"$/ do |code|
33
29
  @exit_code.exitstatus.should == code.to_i
34
30
  end
@@ -9,7 +9,7 @@ end
9
9
  Given /^a one\-stage app using single deploy file with the following environments:$/ do |table|
10
10
  with_or_without_debugging do
11
11
  helpers = StepHelpers.new
12
- helpers.create_app_with_single_deploy_file table.raw.map(&:first)
12
+ helpers.create_app_with_single_deploy_file table.raw.map{|item| item.first}
13
13
  @refs = helpers.refs
14
14
  end
15
15
  end
@@ -41,14 +41,14 @@ end
41
41
  When /^I deploy to (.*)$/ do |environment|
42
42
  with_or_without_debugging do
43
43
  helpers = StepHelpers.new
44
- helpers.deploy(environment)
44
+ @output = helpers.deploy(environment)
45
45
  end
46
46
  end
47
47
 
48
48
  When /^I deploy$/ do
49
49
  with_or_without_debugging do
50
50
  helpers = StepHelpers.new
51
- helpers.deploy
51
+ @output = helpers.deploy
52
52
  end
53
53
  end
54
54
 
@@ -0,0 +1,8 @@
1
+ Then /^I should see "([^\"]*)"$/ do |text|
2
+ @output.should =~ /#{Regexp.escape(text)}/
3
+ end
4
+
5
+ Then /^I should not see "([^\"]*)"$/ do |text|
6
+ @output.should_not =~ /#{Regexp.escape(text)}/
7
+ end
8
+
@@ -155,7 +155,9 @@ class StepHelpers
155
155
  end
156
156
 
157
157
  def run_commands(commands)
158
- puts `#{commands.join(" && ")}`
158
+ output = `#{commands.join(" && ")} 2>&1`
159
+ puts output
160
+ output
159
161
  end
160
162
 
161
163
  end
@@ -32,11 +32,12 @@ module AutoTagger
32
32
  def stages
33
33
  stages = settings[:stages] || []
34
34
  stages = stages.to_s.split(",").map { |stage| stage.strip } if stages.is_a?(String)
35
- stages.reject { |stage| stage.to_s == "" }
35
+ stages.reject { |stage| stage.to_s == "" }.map {|stage| stage.to_s }
36
36
  end
37
37
 
38
38
  def stage
39
- settings[:stage] || stages.last
39
+ stage = settings[:stage] || stages.last
40
+ stage.nil? ? nil : stage.to_s
40
41
  end
41
42
 
42
43
  def date_separator
@@ -13,6 +13,12 @@ module AutoTagger
13
13
  end
14
14
  end
15
15
 
16
+ def find_by_sha(sha)
17
+ all.detect do |ref|
18
+ ref.sha == sha
19
+ end
20
+ end
21
+
16
22
  # name = refs/autotags/2009857463
17
23
  # returns a ref
18
24
  # should un-cache the refs in refset, or never memoize
@@ -58,10 +58,18 @@ module AutoTagger
58
58
  when "version"
59
59
  options[:show_version] = true
60
60
  options[:command] = :version
61
- when * ["help", ""]
61
+ when "help"
62
62
  options[:show_help] = true
63
63
  options[:help_text] = args.options.help
64
64
  options[:command] = :help
65
+ when ""
66
+ if options[:show_version]
67
+ options[:command] = :version
68
+ else
69
+ options[:show_help] = true
70
+ options[:help_text] = args.options.help
71
+ options[:command] = :help
72
+ end
65
73
  when "cleanup"
66
74
  options[:command] = :cleanup
67
75
  options[:stage] = args[1]
@@ -44,7 +44,7 @@ Capistrano::Configuration.instance(:must_exist).load do
44
44
  desc %Q{DEPRECATED: Prints the most current tags from all stages}
45
45
  task :print_latest_refs, :roles => :app do
46
46
  log_auto_tagger "release tag history is:"
47
- auto_tagger.release_tag_entries.each { |entry| logger.info entry }
47
+ auto_tagger.release_tag_entries.each { |entry| logger.info(entry.to_s) }
48
48
  end
49
49
 
50
50
  desc %Q{DEPRECATED: Reads the text file with the latest tag from the shared directory}
@@ -55,9 +55,17 @@ Capistrano::Configuration.instance(:must_exist).load do
55
55
 
56
56
  desc %Q{DEPRECATED: Writes the tag name to a file in the shared directory}
57
57
  task :write_ref_to_shared, :roles => :app do
58
- if exists?(:branch)
58
+ ref_name = if exists?(:branch)
59
+ branch
60
+ elsif ref = auto_tagger.repo.refs.find_by_sha(real_revision)
61
+ ref.name
62
+ else
63
+ nil
64
+ end
65
+
66
+ if ref_name
59
67
  log_auto_tagger "writing tag to shared text file on remote server"
60
- run "echo '#{branch}' > #{shared_path}/released_git_tag.txt"
68
+ run "echo '#{ref_name}' > #{shared_path}/released_git_tag.txt"
61
69
  else
62
70
  log_auto_tagger "no branch available. Text file was not written to server"
63
71
  end
@@ -75,9 +83,9 @@ Capistrano::Configuration.instance(:must_exist).load do
75
83
  auto_tagger.create_ref
76
84
  end
77
85
 
78
- desc %Q{DEPRECATED: use auto_tagger:print_latest_tags}
79
- task :print_latest_refs, :roles => :app do
80
- auto_tagger.print_latest_tags
86
+ desc %Q{DEPRECATED: use auto_tagger:print_latest_refs}
87
+ task :print_latest_tags, :roles => :app do
88
+ auto_tagger.print_latest_refs
81
89
  end
82
90
 
83
91
  desc %Q{DEPRECATED: use auto_tagger:read_ref_from_shared}
@@ -91,6 +91,11 @@ describe AutoTagger::Configuration do
91
91
  config = AutoTagger::Configuration.new :stages => ["ci", ""]
92
92
  config.stages.should == ["ci"]
93
93
  end
94
+
95
+ it "turns stages into strings" do
96
+ config = AutoTagger::Configuration.new :stages => [:ci, :production]
97
+ config.stages.should == ["ci", "production"]
98
+ end
94
99
  end
95
100
 
96
101
  describe "#stage" do
@@ -108,6 +113,11 @@ describe AutoTagger::Configuration do
108
113
  config = AutoTagger::Configuration.new
109
114
  config.stage.should be_nil
110
115
  end
116
+
117
+ it "stringifies the passed in stage" do
118
+ config = AutoTagger::Configuration.new :stage => :demo
119
+ config.stage.should == "demo"
120
+ end
111
121
  end
112
122
 
113
123
  describe "#date_separator" do
@@ -7,7 +7,7 @@ describe AutoTagger::Git::RefSet do
7
7
  @ref_set = AutoTagger::Git::RefSet.new(@repo)
8
8
  @refstring = <<-LIST
9
9
  23087241c495773c8eece1c195cc453a8055c4eb refs/tags/200808080808
10
- 23087241c495773c8eece1c195cc453a8055c4eb refs/tags/200808080809
10
+ 23087241c495773b8eecr1c195cd453a8056c4eb refs/tags/200808080809
11
11
  LIST
12
12
  end
13
13
 
@@ -21,6 +21,19 @@ describe AutoTagger::Git::RefSet do
21
21
  end
22
22
  end
23
23
 
24
+ describe "#find_by_sha" do
25
+ it "returns a ref by the sha" do
26
+ @repo.should_receive(:read).with("show-ref").and_return(@refstring)
27
+ ref = @ref_set.find_by_sha("23087241c495773b8eecr1c195cd453a8056c4eb")
28
+ ref.name.should == "refs/tags/200808080809"
29
+ end
30
+
31
+ it "returns nil if it's not found" do
32
+ @repo.should_receive(:read).with("show-ref").and_return(@refstring)
33
+ @ref_set.find_by_sha("abc123").should be_nil
34
+ end
35
+ end
36
+
24
37
  describe "#create" do
25
38
  it "instantiates and saves a ref" do
26
39
  @repo.should_receive(:exec).with("update-ref refs/auto_tags/demo/2008 abc123")
@@ -124,6 +124,9 @@ describe AutoTagger::Options do
124
124
  options = AutoTagger::Options.from_command_line ["version"]
125
125
  options[:command].should == :version
126
126
 
127
+ options = AutoTagger::Options.from_command_line ["-v"]
128
+ options[:command].should == :version
129
+
127
130
  options = AutoTagger::Options.from_command_line ["help"]
128
131
  options[:command].should == :help
129
132
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auto_tagger
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jeff Dean
@@ -22,7 +22,7 @@ autorequire:
22
22
  bindir: bin
23
23
  cert_chain: []
24
24
 
25
- date: 2010-09-10 00:00:00 -04:00
25
+ date: 2010-09-16 00:00:00 -04:00
26
26
  default_executable: autotag
27
27
  dependencies:
28
28
  - !ruby/object:Gem::Dependency
@@ -65,6 +65,7 @@ files:
65
65
  - features/deployment.feature
66
66
  - features/step_definitions/autotag_steps.rb
67
67
  - features/step_definitions/deployment_steps.rb
68
+ - features/step_definitions/shared_steps.rb
68
69
  - features/support/env.rb
69
70
  - features/support/step_helpers.rb
70
71
  - features/templates/cap_ext_deploy.erb