Class: MSPRelease::CLI::Branch
Constant Summary
Constants included
from Helpers
Helpers::PROJECT_FILE
Instance Attribute Summary
#git, #project
Instance Method Summary
collapse
#initialize
Methods included from Helpers
#author, #changelog, #data, #data=, #data_exists?, #fail_if_modified_wc, #fail_if_push_pending, #git_version, #load_data, #msp_version, #on_release_branch?, #remove_data, #save_data, #time, #time_rfc, #timestamp
#exec
Instance Method Details
#bump_and_push_master ⇒ Object
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/msp_release/cli/branch.rb', line 69
def bump_and_push_master
return "HEAD@{0}" if options[:no_bump_master]
fail_if_modified_wc
new_version, *changed_files = project.bump_version('minor')
exec "git add -- #{changed_files.join(' ')}"
exec "git commit -m 'BUMPED VERSION TO #{new_version}'"
begin
$stdout.puts "Bumping master to #{new_version}, pushing to origin..."
exec "git push origin master"
rescue
$stderr.puts "error pushing bump commit to master, undoing bump..."
exec "git reset --hard HEAD@{1}"
raise CLI::Exit, 'could not push bump commit to master, if you do ' +
'not want to bump the minor version of master, try again with ' +
'--no-bump-master'
end
"HEAD@{1}"
end
|
#check_branching_ok! ⇒ Object
59
60
61
62
63
64
65
66
67
|
# File 'lib/msp_release/cli/branch.rb', line 59
def check_branching_ok!
if options[:allow_non_master_branch]
$stderr.puts("Creating a non-master release branch, --allow-non-master-branch supplied")
"HEAD@{0}"
else
raise CLI::Exit, "You must be on master to create " +
"release branches, or pass --allow-non-master-branch"
end
end
|
#run ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/msp_release/cli/branch.rb', line 34
def run
fail_if_push_pending
version = project.version
branch_from =
if git.on_master?
bump_and_push_master
else
check_branching_ok!
end
branch_name = project.branch_name(version)
begin
MSPRelease::MakeBranch.new(git, branch_name, :start_point => branch_from).
perform!
rescue MSPRelease::MakeBranch::BranchExistsError => e
raise CLI::Exit, "A branch already exists for #{version}"
end
$stdout.puts("Switched to release branch '#{branch_name}'")
end
|