diff --git a/lib/release/base.rb b/lib/release/base.rb index 0f01b57..db1738e 100644 --- a/lib/release/base.rb +++ b/lib/release/base.rb @@ -24,6 +24,20 @@ module Release puts exit end + + private + + def validate_version_format (version) + error "invalid version number format: #{version}" 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}" + end + + def validate_current_branch_master + error "invalid starting branch: #{current_branch}" unless standard_branches.include? current_branch + end end end diff --git a/lib/release/init.rb b/lib/release/init.rb index 9f44af2..b50d82d 100644 --- a/lib/release/init.rb +++ b/lib/release/init.rb @@ -14,13 +14,13 @@ module Release def execute subcommand, version, *extras = *argv - error "invalid version: #{version}" unless version =~ /\d+\.\d+\.\d+/ - error "existing version: #{git_local_list_tags.join(' ')}" if git_local_list_tags.include? "v#{version}" - error "invalid base branch: #{current_branch}" unless standard_branches.include? current_branch + validate_version_format version + validate_version_is_new version + validate_current_branch_master git_pull current_branch -# git_local_tag version + git_local_tag version git_push_tags