metasploit-version 0.1.2-java → 0.1.3-java
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/.rspec +2 -0
- data/.travis.yml +10 -3
- data/CHANGELOG.md +6 -0
- data/CONTRIBUTING.md +10 -44
- data/Gemfile +12 -8
- data/RELEASING.md +86 -0
- data/Rakefile +5 -4
- data/UPGRADING.md +1 -0
- data/app/templates/.rspec.tt +2 -0
- data/app/templates/CHANGELOG.md.tt +18 -0
- data/app/templates/CONTRIBUTING.md.tt +122 -0
- data/app/templates/RELEASING.md.tt +99 -0
- data/app/templates/Rakefile.tt +7 -0
- data/app/templates/UPGRADING.md.tt +1 -0
- data/app/templates/lib/versioned/version.rb.tt +64 -0
- data/app/templates/spec/lib/versioned/version_spec.rb.tt +3 -0
- data/app/templates/spec/lib/versioned_spec.rb.tt +4 -0
- data/app/templates/spec/spec_helper.rb.tt +76 -0
- data/bin/metasploit-version +12 -0
- data/config/cucumber.yml +3 -0
- data/features/metasploit-version/install/add_development_dependency.feature +68 -0
- data/features/metasploit-version/install/bundle_install.feature +24 -0
- data/features/metasploit-version/install/changelog.feature +29 -0
- data/features/metasploit-version/install/conflict.feature +45 -0
- data/features/metasploit-version/install/contributing.feature +139 -0
- data/features/metasploit-version/install/namespace_spec/gem_version_constant.feature +154 -0
- data/features/metasploit-version/install/namespace_spec/namespace.feature +33 -0
- data/features/metasploit-version/install/namespace_spec/version_constant.feature +179 -0
- data/features/metasploit-version/install/rake_spec.feature +27 -0
- data/features/metasploit-version/install/releasing/ruby_versions.feature +50 -0
- data/features/metasploit-version/install/releasing/versioning.feature +138 -0
- data/features/metasploit-version/install/steps/gemspec_steps.rb +19 -0
- data/features/metasploit-version/install/upgrading.feature +19 -0
- data/features/metasploit-version/install/version.feature +11 -0
- data/features/metasploit-version/install/version/namespace.feature +157 -0
- data/features/metasploit-version/install/version/prerelease.feature +154 -0
- data/features/metasploit-version/install/version_spec/namespace.feature +32 -0
- data/features/metasploit-version/install/version_spec/testing/branch_from_master.feature +40 -0
- data/features/metasploit-version/install/version_spec/testing/branching_from_branch.feature +161 -0
- data/features/metasploit-version/install/version_spec/testing/merge_branch_to_master.feature +97 -0
- data/features/{shared/examples/metasploit/version/version_module/prerelease/git/step_definitions → step_definitions}/environment_variable_steps.rb +1 -1
- data/features/{shared/examples/metasploit/version/version_module/prerelease/git/step_definitions → step_definitions}/git_steps.rb +11 -3
- data/features/support/env.rb +15 -11
- data/lib/metasploit/version.rb +1 -0
- data/lib/metasploit/version/cli.rb +321 -0
- data/lib/metasploit/version/version.rb +2 -2
- data/metasploit-version.gemspec +2 -2
- data/spec/lib/metasploit/version/branch_spec.rb +1 -3
- data/spec/lib/metasploit/version/cli_spec.rb +514 -0
- data/spec/lib/metasploit/version/version_spec.rb +2 -4
- data/spec/lib/metasploit/version_spec.rb +2 -4
- data/spec/spec_helper.rb +63 -1
- data/spec/support/shared/examples/metasploit/version/version_module.rb +3 -1
- metadata +81 -7
@@ -0,0 +1,138 @@
|
|
1
|
+
Feature: metasploit-version install should add RELEASING.md that handles pre-1.0.0 and post-1.0.0 versioning
|
2
|
+
|
3
|
+
`metasploit-version install` should have different directions for update the semantic version when it is < 1.0.0 and
|
4
|
+
>= 1.0.0. These instructions should be based on the contents of CHANGELOG.md.
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given I successfully run `bundle gem released`
|
8
|
+
And I cd to "released"
|
9
|
+
And my git identity is configured
|
10
|
+
And I successfully run `git commit --message "bundle gem released"`
|
11
|
+
And I unset the environment variable "TRAVIS_BRANCH"
|
12
|
+
And I set the environment variables to:
|
13
|
+
| variable | value |
|
14
|
+
| TRAVIS_PULL_REQUEST | false |
|
15
|
+
|
16
|
+
Scenario: < 1.0.0
|
17
|
+
When I successfully run `metasploit-version install --force --major 0 --minor 1 --patch 2 --no-bundle-install`
|
18
|
+
Then the file "RELEASING.md" should contain:
|
19
|
+
"""
|
20
|
+
### Compatible changes
|
21
|
+
|
22
|
+
If the [CHANGELOG.md](CHANGELOG.md) contains only Enhancements, Bug Fixes, and/or Deprecations for the Next Release then
|
23
|
+
increment [`PATCH`](lib/released/version.rb).
|
24
|
+
|
25
|
+
### Incompatible changes
|
26
|
+
|
27
|
+
If the [CHANGELOG.md](CHANGELOG.md) contains any Incompatible Changes for the Next Release, then you can either (1)
|
28
|
+
decide to remain pre-1.0.0 or (2) advance to 1.0.0.
|
29
|
+
|
30
|
+
1. To remain pre-1..0.0, then increment [`MINOR`](lib/released/version.rb) and reset [`PATCH`](lib/released/version.rb) to `0`.
|
31
|
+
2. To advance to 1.0.0, increment [`MAJOR`](lib/released/version.rb) and reset [`MINOR`](lib/released/version.rb and [`PATCH`](lib/released/version.rb) to `0`.
|
32
|
+
|
33
|
+
"""
|
34
|
+
|
35
|
+
Scenario: 1.0.0
|
36
|
+
When I successfully run `metasploit-version install --force --major 1 --minor 0 --patch 0 --no-bundle-install`
|
37
|
+
Then the file "RELEASING.md" should contain:
|
38
|
+
"""
|
39
|
+
### Bug fixes
|
40
|
+
|
41
|
+
If the [CHANGELOG.md](CHANGELOG.md) contains only Bug Fixes for the Next Release, then increment
|
42
|
+
[`PATCH`](lib/released/version.rb).
|
43
|
+
|
44
|
+
### Compatible API changes
|
45
|
+
|
46
|
+
If the [CHANGELOG.md](CHANGELOG.md) contains any Enhancements or Deprecations, then increment
|
47
|
+
[`MINOR`](lib/released/version.rb) and reset [`PATCH`](lib/released/version.rb) to `0`.
|
48
|
+
|
49
|
+
### Incompatible API changes
|
50
|
+
|
51
|
+
If the [CHANGELOG.md](CHANGELOG.md) contains any Incompatible Change, then increment [`MAJOR`](lib/released/version.rb) and
|
52
|
+
reset [`MINOR`](lib/released/version.rb and [`PATCH`](lib/released/version.rb) to `0`.
|
53
|
+
|
54
|
+
"""
|
55
|
+
|
56
|
+
Scenario: Version indepedent
|
57
|
+
When I successfully run `metasploit-version install --force --major 0 --minor 1 --patch 2 --no-bundle-install`
|
58
|
+
Then the file "RELEASING.md" should contain:
|
59
|
+
"""
|
60
|
+
# Releasing
|
61
|
+
|
62
|
+
These steps can be added to the Pull Request description's task list to remind the reviewer of how to release the
|
63
|
+
gem.
|
64
|
+
|
65
|
+
```
|
66
|
+
# Release
|
67
|
+
|
68
|
+
Complete these steps on DESTINATION
|
69
|
+
|
70
|
+
## [CHANGELOG.md](CHANGELOG.md)
|
71
|
+
|
72
|
+
### Terminology
|
73
|
+
|
74
|
+
* "Enhancements" are widdening the API, such as by adding new classes or methods.
|
75
|
+
* "Bug Fixes" are fixes to the implementation that do not affect the public API. If the public API is affected then
|
76
|
+
the change should be listed as both a "Bug Fix" and either an "Enhancement" or "Incompatible Change" depending on how
|
77
|
+
the bug was fixed.
|
78
|
+
* "Deprecations" are changes to the implementation that cause deprecation warnings to be issued for APIs which will be
|
79
|
+
removed in a future major release. "Deprecations" are usually accompanied by an Enhancement that creates a new API
|
80
|
+
that is meant to be used in favor of the deprecated API.
|
81
|
+
* "Incompatbile Changes" are the removal of classes or methods or new required arguments or setup that shrink the API.
|
82
|
+
It is best practice to make a "Deprecation" for the API prior to its removal.
|
83
|
+
|
84
|
+
### Task List
|
85
|
+
|
86
|
+
- [ ] Generate the list of changes since the last release: `git log v<LAST_MAJOR>.<LAST_MINOR>.<LAST_PATCH>..HEAD`
|
87
|
+
- [ ] For each commit in the release, find the corresponding PR by search for the commit on Github.
|
88
|
+
- [ ] For each PR, determine whether it is an Enhancement, Bug Fix, Deprecation, and/or Incompatible Change. A PR can
|
89
|
+
be in more than one category, in which case it should be listed in each category it belongs, but with a category
|
90
|
+
specific description of the change.
|
91
|
+
- [ ] Add an item to each category's list in the following format: `[#<PR>](https://github.com/rapid7/released/pull/<PR>) <consumer summary> - [@<github_user>](https://github.com/<github_user>)`
|
92
|
+
`consumer_summary` should be a summary of the Enhancement, Bug Fix, Deprecation, or Incompatible Change from a
|
93
|
+
downstream consumer's of the library's perspective. `github_user` should be Github handle of the author of the
|
94
|
+
PR.
|
95
|
+
- [ ] If you added any Deprecations or Incompatible Changes, then adding upgrading information to
|
96
|
+
[UPGRADING.md](UPGRADING.md)
|
97
|
+
|
98
|
+
## `VERSION`
|
99
|
+
|
100
|
+
The entries in the [CHANGELOG.md](CHANGELOG.md) can be used to help determine how the `VERSION` should be bumped.
|
101
|
+
|
102
|
+
"""
|
103
|
+
And the file "RELEASING.md" should contain:
|
104
|
+
"""
|
105
|
+
|
106
|
+
## Setup [CHANGELOG.md](CHANGELOG.md) for next release
|
107
|
+
|
108
|
+
- [ ] Change `Next Release` section name at the top of [CHANGELOG.md](CHANGELOG.md) to match the current `VERSION`.
|
109
|
+
- [ ] Add a new `Next Release` section above the `VERSION`'s section you just renamed:
|
110
|
+
<pre>
|
111
|
+
# Next Release
|
112
|
+
|
113
|
+
* Enhancements
|
114
|
+
* Bug Fixes
|
115
|
+
* Deprecations
|
116
|
+
* Incompatible Changes
|
117
|
+
</pre>
|
118
|
+
|
119
|
+
## Release to rubygems.org
|
120
|
+
|
121
|
+
## jruby
|
122
|
+
- [ ] `rvm use jruby@released`
|
123
|
+
- [ ] `rm Gemfile.lock`
|
124
|
+
- [ ] `bundle install`
|
125
|
+
- [ ] `rake release`
|
126
|
+
|
127
|
+
## ruby-2.1
|
128
|
+
- [ ] `rvm use ruby-2.1@released`
|
129
|
+
- [ ] `rm Gemfile.lock`
|
130
|
+
- [ ] `bundle install`
|
131
|
+
- [ ] `rake release`
|
132
|
+
```
|
133
|
+
|
134
|
+
### Downstream dependencies
|
135
|
+
|
136
|
+
There are currently no known downstream dependenci
|
137
|
+
"""
|
138
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Then(/^metasploit\-version should be development dependency with semantic version restriction in "(.*?)"$/) do |gemspec_path|
|
2
|
+
version_requirement = if defined? Metasploit::Version::Version::PRERELEASE
|
3
|
+
# require exactly this pre-release in case there are multiple prereleases for the same
|
4
|
+
# version number due to parallel branches.
|
5
|
+
"= #{Metasploit::Version::GEM_VERSION}"
|
6
|
+
elsif Metasploit::Version::Version::MAJOR < 1
|
7
|
+
# can only allow the PATCH to wiggle pre-1.0.0
|
8
|
+
"~> #{Metasploit::Version::Version::MAJOR}.#{Metasploit::Version::Version::MINOR}.#{Metasploit::Version::Version::PATCH}"
|
9
|
+
else
|
10
|
+
# can allow the MINOR to wiggle 1.0.0+
|
11
|
+
"~> #{Metasploit::Version::Version::MAJOR}.#{Metasploit::Version::Version::MINOR}"
|
12
|
+
end
|
13
|
+
|
14
|
+
check_file_content(
|
15
|
+
gemspec_path,
|
16
|
+
%r{spec\.add_development_dependency\s*(?<quote>'|")metasploit-version\k<quote>,\s*\k<quote>#{version_requirement}\k<quote>},
|
17
|
+
true
|
18
|
+
)
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Feature: metasploit-version install should add UPGRADING.md
|
2
|
+
|
3
|
+
`metasploit-version install` should generate UPGRADING.md which includes any information needed by downstream
|
4
|
+
consumers of the gem when upgrading to handle Deprecations or Incompatible Changes.
|
5
|
+
|
6
|
+
Scenario:
|
7
|
+
Given I successfully run `bundle gem upgraded`
|
8
|
+
And I cd to "upgraded"
|
9
|
+
And my git identity is configured
|
10
|
+
And I successfully run `git commit --message "bundle gem upgraded"`
|
11
|
+
And I unset the environment variable "TRAVIS_BRANCH"
|
12
|
+
And I set the environment variables to:
|
13
|
+
| variable | value |
|
14
|
+
| TRAVIS_PULL_REQUEST | false |
|
15
|
+
When I successfully run `metasploit-version install --force --no-bundle-install`
|
16
|
+
Then the file "UPGRADING.md" should contain:
|
17
|
+
"""
|
18
|
+
No Deprecations or Incompatible Changes have been introduced at this time
|
19
|
+
"""
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Feature: metasploit-version install adds 'version.rb' to replace default 'version.rb'
|
2
|
+
|
3
|
+
The version.rb file from metasploit-version will follow semver.org and define `MAJOR`, `MINOR`, and `PATCH`. If on
|
4
|
+
a branch, the `PRERELEASE` will also be defined. Default implementations for `Version.full` and `Version.gem` will
|
5
|
+
be provided and `VERSION` and `GEM_VERSION` will be set to the respective method.
|
6
|
+
|
7
|
+
Scenario: No gemspec
|
8
|
+
Given a file matching %r<.*\.gemspec> should not exist
|
9
|
+
When I run `metasploit-version install`
|
10
|
+
Then the output should contain "No gemspec found"
|
11
|
+
And the exit status should not be 0
|
@@ -0,0 +1,157 @@
|
|
1
|
+
Feature: metasploit-version install's 'version.rb' generate proper namespace nesting
|
2
|
+
|
3
|
+
The version.rb file from metasploit-version will generate the appropriately indented nesting for single and multiple
|
4
|
+
namespaces with proper conversion of underscored and dashes in the gem name to camel case and separate modules,
|
5
|
+
respectively
|
6
|
+
|
7
|
+
Scenario Outline: Top-level namespace
|
8
|
+
Given I successfully run `bundle gem <gem_name>`
|
9
|
+
And I cd to "<gem_name>"
|
10
|
+
And my git identity is configured
|
11
|
+
And I successfully run `git commit --message "bundle gem <gem_name>"`
|
12
|
+
And I unset the environment variable "TRAVIS_BRANCH"
|
13
|
+
And I set the environment variables to:
|
14
|
+
| variable | value |
|
15
|
+
| TRAVIS_PULL_REQUEST | false |
|
16
|
+
When I successfully run `metasploit-version install --force --no-bundle-install`
|
17
|
+
Then the file "<version_rb_path>" should contain exactly:
|
18
|
+
"""
|
19
|
+
module <namespace_name>
|
20
|
+
# Holds components of {VERSION} as defined by {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0}.
|
21
|
+
module Version
|
22
|
+
#
|
23
|
+
# CONSTANTS
|
24
|
+
#
|
25
|
+
|
26
|
+
# The major version number.
|
27
|
+
MAJOR = 0
|
28
|
+
# The minor version number, scoped to the {MAJOR} version number.
|
29
|
+
MINOR = 0
|
30
|
+
# The patch version number, scoped to the {MAJOR} and {MINOR} version numbers.
|
31
|
+
PATCH = 1
|
32
|
+
|
33
|
+
#
|
34
|
+
# Module Methods
|
35
|
+
#
|
36
|
+
|
37
|
+
# The full version string, including the {<namespace_name>::Version::MAJOR},
|
38
|
+
# {<namespace_name>::Version::MINOR}, {<namespace_name>::Version::PATCH}, and optionally, the
|
39
|
+
# `<namespace_name>::Version::PRERELEASE` in the
|
40
|
+
# {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0} format.
|
41
|
+
#
|
42
|
+
# @return [String] '{<namespace_name>::Version::MAJOR}.{<namespace_name>::Version::MINOR}.{<namespace_name>::Version::PATCH}' on master.
|
43
|
+
# '{<namespace_name>::Version::MAJOR}.{<namespace_name>::Version::MINOR}.{<namespace_name>::Version::PATCH}-PRERELEASE'
|
44
|
+
# on any branch other than master.
|
45
|
+
def self.full
|
46
|
+
version = "#{MAJOR}.#{MINOR}.#{PATCH}"
|
47
|
+
|
48
|
+
if defined? PRERELEASE
|
49
|
+
version = "#{version}-#{PRERELEASE}"
|
50
|
+
end
|
51
|
+
|
52
|
+
version
|
53
|
+
end
|
54
|
+
|
55
|
+
# The full gem version string, including the {<namespace_name>::Version::MAJOR},
|
56
|
+
# {<namespace_name>::Version::MINOR}, {<namespace_name>::Version::PATCH}, and optionally, the
|
57
|
+
# `<namespace_name>::Version::PRERELEASE` in the
|
58
|
+
# {http://guides.rubygems.org/specification-reference/#version RubyGems versioning} format.
|
59
|
+
#
|
60
|
+
# @return [String] '{<namespace_name>::Version::MAJOR}.{<namespace_name>::Version::MINOR}.{<namespace_name>::Version::PATCH}'
|
61
|
+
# on master. '{<namespace_name>::Version::MAJOR}.{<namespace_name>::Version::MINOR}.{<namespace_name>::Version::PATCH}.PRERELEASE'
|
62
|
+
# on any branch other than master.
|
63
|
+
def self.gem
|
64
|
+
full.gsub('-', '.pre.')
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# (see Version.gem)
|
69
|
+
GEM_VERSION = Version.gem
|
70
|
+
|
71
|
+
# (see Version.full)
|
72
|
+
VERSION = Version.full
|
73
|
+
end
|
74
|
+
|
75
|
+
"""
|
76
|
+
|
77
|
+
Examples:
|
78
|
+
| gem_name | version_rb_path | namespace_name |
|
79
|
+
| single | lib/single/version.rb | Single |
|
80
|
+
| two_words | lib/two_words/version.rb | TwoWords |
|
81
|
+
|
82
|
+
Scenario Outline: Two-level namespace
|
83
|
+
Given I successfully run `bundle gem <gem_name>`
|
84
|
+
And I cd to "<gem_name>"
|
85
|
+
And my git identity is configured
|
86
|
+
And I successfully run `git commit --message "bundle gem <gem_name>"`
|
87
|
+
And I unset the environment variable "TRAVIS_BRANCH"
|
88
|
+
And I set the environment variables to:
|
89
|
+
| variable | value |
|
90
|
+
| TRAVIS_PULL_REQUEST | false |
|
91
|
+
When I successfully run `metasploit-version install --force --no-bundle-install`
|
92
|
+
Then the file "<version_rb_path>" should contain exactly:
|
93
|
+
"""
|
94
|
+
module <parent_module_name>
|
95
|
+
module <child_module_name>
|
96
|
+
# Holds components of {VERSION} as defined by {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0}.
|
97
|
+
module Version
|
98
|
+
#
|
99
|
+
# CONSTANTS
|
100
|
+
#
|
101
|
+
|
102
|
+
# The major version number.
|
103
|
+
MAJOR = 0
|
104
|
+
# The minor version number, scoped to the {MAJOR} version number.
|
105
|
+
MINOR = 0
|
106
|
+
# The patch version number, scoped to the {MAJOR} and {MINOR} version numbers.
|
107
|
+
PATCH = 1
|
108
|
+
|
109
|
+
#
|
110
|
+
# Module Methods
|
111
|
+
#
|
112
|
+
|
113
|
+
# The full version string, including the {<parent_module_name>::<child_module_name>::Version::MAJOR},
|
114
|
+
# {<parent_module_name>::<child_module_name>::Version::MINOR}, {<parent_module_name>::<child_module_name>::Version::PATCH}, and optionally, the
|
115
|
+
# `<parent_module_name>::<child_module_name>::Version::PRERELEASE` in the
|
116
|
+
# {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0} format.
|
117
|
+
#
|
118
|
+
# @return [String] '{<parent_module_name>::<child_module_name>::Version::MAJOR}.{<parent_module_name>::<child_module_name>::Version::MINOR}.{<parent_module_name>::<child_module_name>::Version::PATCH}' on master.
|
119
|
+
# '{<parent_module_name>::<child_module_name>::Version::MAJOR}.{<parent_module_name>::<child_module_name>::Version::MINOR}.{<parent_module_name>::<child_module_name>::Version::PATCH}-PRERELEASE'
|
120
|
+
# on any branch other than master.
|
121
|
+
def self.full
|
122
|
+
version = "#{MAJOR}.#{MINOR}.#{PATCH}"
|
123
|
+
|
124
|
+
if defined? PRERELEASE
|
125
|
+
version = "#{version}-#{PRERELEASE}"
|
126
|
+
end
|
127
|
+
|
128
|
+
version
|
129
|
+
end
|
130
|
+
|
131
|
+
# The full gem version string, including the {<parent_module_name>::<child_module_name>::Version::MAJOR},
|
132
|
+
# {<parent_module_name>::<child_module_name>::Version::MINOR}, {<parent_module_name>::<child_module_name>::Version::PATCH}, and optionally, the
|
133
|
+
# `<parent_module_name>::<child_module_name>::Version::PRERELEASE` in the
|
134
|
+
# {http://guides.rubygems.org/specification-reference/#version RubyGems versioning} format.
|
135
|
+
#
|
136
|
+
# @return [String] '{<parent_module_name>::<child_module_name>::Version::MAJOR}.{<parent_module_name>::<child_module_name>::Version::MINOR}.{<parent_module_name>::<child_module_name>::Version::PATCH}'
|
137
|
+
# on master. '{<parent_module_name>::<child_module_name>::Version::MAJOR}.{<parent_module_name>::<child_module_name>::Version::MINOR}.{<parent_module_name>::<child_module_name>::Version::PATCH}.PRERELEASE'
|
138
|
+
# on any branch other than master.
|
139
|
+
def self.gem
|
140
|
+
full.gsub('-', '.pre.')
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
# (see Version.gem)
|
145
|
+
GEM_VERSION = Version.gem
|
146
|
+
|
147
|
+
# (see Version.full)
|
148
|
+
VERSION = Version.full
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
"""
|
153
|
+
|
154
|
+
Examples:
|
155
|
+
| gem_name | version_rb_path | parent_module_name | child_module_name |
|
156
|
+
| parent-single | lib/parent/single/version.rb | Parent | Single |
|
157
|
+
| parent-two_words | lib/parent/two_words/version.rb | Parent | TwoWords |
|
@@ -0,0 +1,154 @@
|
|
1
|
+
Feature: metasploit-version install conditionally defines PRERELEASE in version.rb
|
2
|
+
|
3
|
+
The version.rb file will define PRERELEASE to the branch's prerelease name when `metasploit-version install` is run on
|
4
|
+
a branch, while it will not define PRERELEASE on master.
|
5
|
+
|
6
|
+
Scenario: No PRERELEASE on master
|
7
|
+
Given I successfully run `bundle gem master`
|
8
|
+
And I cd to "master"
|
9
|
+
And I unset the environment variable "TRAVIS_BRANCH"
|
10
|
+
And I set the environment variables to:
|
11
|
+
| variable | value |
|
12
|
+
| TRAVIS_PULL_REQUEST | false |
|
13
|
+
And my git identity is configured
|
14
|
+
And I successfully run `git commit --message "bundle gem master"`
|
15
|
+
When I successfully run `metasploit-version install --force --no-bundle-install`
|
16
|
+
Then the file "lib/master/version.rb" should contain exactly:
|
17
|
+
"""
|
18
|
+
module Master
|
19
|
+
# Holds components of {VERSION} as defined by {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0}.
|
20
|
+
module Version
|
21
|
+
#
|
22
|
+
# CONSTANTS
|
23
|
+
#
|
24
|
+
|
25
|
+
# The major version number.
|
26
|
+
MAJOR = 0
|
27
|
+
# The minor version number, scoped to the {MAJOR} version number.
|
28
|
+
MINOR = 0
|
29
|
+
# The patch version number, scoped to the {MAJOR} and {MINOR} version numbers.
|
30
|
+
PATCH = 1
|
31
|
+
|
32
|
+
#
|
33
|
+
# Module Methods
|
34
|
+
#
|
35
|
+
|
36
|
+
# The full version string, including the {Master::Version::MAJOR},
|
37
|
+
# {Master::Version::MINOR}, {Master::Version::PATCH}, and optionally, the
|
38
|
+
# `Master::Version::PRERELEASE` in the
|
39
|
+
# {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0} format.
|
40
|
+
#
|
41
|
+
# @return [String] '{Master::Version::MAJOR}.{Master::Version::MINOR}.{Master::Version::PATCH}' on master.
|
42
|
+
# '{Master::Version::MAJOR}.{Master::Version::MINOR}.{Master::Version::PATCH}-PRERELEASE'
|
43
|
+
# on any branch other than master.
|
44
|
+
def self.full
|
45
|
+
version = "#{MAJOR}.#{MINOR}.#{PATCH}"
|
46
|
+
|
47
|
+
if defined? PRERELEASE
|
48
|
+
version = "#{version}-#{PRERELEASE}"
|
49
|
+
end
|
50
|
+
|
51
|
+
version
|
52
|
+
end
|
53
|
+
|
54
|
+
# The full gem version string, including the {Master::Version::MAJOR},
|
55
|
+
# {Master::Version::MINOR}, {Master::Version::PATCH}, and optionally, the
|
56
|
+
# `Master::Version::PRERELEASE` in the
|
57
|
+
# {http://guides.rubygems.org/specification-reference/#version RubyGems versioning} format.
|
58
|
+
#
|
59
|
+
# @return [String] '{Master::Version::MAJOR}.{Master::Version::MINOR}.{Master::Version::PATCH}'
|
60
|
+
# on master. '{Master::Version::MAJOR}.{Master::Version::MINOR}.{Master::Version::PATCH}.PRERELEASE'
|
61
|
+
# on any branch other than master.
|
62
|
+
def self.gem
|
63
|
+
full.gsub('-', '.pre.')
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# (see Version.gem)
|
68
|
+
GEM_VERSION = Version.gem
|
69
|
+
|
70
|
+
# (see Version.full)
|
71
|
+
VERSION = Version.full
|
72
|
+
end
|
73
|
+
|
74
|
+
"""
|
75
|
+
|
76
|
+
Scenario Outline: PRERELEASE on branch
|
77
|
+
Given I successfully run `bundle gem branch`
|
78
|
+
And I cd to "branch"
|
79
|
+
And I unset the environment variable "TRAVIS_BRANCH"
|
80
|
+
And I set the environment variables to:
|
81
|
+
| variable | value |
|
82
|
+
| TRAVIS_PULL_REQUEST | false |
|
83
|
+
And my git identity is configured
|
84
|
+
And I successfully run `git commit --message "bundle gem branch"`
|
85
|
+
And I successfully run `git checkout -b <branch>`
|
86
|
+
When I successfully run `metasploit-version install --force --no-bundle-install`
|
87
|
+
Then the file "lib/branch/version.rb" should contain exactly:
|
88
|
+
"""
|
89
|
+
module Branch
|
90
|
+
# Holds components of {VERSION} as defined by {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0}.
|
91
|
+
module Version
|
92
|
+
#
|
93
|
+
# CONSTANTS
|
94
|
+
#
|
95
|
+
|
96
|
+
# The major version number.
|
97
|
+
MAJOR = 0
|
98
|
+
# The minor version number, scoped to the {MAJOR} version number.
|
99
|
+
MINOR = 0
|
100
|
+
# The patch version number, scoped to the {MAJOR} and {MINOR} version numbers.
|
101
|
+
PATCH = 1
|
102
|
+
# The prerelease version, scoped to the {MAJOR}, {MINOR}, and {PATCH} version numbers.
|
103
|
+
PRERELEASE = '<prerelease>'
|
104
|
+
|
105
|
+
#
|
106
|
+
# Module Methods
|
107
|
+
#
|
108
|
+
|
109
|
+
# The full version string, including the {Branch::Version::MAJOR},
|
110
|
+
# {Branch::Version::MINOR}, {Branch::Version::PATCH}, and optionally, the
|
111
|
+
# `Branch::Version::PRERELEASE` in the
|
112
|
+
# {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0} format.
|
113
|
+
#
|
114
|
+
# @return [String] '{Branch::Version::MAJOR}.{Branch::Version::MINOR}.{Branch::Version::PATCH}' on master.
|
115
|
+
# '{Branch::Version::MAJOR}.{Branch::Version::MINOR}.{Branch::Version::PATCH}-PRERELEASE'
|
116
|
+
# on any branch other than master.
|
117
|
+
def self.full
|
118
|
+
version = "#{MAJOR}.#{MINOR}.#{PATCH}"
|
119
|
+
|
120
|
+
if defined? PRERELEASE
|
121
|
+
version = "#{version}-#{PRERELEASE}"
|
122
|
+
end
|
123
|
+
|
124
|
+
version
|
125
|
+
end
|
126
|
+
|
127
|
+
# The full gem version string, including the {Branch::Version::MAJOR},
|
128
|
+
# {Branch::Version::MINOR}, {Branch::Version::PATCH}, and optionally, the
|
129
|
+
# `Branch::Version::PRERELEASE` in the
|
130
|
+
# {http://guides.rubygems.org/specification-reference/#version RubyGems versioning} format.
|
131
|
+
#
|
132
|
+
# @return [String] '{Branch::Version::MAJOR}.{Branch::Version::MINOR}.{Branch::Version::PATCH}'
|
133
|
+
# on master. '{Branch::Version::MAJOR}.{Branch::Version::MINOR}.{Branch::Version::PATCH}.PRERELEASE'
|
134
|
+
# on any branch other than master.
|
135
|
+
def self.gem
|
136
|
+
full.gsub('-', '.pre.')
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
# (see Version.gem)
|
141
|
+
GEM_VERSION = Version.gem
|
142
|
+
|
143
|
+
# (see Version.full)
|
144
|
+
VERSION = Version.full
|
145
|
+
end
|
146
|
+
|
147
|
+
"""
|
148
|
+
|
149
|
+
Examples:
|
150
|
+
| branch | prerelease |
|
151
|
+
| staging/flood-release | flood-release |
|
152
|
+
| bug/MSP-666/nasty | nasty |
|
153
|
+
| chore/MSP-1234/recurring | recurring |
|
154
|
+
| feature/MSP-1337/super-cool | super-cool |
|