class SRC::Branch
Attributes
branches_from[R]
merges_to[R]
prefix[R]
semantic_level[R]
vc[R]
Public Class Methods
new(type)
click to toggle source
# File lib/src/branch.rb, line 8 def initialize(type) opts = branches[type.to_sym] || {} @vc = SRC::Git::Branch @branches_from = vc.new(opts[:branches_from]) @prefix = opts[:prefix] @merges_to = vc.new(opts[:merges_to]) @semantic_level = opts[:semantic_level] end
Public Instance Methods
cut()
click to toggle source
# File lib/src/branch.rb, line 17 def cut if unmerged? puts "An unmerged #{prefix} branch exists. Checking out." latest.checkout else create_new end end
latest()
click to toggle source
# File lib/src/branch.rb, line 56 def latest @latest ||= vc.latest(prefix) end
merge()
click to toggle source
# File lib/src/branch.rb, line 26 def merge if unmerged? if merges_to.subset_of?(latest) merges_to.merge(latest) merges_to.tag else puts "You must first merge #{merges_to} into #{latest}" end else puts "No unmerged #{prefix} branch exists." end end
next_version()
click to toggle source
# File lib/src/branch.rb, line 39 def next_version case semantic_level when 'patch' i = 2 when 'minor' i = 1 when 'major' i = 0 end parts = branches_from.version.split('.') ((i + 1)..2).each { |j| parts[j] = '0' } parts[i] = (parts[i].to_i + 1).to_s parts.join('.') end
unmerged?()
click to toggle source
# File lib/src/branch.rb, line 60 def unmerged? latest && !latest.subset_of?(merges_to) end
Private Instance Methods
branches()
click to toggle source
# File lib/src/branch.rb, line 77 def branches SRC::BRANCHES end
create_new()
click to toggle source
# File lib/src/branch.rb, line 66 def create_new if branches_from == merges_to new_branch = branches_from.branch_from("#{prefix}-#{next_version}") new_branch.update_version_file(next_version) else new_branch = branches_from.branch_from("#{prefix}-#{branches_from.version}") branches_from.update_version_file(next_version) end new_branch.checkout end