Class: GitMaintain::GitMaintainBranch
- Defined in:
- lib/addons/git-maintain.rb
Constant Summary collapse
- REPO_NAME =
"git-maintain"
Constants inherited from Branch
Branch::ACTION_HELP, Branch::ACTION_LIST, Branch::ALL_BRANCHES_ACTIONS, Branch::NO_CHECKOUT_ACTIONS, Branch::NO_FETCH_ACTIONS
Instance Attribute Summary
Attributes inherited from Branch
#exists, #head, #local_branch, #remote_branch, #remote_ref, #stable_base, #stable_head, #verbose_name, #version
Instance Method Summary collapse
Methods inherited from Branch
check_opts, #checkout, #cp, #create, #delete, delete_epilogue, execAction, #initialize, #is_targetted?, #list, #list_stable, load, #log, #merge, #monitor, #monitor_stable, #push, push_epilogue, #push_stable, push_stable_epilogue, #reset, set_opts, #steal
Constructor Details
This class inherits a constructor from GitMaintain::Branch
Instance Method Details
#release(opts) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/addons/git-maintain.rb', line 5 def release(opts) prev_ver=@repo.runGit("show HEAD:CHANGELOG | grep -A 1 -- '---------' | head -n 2 | tail -n 1 | awk '{ print $1}'").chomp() ver_nums = prev_ver.split(".") if opts[:manual_branch] == nil then new_ver = (ver_nums[0 .. -2] + [ver_nums[-1].to_i() + 1 ]).join(".") git_prev_ver = "v" + (ver_nums[-1] == "0" ? ver_nums[0 .. -2].join(".") : prev_ver) else new_ver = (ver_nums[0 .. -3] + [ver_nums[-2].to_i() + 1 ] + [ "0" ]).join(".") git_prev_ver = "v" + prev_ver end changes=@repo.runGit("show HEAD:CHANGELOG | awk ' BEGIN {count=0} {if ($1 == \"------------------\") count++; if (count == 0) print $0}'") puts "Preparing release #{prev_ver} => #{new_ver}" rep = GitMaintain::checkLog(opts, @local_branch, git_prev_ver, "release") if rep != "y" then puts "Skipping release" return end # Prepare tag message tag_path=`mktemp`.chomp() puts tag_path tag_file = File.open(tag_path, "w+") tag_file.puts "git-maintain-#{new_ver}" tag_file.puts "" tag_file.puts changes tag_file.close() @repo.run("cat <<EOF > CHANGELOG.new ------------------ #{new_ver} #{`date '+ (%Y-%m-%d)'`.chomp()} ------------------ $(cat CHANGELOG) EOF mv CHANGELOG.new CHANGELOG") # Add and commit @repo.runGit("add CHANGELOG") @repo.runGitInteractive("commit -F #{tag_path} --verbose --edit --signoff") if $? != 0 then raise("Failed to commit on branch #{local_branch}") end @repo.runGitInteractive("tag -a -s v#{new_ver} --edit -F #{tag_path}") if $? != 0 then raise("Failed to tag branch #{local_branch}") end `rm -f #{tag_path}` end |