release: cleanup patch, minor, major
This commit is contained in:
@@ -28,15 +28,23 @@ module Release
|
||||
private
|
||||
|
||||
def validate_version_format (version)
|
||||
error "invalid version number format: #{version}" unless version =~ /\d+\.\d+\.\d+/
|
||||
error "Invalid version number format. Try using MAJOR.MINOR.PATCH." unless version =~ /\d+\.\d+\.\d+/
|
||||
end
|
||||
|
||||
def validate_version_is_new (version)
|
||||
error "version already exists: #{git_local_list_tags.join(' ')}" if git_local_list_tags.include? "v#{version}"
|
||||
error "Version already exists: #{git_local_list_tags.join(' ')}" if git_local_list_tags.include? "v#{version}"
|
||||
end
|
||||
|
||||
def validate_version_exists (version)
|
||||
error "Version does not exist: #{git_local_list_tags.join(' ')}" unless git_local_list_tags.include? "v#{version}"
|
||||
end
|
||||
|
||||
def validate_current_branch_master
|
||||
error "invalid starting branch: #{current_branch}" unless standard_branches.include? current_branch
|
||||
error "Invalid starting branch: #{current_branch}. Try switching to #{standard_branches.join(' ')}." unless standard_branches.include? current_branch
|
||||
end
|
||||
|
||||
def validate_release_branch_does_not_exist (branch)
|
||||
error "Version branch already exists: #{branch}" if remote_branch(branch) != ""
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -15,11 +15,12 @@ module Release
|
||||
subcommand, version, *extras = *argv
|
||||
|
||||
validate_version_format version
|
||||
validate_version_is_new version
|
||||
validate_current_branch_master
|
||||
|
||||
validate_current_branch_master
|
||||
git_pull current_branch
|
||||
|
||||
validate_version_is_new version
|
||||
|
||||
git_local_tag version
|
||||
|
||||
git_push_tags
|
||||
|
||||
@@ -1,35 +1,16 @@
|
||||
require_relative './base'
|
||||
require_relative './new_version'
|
||||
|
||||
module Release
|
||||
|
||||
class Major < Release::Base
|
||||
def valid?
|
||||
argv.size > 1
|
||||
end
|
||||
|
||||
def help
|
||||
"release major version"
|
||||
end
|
||||
|
||||
def execute
|
||||
subcommand, version, *extras = *argv
|
||||
|
||||
error "invalid version: #{version}" unless version =~ /\d+\.\d+\.\d+/
|
||||
error "unknown version: #{git_local_list_tags.join(' ')}" unless git_local_list_tags.include? "v#{version}"
|
||||
error "invalid base branch: #{current_branch}" unless standard_branches.include? current_branch
|
||||
|
||||
major_branch = major(version)
|
||||
|
||||
git_pull current_branch
|
||||
|
||||
git_local_branch_create major_branch, "v#{version}"
|
||||
|
||||
git_push major_branch
|
||||
end
|
||||
class Major < Release::NewVersion
|
||||
|
||||
private
|
||||
|
||||
def major (version)
|
||||
def subcommand_name
|
||||
"major"
|
||||
end
|
||||
|
||||
def increment_version (version)
|
||||
numbers = version.split('.').map { |x| x.to_i }
|
||||
"#{numbers[0]+1}.0.0"
|
||||
end
|
||||
|
||||
@@ -1,35 +1,16 @@
|
||||
require_relative './base'
|
||||
require_relative './new_version'
|
||||
|
||||
module Release
|
||||
|
||||
class Minor < Release::Base
|
||||
def valid?
|
||||
argv.size > 1
|
||||
end
|
||||
|
||||
def help
|
||||
"release minor version"
|
||||
end
|
||||
|
||||
def execute
|
||||
subcommand, version, *extras = *argv
|
||||
|
||||
error "invalid version: #{version}" unless version =~ /\d+\.\d+\.\d+/
|
||||
error "unknown version: #{git_local_list_tags.join(' ')}" unless git_local_list_tags.include? "v#{version}"
|
||||
error "invalid base branch: #{current_branch}" unless standard_branches.include? current_branch
|
||||
|
||||
minor_branch = minor(version)
|
||||
|
||||
git_pull current_branch
|
||||
|
||||
git_local_branch_create minor_branch, "v#{version}"
|
||||
|
||||
git_push minor_branch
|
||||
end
|
||||
class Minor < Release::NewVersion
|
||||
|
||||
private
|
||||
|
||||
def minor (version)
|
||||
def subcommand_name
|
||||
"minor"
|
||||
end
|
||||
|
||||
def increment_version (version)
|
||||
numbers = version.split('.').map { |x| x.to_i }
|
||||
"#{numbers[0]}.#{numbers[1]+1}.0"
|
||||
end
|
||||
|
||||
44
lib/release/new_version.rb
Normal file
44
lib/release/new_version.rb
Normal file
@@ -0,0 +1,44 @@
|
||||
require_relative './base'
|
||||
|
||||
module Release
|
||||
|
||||
class NewVersion < Release::Base
|
||||
def valid?
|
||||
argv.size > 1
|
||||
end
|
||||
|
||||
def help
|
||||
"release #{subcommand_name} version"
|
||||
end
|
||||
|
||||
def execute
|
||||
subcommand, version, *extras = *argv
|
||||
|
||||
validate_version_format version
|
||||
|
||||
validate_current_branch_master
|
||||
git_pull current_branch
|
||||
|
||||
validate_version_exists version
|
||||
|
||||
new_branch = increment_version(version)
|
||||
validate_release_branch_does_not_exist(new_branch)
|
||||
|
||||
git_local_branch_create new_branch, "v#{version}"
|
||||
|
||||
git_push new_branch
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def subcommand_name
|
||||
error "override"
|
||||
end
|
||||
|
||||
def increment_version (version)
|
||||
error "override"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,35 +1,16 @@
|
||||
require_relative './base'
|
||||
require_relative './new_version'
|
||||
|
||||
module Release
|
||||
|
||||
class Patch < Release::Base
|
||||
def valid?
|
||||
argv.size > 1
|
||||
end
|
||||
|
||||
def help
|
||||
"release patch version"
|
||||
end
|
||||
|
||||
def execute
|
||||
subcommand, version, *extras = *argv
|
||||
|
||||
error "invalid version: #{version}" unless version =~ /\d+\.\d+\.\d+/
|
||||
error "unknown version: #{git_local_list_tags.join(' ')}" unless git_local_list_tags.include? "v#{version}"
|
||||
error "invalid base branch: #{current_branch}" unless standard_branches.include? current_branch
|
||||
|
||||
patch_branch = patch(version)
|
||||
|
||||
git_pull current_branch
|
||||
|
||||
git_local_branch_create patch_branch, "v#{version}"
|
||||
|
||||
git_push patch_branch
|
||||
end
|
||||
class Patch < Release::NewVersion
|
||||
|
||||
private
|
||||
|
||||
def patch (version)
|
||||
def subcommand_name
|
||||
"patch"
|
||||
end
|
||||
|
||||
def increment_version (version)
|
||||
numbers = version.split('.').map { |x| x.to_i }
|
||||
"#{numbers[0]}.#{numbers[1]}.#{numbers[2]+1}"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user