stove 2.0.0 → 3.0.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.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +6 -1
  4. data/CHANGELOG.md +20 -0
  5. data/README.md +34 -80
  6. data/Rakefile +9 -1
  7. data/bin/bake +2 -0
  8. data/bin/stove +4 -0
  9. data/features/plugins/community.feature +11 -26
  10. data/features/plugins/git.feature +17 -6
  11. data/features/step_definitions/community_steps.rb +3 -1
  12. data/features/step_definitions/config_steps.rb +4 -21
  13. data/features/step_definitions/git_steps.rb +38 -1
  14. data/features/support/env.rb +17 -11
  15. data/features/support/stove/git.rb +28 -8
  16. data/lib/stove/cli.rb +72 -53
  17. data/lib/stove/community.rb +16 -67
  18. data/lib/stove/config.rb +55 -46
  19. data/lib/stove/cookbook/metadata.rb +3 -5
  20. data/lib/stove/cookbook.rb +2 -41
  21. data/lib/stove/error.rb +37 -8
  22. data/lib/stove/filter.rb +2 -1
  23. data/lib/stove/mixins/instanceable.rb +3 -2
  24. data/lib/stove/mixins/validatable.rb +5 -1
  25. data/lib/stove/packager.rb +11 -3
  26. data/lib/stove/plugins/base.rb +26 -13
  27. data/lib/stove/plugins/community.rb +3 -7
  28. data/lib/stove/plugins/git.rb +27 -30
  29. data/lib/stove/rake_task.rb +3 -63
  30. data/lib/stove/runner.rb +16 -65
  31. data/lib/stove/validator.rb +7 -6
  32. data/lib/stove/version.rb +1 -1
  33. data/lib/stove.rb +3 -21
  34. data/spec/spec_helper.rb +2 -0
  35. data/spec/unit/error_spec.rb +148 -0
  36. data/stove.gemspec +10 -14
  37. data/templates/errors/abstract_method.erb +5 -0
  38. data/templates/errors/community_category_validation_failed.erb +5 -0
  39. data/templates/errors/community_key_validation_failed.erb +3 -0
  40. data/templates/errors/community_username_validation_failed.erb +3 -0
  41. data/templates/errors/git_clean_validation_failed.erb +1 -0
  42. data/templates/errors/git_failed.erb +5 -0
  43. data/templates/errors/git_repository_validation_failed.erb +3 -0
  44. data/templates/errors/git_up_to_date_validation_failed.erb +7 -0
  45. data/templates/errors/metadata_not_found.erb +1 -0
  46. data/templates/errors/server_unavailable.erb +1 -0
  47. data/templates/errors/stove_error.erb +1 -0
  48. metadata +32 -114
  49. data/features/actions/bump.feature +0 -22
  50. data/features/actions/changelog.feature +0 -52
  51. data/features/actions/dev.feature +0 -18
  52. data/features/actions/upload.feature +0 -26
  53. data/features/rake.feature +0 -15
  54. data/features/step_definitions/cli_steps.rb +0 -3
  55. data/lib/stove/actions/base.rb +0 -21
  56. data/lib/stove/actions/bump.rb +0 -25
  57. data/lib/stove/actions/changelog.rb +0 -71
  58. data/lib/stove/actions/dev.rb +0 -22
  59. data/lib/stove/actions/finish.rb +0 -8
  60. data/lib/stove/actions/start.rb +0 -7
  61. data/lib/stove/actions/upload.rb +0 -11
  62. data/lib/stove/jira.rb +0 -88
  63. data/lib/stove/middlewares/chef_authentication.rb +0 -60
  64. data/lib/stove/middlewares/exceptions.rb +0 -17
  65. data/lib/stove/mixins/filterable.rb +0 -11
  66. data/lib/stove/plugins/github.rb +0 -107
  67. data/lib/stove/plugins/jira.rb +0 -72
  68. data/locales/en.yml +0 -230
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 41d8bc6c0ecbe6769abf2fbaeb7c79101eb7dc1b
4
- data.tar.gz: 5ca0ecb5f7ba581eeb4e9fbff9677e3fc19b449a
3
+ metadata.gz: b2054d6ff1813a9e732d90f9758cee5f45b39a5b
4
+ data.tar.gz: 680226a4dd39d13ceac6e78d8811e69206f7f3b4
5
5
  SHA512:
