diff --git a/lib/release/commander.rb b/lib/release/commander.rb index 9c9ed2d..bbdd8f3 100644 --- a/lib/release/commander.rb +++ b/lib/release/commander.rb @@ -6,6 +6,7 @@ module Release COMMANDS = [ :help, + :init ].sort DEFAULT = :help diff --git a/lib/release/init.rb b/lib/release/init.rb new file mode 100644 index 0000000..9f44af2 --- /dev/null +++ b/lib/release/init.rb @@ -0,0 +1,30 @@ +require_relative './base' + +module Release + + class Init < Release::Base + def valid? + argv.size > 1 + end + + def help + "release init version" + end + + 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 + + git_pull current_branch + +# git_local_tag version + + git_push_tags + + end + end + +end diff --git a/lib/shared/branchability.rb b/lib/shared/branchability.rb index 8a0efea..3f247bb 100644 --- a/lib/shared/branchability.rb +++ b/lib/shared/branchability.rb @@ -10,7 +10,7 @@ module Shared end def standard_branches - ['master','develop','integration'] + ['master'] end def parse_branch (branch) diff --git a/lib/shared/runnable.rb b/lib/shared/runnable.rb index 7ea824d..2733d31 100644 --- a/lib/shared/runnable.rb +++ b/lib/shared/runnable.rb @@ -39,6 +39,14 @@ module Shared run_cmd "git branch -D #{branch}" end + def git_local_tag ( tag ) + run_cmd "git tag -a 'v#{tag}' -m 'v#{tag}'" + end + + def git_local_list_tags + `git tag -l 'v*'`.strip.split(/\s+/) + end + def git_prune run_cmd "git remote prune origin" end