release: added init
This commit is contained in:
@@ -6,6 +6,7 @@ module Release
|
|||||||
|
|
||||||
COMMANDS = [
|
COMMANDS = [
|
||||||
:help,
|
:help,
|
||||||
|
:init
|
||||||
].sort
|
].sort
|
||||||
|
|
||||||
DEFAULT = :help
|
DEFAULT = :help
|
||||||
|
|||||||
30
lib/release/init.rb
Normal file
30
lib/release/init.rb
Normal file
@@ -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
|
||||||
@@ -10,7 +10,7 @@ module Shared
|
|||||||
end
|
end
|
||||||
|
|
||||||
def standard_branches
|
def standard_branches
|
||||||
['master','develop','integration']
|
['master']
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse_branch (branch)
|
def parse_branch (branch)
|
||||||
|
|||||||
@@ -39,6 +39,14 @@ module Shared
|
|||||||
run_cmd "git branch -D #{branch}"
|
run_cmd "git branch -D #{branch}"
|
||||||
end
|
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
|
def git_prune
|
||||||
run_cmd "git remote prune origin"
|
run_cmd "git remote prune origin"
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user