6
- metadata.gz: f9fd20c6488ceebac425c6f6e326209edc1e834af8d05a750a42ac42bb4788f77855c00936a745e4f1857aa8f747058078e8ea79a78a4313e7d2a722af0f0dc9
7
- data.tar.gz: 074a33d4bebce2fb0528a0f498e4b0da2bf785fabac835ab739b0b0d440210146be57a29c93ca9117a70cc5fcb0d0e24cb481faf863763ad67fb310a9ed0f1e0
6
+ metadata.gz: 3ea199748cab9c2d639c4c12acee0bf5e36334cfe7fcc77850ff60fed204798061901f0ec9fb70cbbeaaaf4d8d701da62b4a3e7ba29328a85d37e943370d0b67
7
+ data.tar.gz: 42e80c8bae4b0166a71c5709bb9ebd4c1411de9fe58fcd09dc5600cdf65615c82607c76aa78b4cc710a4df949ded7dfe6b86bd9711360de3ef16ea6199462be2
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ .rspec
data/.travis.yml CHANGED
@@ -1,7 +1,12 @@
1
1
  rvm:
2
2
  - 1.9.3
3
3
  - 2.0.0
4
- - 2.1.0
4
+ - 2.1
5
+
6
+ bundler_args: --jobs 7
7
+
5
8
  before_script:
6
9
  - git config --global user.email "ci@traivs-ci.org"
7
10
  - git config --global user.name "Travis CI"
11
+
12
+ script: bundle exec rake
data/CHANGELOG.md CHANGED
@@ -2,6 +2,26 @@ Stove CHANGELOG
2
2
  ===============
3
3
  This is the Changelog for the Stove gem.
4
4
 
5
+ v3.0.0 (2014-07-07)
6
+ -------------------
7
+ - Add support for signed git tags
8
+ - Require Ruby 1.9+
9
+ - Remove i18n in favor of ERB
10
+ - Remove solve gem
11
+ - Remove GitHub functionality
12
+ - Remove JIRA functionality
13
+ - Remove bump and devodd functionality
14
+ - Clear up confusion on Gemfile vs not Gemfile
15
+ - Always read tarball objects as binary
16
+ - End tempfiles in the correct extension (needed to detect mime_types)
17
+ - Bump required version of ChefAPI gem
18
+ - Remove unused errors and code
19
+ - Improved documentation
20
+ - Remove editor files (`.swp`, etc) before packaging
21
+ - Upgrade to RSpec 3
22
+ - Improve test coverage
23
+ - Publish to Supermarket by default
24
+
5
25
  v2.0.0 (2014-04-04)
6
26
  -------------------
7
27
  - Completely refactor the runner for speed optimizations
data/README.md CHANGED
@@ -14,111 +14,68 @@ Stove
14
14
 
15
15
  A utility for releasing and managing Chef Cookbooks. It will:
16
16
 
17
- - Edit the `metadata.rb` and insert the proper version
18
- - Create a CHANGELOG from JIRA tickets
19
- - Commit and push these changes to git
20
- - Create a git tag and push those changes to git
21
- - Publish a release to GitHub releases
22
- - Upload the cookbook to the Opscode Community Site
23
- - Resolve (close) the JIRA tickets
17
+ - Tag and push a new release to git
18
+ - Upload the cookbook to a cookbook share (such as Supermarket)
24
19
 
25
20
 
26
21
  Why?
27
22
  ----
