Class: GitMaintain::RDMACoreBranch
- Defined in:
- lib/addons/RDMACore.rb
Constant Summary collapse
- REPO_NAME =
"rdma-core"
- AZURE_MIN_VERSION =
18
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
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Branch
#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, #steal
Constructor Details
This class inherits a constructor from GitMaintain::Branch
Class Method Details
.check_opts(opts) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/addons/RDMACore.rb', line 17 def self.check_opts(opts) if opts[:action] == :release then case opts[:rel_type] when nil raise "No release type specified use --stable or --major" when :major if opts[:manual_branch] == nil then GitMaintain::log(:INFO, "Major release selected. Auto-forcing branch to master") opts[:manual_branch] = "master" end end end end |
.set_opts(action, optsParser, opts) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/addons/RDMACore.rb', line 6 def self.set_opts(action, optsParser, opts) opts[:rel_type] = nil case action when :release optsParser.on("--major", "Release a major version.") { opts[:rel_type] = :major } optsParser.on("--stable", "Release a stable version.") { opts[:rel_type] = :stable } end end |
Instance Method Details
#release(opts) ⇒ Object
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 56 57 58 59 60 61 62 63 64 65 66 67 68 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 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/addons/RDMACore.rb', line 30 def release(opts) prev_ver=@repo.runGit("show HEAD:CMakeLists.txt | egrep \"[sS][eE][tT]\\\\(PACKAGE_VERSION\""). chomp().gsub(/[sS][eE][tT]\(PACKAGE_VERSION\s*"([0-9.]*)".*$/, '\1') ver_nums = prev_ver.split(".") new_ver = (ver_nums[0 .. -2] + [ver_nums[-1].to_i() + 1 ]).join(".") rel_ver = new_ver commit_msg = "Bump to version" if opts[:rel_type] == :major new_ver = ([ ver_nums[0].to_i() + 1] + ver_nums[1 .. -1]).join(".") rel_ver = prev_ver prev_ver = ([ ver_nums[0].to_i() - 1] + ver_nums[1 .. -1]).join(".") ver_nums = prev_ver.split(".") commit_msg ="Update library version to be" end git_prev_ver = "v" + prev_ver # Older tags might do have the terminal minor version (.0) for major releases @repo.runGit("rev-parse --verify --quiet #{git_prev_ver}") if $? != 0 then # Try without the minor version number git_prev_ver = "v" + ver_nums[0 .. -2].join(".") end puts "Preparing #{opts[:rel_type].to_s} release #{prev_ver} => #{rel_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 "rdma-core-#{rel_ver}:" tag_file.puts "" tag_file.puts "Updates from version #{prev_ver}" if opts[:rel_type] == :stable then tag_file.puts " * Backport fixes:" end tag_file.puts `git log HEAD ^#{git_prev_ver} --no-merges --format=' * %s'` tag_file.close() edit_flag = "" edit_flag = "--edit" if opts[:no_edit] == false if opts[:rel_type] == :major # For major, tag the current version first @repo.runGitInteractive("tag -a -s v#{rel_ver} #{edit_flag} -F #{tag_path}") if $? != 0 then raise("Failed to tag branch #{local_branch}") end end # Update version number in relevant files @repo.run("sed -i -e 's/\\(Version:[[:space:]]*\\)[0-9.]\\+/\\1#{new_ver}/g' */*.spec") @repo.run("sed -i -e 's/\\([sS][eE][tT](PACKAGE_VERSION[[:space:]]*\"\\)[0-9.]*\"/\\1#{new_ver}\"/g' CMakeLists.txt") case opts[:rel_type] when :stable @repo.run("cat <<EOF > debian/changelog.new rdma-core (#{new_ver}-1) unstable; urgency=low * New upstream release. -- $(git config user.name) <$(git config user.email)> $(date '+%a, %d %b %Y %T %z') $(cat debian/changelog) EOF mv debian/changelog.new debian/changelog") when :major @repo.run("sed -i -e 's/^rdma-core (#{rel_ver}-1)/rdma-core (#{new_ver}-1)/' debian/changelog") end # Add and commit @repo.runGit("add */*.spec CMakeLists.txt debian/changelog") @repo.runGitInteractive("commit -m '#{commit_msg} #{new_ver}' --verbose #{edit_flag} --signoff") if $? != 0 then raise("Failed to commit on branch #{local_branch}") end if opts[:rel_type] == :stable @repo.runGitInteractive("tag -a -s v#{rel_ver} #{edit_flag} -F #{tag_path}") if $? != 0 then raise("Failed to tag branch #{local_branch}") end end `rm -f #{tag_path}` end |