28
- Existing tools to package cookbooks (such as [Knife Community](https://github.com/miketheman/knife-community) and `knife cookbook site share`) require a dependency on Chef. Because of thier dependency on Chef, they enforce the use of a "cookbook repo". Especially with the evolution of [Berkshelf](https://github.com/RiotGames/berkshelf), cookbooks are individualized artifacts and are often contained in their own repositories. [stove](https://github.com/sethvargo/stove) is **cookbook-centric, rather than Chef-centric**. Since all commands are run from inside the cookbook, it's safe to include stove in your cookbooks `Gemfile`.
23
+ Existing tools to package cookbooks (such as [Knife Community](https://github.com/miketheman/knife-community) and `knife cookbook site share`) require a dependency on Chef. Because of thier dependency on Chef, they enforce the use of a "cookbook repo". Especially with the evolution of [Berkshelf](https://github.com/RiotGames/berkshelf), cookbooks are individualized artifacts and are often contained in their own repositories. [stove](https://github.com/sethvargo/stove) is **cookbook-centric, rather than Chef-centric**.
29
24
 
30
25
 
31
26
  Installation
32
27
  ------------
33
- It is highly recommended that you include `stove` in your cookbook's Gemfile:
28
+ 1. Add Stove to your project's Gemfile:
34
29
 
35
- ```ruby
36
- gem 'stove'
37
- ```
30
+ gem 'stove'
38
31
 
39
- Alternatively, you may install it as a gem:
32
+ 2. Run the `bundle` command to install:
40
33
 
41
- $ gem install stove
34
+ $ bundle install --binstubs
42
35
 
43
- The use of some plugins (such as GitHub and JIRA) require a Stove configuration file. The Stove config is a JSON file stored at `~/.stove` on your local hard drive. The schema looks like this:
44
36
 
45
- ```javascript
46
- {
47
- "field": {
48
- "option": "value"
49
- }
50
- }
51
- ```
37
+ Configuration
38
+ -------------
39
+ Stove requires your username and private key to upload a cookbook. You can pass these to each command call, or you can set them Stove:
52
40
 
53
- For example, my local Stove configuration looks like this:
54
-
55
- ```javascript
56
- {
57
- "community": {
58
- "username": "sethvargo",
59
- "key": "~/.chef/sethvargo.pem"
60
- },
61
- "github": {
62
- "access_token": "..."
63
- },
64
- "jira": {
65
- "username": "sethvargo",
66
- "password": "..."
67
- }
68
- }
41
+ ```bash
42
+ $ stove login --username sethvargo --key ~/.chef/sethvargo.pem
69
43
  ```
70
44
 
71
- If you are using Stove 1.0, you need to update your configuration file syntax.
45
+ These values will be saved in Stove's configuration file and persisted across your workstation.
72
46
 
73
- **It is recommended that the permissions on this file be 0600 to prevent unauthorized reading!**
47
+ The default publishing endpoint is the [Chef Supermarket](https://supermarket.getchef.com), but this is configurable. If you want to publish to an internal community site, you can specify the `--endpoint` value:
48
+
49
+ ```bash
50
+ $ stove --endpoint https://internal-cookbook-store.example.com
51
+ ```
74
52
 
75
53
 
76
54
  Usage
77
55
  -----
78
- The gem is packaged as a binary. It should be run from _inside the cookbook to release_:
56
+ There are two ways to use Stove. You can either use the `stove` command directly or use the embedded rake task.
79
57
 
80
- (~/cookbooks/bacon) $ bake 1.2.3
58
+ ### Command
59
+ Execute the `stove` command from inside the root of a cookbook:
81
60
 
82
- You can always use the `--help` flag to get information:
83
-
84
- ```text
85
- Usage: bake x.y.z
86
-
87
- Actions:
88
- --[no-]bump [Don't] Perform a version bump the local version automatically
89
- --[no-]changelog [Don't] Generate and prompt for a CHANGELOG
90
- --[no-]dev [Don't] Bump a minor version release for development purposes
91
- --[no-]upload [Don't] Execute upload stages of enabled plugins
92
-
93
- Plugins:
94
- --[no-]community [Don't] Upload to the community site
95
- --[no-]git [Don't] Tag and push to a git remote
96
- --[no-]github [Don't] Publish the release to GitHub
97
- --[no-]jira [Don't] Resolve JIRA issues
98
-
99
- Global Options:
100
- --locale [LANGUAGE] Change the language to output messages
101
- --log-level [LEVEL] Set the log verbosity
102
- --category [CATEGORY] Set category for the cookbook
103
- --path [PATH] Change the path to a cookbook
104
- --remote [REMOTE] The name of the git remote to push to
105
- --branch [BRANCH] The name of the git branch to push to
106
- -h, --help Show this message
107
- -v, --version Show version
61
+ ```bash
62
+ $ bin/stove
108
63
  ```
109
64
 
65
+ This will package (as a tarball) the cookbook in the current working directory, tag a new version, push to git, and publish to a cookbook share.
110
66
 
111
- Rake Task
112
- ---------
113
- Stove also includes a Rake task you can include in your Rakefile:
67
+ ### Rake task
68
+ If you are familiar with the Bundler approach to publishing Ruby gems, this approach will feel very familiar. Simply add the following to your `Rakefile`:
114
69
 
115
70
  ```ruby
116
71
  require 'stove/rake_task'
72
+ Stove::RakeTask.new
73
+ ```
117
74
 
118
- Stove::RakeTask.new do |stove|
119
- stove.git = true
120
- stove.devodd = true
121
- end
75
+ And then use rake to publish the cookbook:
76
+
77
+ ```bash
78
+ $ bin/rake publish
122
79
  ```
123
80
 
124
81
 
@@ -130,9 +87,6 @@ Contributing
130
87
  4. Push to the branch (`git push origin my-new-feature`)
131
88
  5. Create new Pull Request
132
89
 
133
- TODO:
134
- - Secure the authentication file
135
-
136
90
 
137
91
  See Also
138
92
  --------
@@ -145,8 +99,8 @@ License & Authors
145
99
  - Author: Seth Vargo (sethvargo@gmail.com)
146
100
 
147
101
  ```text
148
- Copyright 2013 Seth Vargo <sethvargo@gmail.com>
149
- Copyright 2013 Opscode, Inc
102
+ Copyright 2013-2014 Seth Vargo <sethvargo@gmail.com>
103
+ Copyright 2013-2014 Chef Software, Inc
150
104
 
151
105
  Licensed under the Apache License, Version 2.0 (the "License");
152
106
  you may not use this file except in compliance with the License.
data/Rakefile CHANGED
@@ -1,5 +1,13 @@
1
1
  require 'bundler/gem_tasks'
2
2
 
3
+ require 'rspec/core/rake_task'
4
+ RSpec::Core::RakeTask.new(:unit) do |t|
5
+ t.rspec_opts = [].tap do |a|
6
+ a.push('--color')
7
+ a.push('--format progress')
8
+ end.join(' ')
9
+ end
10
+
3
11
  require 'cucumber/rake/task'
4
12
  Cucumber::Rake::Task.new(:acceptance) do |t|
5
13
  t.cucumber_opts = [].tap do |a|
@@ -11,6 +19,6 @@ Cucumber::Rake::Task.new(:acceptance) do |t|
11
19
  end
12
20
 
13
21
  desc 'Run all tests'
14
- task :test => [:acceptance]
22
+ task :test => [:unit, :acceptance]
15
23
 
16
24
  task :default => [:test]
data/bin/bake CHANGED
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ $stderr.puts "The `bake' command is deprecated. Please use `stove' instead!"
4
+
3
5
  require 'stove'
4
6
  Stove::Cli.new(ARGV.dup).execute!
data/bin/stove ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'stove'
4
+ Stove::Cli.new(ARGV.dup).execute!
@@ -1,40 +1,25 @@
1
1
  Feature: Community
2
2
  Background:
3
- * the Stove config is empty
4
- * the CLI options are all off
5
3
  * I have a cookbook named "bacon"
6
4
  * I am using the community server
7
5
 
8
- Scenario: When the configuration does not exist
9
- * I run `bake --upload --community`
10
- * it should fail with "configuration for the Chef community site does not exist"
11
-
12
6
  Scenario: When the username does not exist
13
- * the Stove config at "community._" is ""
14
- * I run `bake --upload --community`
15
- * it should fail with "does not contain a username"
7
+ * the Stove config at "username" is unset
8
+ * I run `stove --no-git`
9
+ * it should fail with "requires a username"
16
10
 
17
11
  Scenario: When the key does not exist
18
- * the Stove config at "community.username" is "bobo"
19
- * I run `bake --upload --community`
20
- * it should fail with "does not contain a key"
12
+ * the Stove config at "key" is unset
13
+ * I run `stove --no-git`
14
+ * it should fail with "requires a private key"
21
15
 
22
16
  Scenario: When the category does not exist
23
- * the Stove config at "community.username" is "bobo"
24
- * the Stove config at "community.key" is "../../features/support/stove.pem"
25
- * I run `bake --upload --community`
17
+ * I run `stove --no-git`
26
18
  * it should fail with "You did not specify a category"
27
19
 
28
- Scenario: In isolation
29
- * the Stove config at "community.username" is "bobo"
30
- * the Stove config at "community.key" is "../../features/support/stove.pem"
20
+ Scenario: With the default parameters
31
21
  * the community server has the cookbook:
32
22
  | bacon | 1.2.3 | Application |
33
- * I successfully run `bake --upload --community`
34
-
35
- Scenario: When the community plugin is explicitly disabled
36
- * the Stove config at "community.username" is "bobo"
37
- * the Stove config at "community.key" is "../../features/support/stove.pem"
38
- * I successfully run `bake --upload --no-community`
39
- * the community server will not have the cookbook:
40
- | bacon | | |
23
+ * I successfully run `stove --no-git`
24
+ * the community server will have the cookbooks:
25
+ | bacon | 0.0.0 | Application |
@@ -1,11 +1,11 @@
1
1
  Feature: git Plugin
2
2
  Background:
3
- * the Stove config is empty
4
- * the CLI options are all off
5
3
  * I have a cookbook named "bacon"
4
+ * the community server has the cookbooks:
5
+ | bacon | 1.0.0 | Application |
6
6
 
7
7
  Scenario: When the directory is not a git repository
8
- * I run `bake --git`
8
+ * I run `stove`
9
9
  * it should fail with "does not appear to be a valid git repository"
10
10
 
11
11
  Scenario: When the directory is dirty
@@ -14,16 +14,27 @@ Feature: git Plugin
14
14
  """
15
15
  This is new content
16
16
  """
17
- * I run `bake --git`
17
+ * I run `stove`
18
18
  * it should fail with "has untracked files"
19
19
 
20
20
  Scenario: When the local is out of date with the remote
21
21
  * I have a cookbook named "bacon" with git support
22
22
  * the remote repository has additional commits
23
- * I run `bake --git`
23
+ * I run `stove -l debug`
24
24
  * it should fail with "out of sync with the remote repository"
25
25
 
26
26
  Scenario: When a git upload should be done
27
27
  * I have a cookbook named "bacon" with git support
28
- * I successfully run `bake --upload --git`
28
+ * I successfully run `stove`
29
29
  * the git remote should have the tag "v0.0.0"
30
+
31
+ Scenario: When using signed tags
32
+ * I have a cookbook named "bacon" with git support
33
+ * a GPG key exists
34
+ * I successfully run `stove --sign`
35
+ * the git remote should have the signed tag "v0.0.0"
36
+
37
+ Scenario: With the git plugin disabled
38
+ * I have a cookbook named "bacon" with git support
39
+ * I successfully run `stove --no-git`
40
+ * the git remote should not have the tag "v0.0.0"
@@ -1,5 +1,7 @@
1
1
  Given /^I am using the community server$/ do
2
- set_env('COMMUNITY_URL', CommunityZero::RSpec.url)
2
+ set_env('STOVE_ENDPOINT', CommunityZero::RSpec.url)
3
+ set_env('STOVE_CLIENT', 'stove')
4
+ set_env('STOVE_KEY', File.expand_path('../../support/stove.pem', __FILE__))
3
5
  end
4
6
 
5
7
  Given /^the community server has the cookbooks?:$/ do |table|
@@ -1,24 +1,7 @@
1
- Given /^the Stove config is empty$/ do
2
- path = File.join(tmp_path, '_config.rb')
3
-
4
- write_file(path, '{}')
5
- set_env('STOVE_CONFIG', path)
1
+ Given /^the Stove config at "(.+)" is "(.+)"/ do |variable, value|
2
+ Stove::Config.__set__(variable, value)
6
3
  end
7
4
 
8
- Given /^the Stove config at "(.+)" is "(.*)"$/ do |path, value|
9
- parts = path.split('.').map(&:to_sym)
10
- parents = parts[0...-1]
11
-
12
- path = ENV['STOVE_CONFIG']
13
- config = JSON.parse(File.read(path), symbolize_names: true)
14
-
15
- # Vivify the hash
16
- parent = parents.inject(config) do |config, parent|
17
- config[parent] ||= {}
18
- config[parent]
19
- end
20
-
21
- parent[parts.last] = value
22
-
23
- File.open(path, 'w') { |f| f.write(JSON.generate(config)) }
5
+ Given /^the Stove config at "(.+)" is unset/ do |variable|
6
+ Stove::Config.__unset__(variable)
24
7
  end
@@ -9,6 +9,42 @@ Given /^the remote repository has additional commits/ do
9
9
  %x|#{cmd}|
10
10
  end
11
11
 
12
+ Given /^a GPG key exists/ do
13
+ gpg_home = File.join(scratch_dir, '.gnupg')
14
+ set_env('GNUPGHOME', gpg_home)
15
+ Dir.mkdir(gpg_home)
16
+ File.chmod(0700, gpg_home)
17
+ batch_path = File.join(gpg_home, 'batch')
18
+ File.write(batch_path, <<-EOH)
19
+ %pubring #{File.join(gpg_home, 'keyring')}
20
+ %secring #{File.join(gpg_home, 'keyring.sec')}
21
+ Key-Type: DSA
22
+ Key-Length: 832
23
+ Subkey-Type: ELG-E
24
+ Subkey-Length: 800
25
+ Name-Real: Alan Smithee
26
+ Name-Email: asmithee@example.com
27
+ Expire-Date: 0
28
+ %commit
29
+ EOH
30
+ gpg_wrapper = File.join(gpg_home, 'gpg_wrapper')
31
+ File.write(gpg_wrapper, <<-EOH)
32
+ #!/bin/sh
33
+ gpg "--keyring=#{File.join(gpg_home, 'keyring')}" "--secret-keyring=#{File.join(gpg_home, 'keyring.sec')}" "$@"
34
+ EOH
35
+ File.chmod(0755, gpg_wrapper)
36
+
37
+ cmd = [
38
+ "cd \"#{current_dir}\"",
39
+ "git config gpg.program #{gpg_wrapper}",
40
+ 'git config user.signingkey asmithee@example.com',
41
+ "gpg --quiet --batch --gen-key #{batch_path}",
42
+ ].join(' && ')
43
+
44
+ %x|#{cmd}|
45
+ end
46
+
47
+
12
48
  Then /^the git remote should( not)? have the commit "(.+)"$/ do |negate, message|
13
49
  commits = git_commits(fake_git_remote)
14
50
 
@@ -19,12 +55,13 @@ Then /^the git remote should( not)? have the commit "(.+)"$/ do |negate, message
19
55
  end
20
56
  end
21
57
 
22
- Then /^the git remote should( not)? have the tag "(.+)"$/ do |negate, tag|
58
+ Then /^the git remote should( not)? have the( signed)? tag "(.+)"$/ do |negate, signed, tag|
23
59
  tags = git_tags(fake_git_remote)
24
60
 
25
61
  if negate
26
62
  expect(tags).to_not include(tag)
27
63
  else
28
64
  expect(tags).to include(tag)
65
+ expect(git_tag_signature?(fake_git_remote, tag)).to be_truthy if signed
29
66
  end
30
67
  end
@@ -1,27 +1,33 @@
1
- require 'bundler/setup'
1
+ require 'stove'
2
2
 
3
- require 'aruba/api'
3
+ require 'aruba'
4
4
  require 'aruba/cucumber'
5
- require 'cucumber/rspec/doubles'
6
- require 'rspec/expectations'
5
+ require 'aruba/in_process'
6
+
7
+ Aruba::InProcess.main_class = Stove::Cli
8
+ Aruba.process = Aruba::InProcess
7
9
 
8
10
  require 'community_zero/rspec'
9
11
  CommunityZero::RSpec.start
10
12
  Before { CommunityZero::RSpec.reset! }
11
13
 
12
- require 'stove'
13
-
14
14
  require File.expand_path('../stove/git', __FILE__)
15
15
 
16
16
  World(Aruba::Api)
17
17
  World(Stove::Git)
18
18
 
19
19
  Before do
20
- FileUtils.rm_rf(tmp_path)
21
- @aruba_timeout_seconds = 15
20
+ Stove::Config.endpoint = CommunityZero::RSpec.url
21
+ Stove::Config.username = 'stove'
22
+ Stove::Config.key = File.expand_path('../stove.pem', __FILE__)
23
+ end
24
+
25
+ Before do
26
+ FileUtils.rm_rf(scratch_dir)
27
+ FileUtils.mkdir_p(scratch_dir)
22
28
  end
23
29
 
24
- # The path to Aruba's "stuff"
25
- def tmp_path
26
- File.expand_path(@dirs.first.to_s)
30
+ # The scratch directory
31
+ def scratch_dir
32
+ @scratch_dir ||= File.expand_path('tmp/aruba/scratch')
27
33
  end
@@ -4,7 +4,6 @@ module Stove
4
4
  module Git
5
5
  def git_init(path = Dir.pwd)
6
6
  cmd = [
7
- 'cd "' + path + '"',
8
7
  'git init .',
9
8
  'git add --all',
10
9
  'git commit --message "Initial commit"',
@@ -12,37 +11,58 @@ module Stove
12
11
  'git push --quiet --force origin master',
13
12
  ].join(' && ')
14
13
 
15
- %x|#{cmd}|
14
+ Dir.chdir(path) do
15
+ %x|#{cmd}|
16
+ end
16
17
  end
17
18
 
18
19
  def fake_git_remote
19
- path = File.expand_path(File.join(tmp_path, 'remote.git'))
20
+ path = File.expand_path(File.join(remotes_path, 'remote.git'))
20
21
  return path if File.exists?(path)
21
22
 
22
23
  FileUtils.mkdir_p(path)
23
24
  cmd = [
24
- 'cd "' + path + '"',
25
25
  'git init .',
26
26
  'git config receive.denyCurrentBranch ignore',
27
27
  'git config receive.denyNonFastforwards true',
28
28
  'git config core.sharedrepository 1',
29
29
  ].join(' && ')
30
30
 
31
- %x|#{cmd}|
31
+ Dir.chdir(path) do
32
+ %x|#{cmd}|
33
+ end
32
34
 
33
35
  path
34
36
  end
35
37
 
36
38
  def git_shas(path)
37
- %x|cd "#{path}" && git log --oneline|.split("\n").map { |line| line.split(/\s+/, 2).first.strip } rescue []
39
+ Dir.chdir(path) do
40
+ %x|git log --oneline|.split("\n").map { |line| line.split(/\s+/, 2).first.strip } rescue []
41
+ end
38
42
  end
39
43
 
40
44
  def git_commits(path)
41
- %x|cd "#{path}" && git log --oneline|.split("\n").map { |line| line.split(/\s+/, 2).last.strip } rescue []
45
+ Dir.chdir(path) do
46
+ %x|git log --oneline|.split("\n").map { |line| line.split(/\s+/, 2).last.strip } rescue []
47
+ end
42
48
  end
43
49
 
44
50
  def git_tags(path)
45
- %x|cd "#{path}" && git tag --list|.split("\n").map(&:strip) rescue []
51
+ Dir.chdir(path) do
52
+ %x|git tag --list|.split("\n").map(&:strip) rescue []
53
+ end
54
+ end
55
+
56
+ def git_tag_signature?(path, tag)
57
+ Dir.chdir(path) do
58
+ %x|git show --show-signature #{tag}|.include?('BEGIN PGP SIGNATURE') rescue false
59
+ end
60
+ end
61
+
62
+ private
63
+
64
+ def remotes_path
65
+ @remotes_path ||= File.join(scratch_dir, 'remotes')
46
66
  end
47
67
  end
48
68
  end