Method: MSPRelease::Project::Debian#rename_dir_for_build

Defined in:
lib/msp_release/project/debian.rb

#rename_dir_for_build(branch_name, distribution) ⇒ Object



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/msp_release/project/debian.rb', line 127

def rename_dir_for_build(branch_name, distribution)
  branch_is_release_branch = !! /^release-.+$/.match(branch_name)
  new_dir = Dir.chdir(@dir) do
    if branch_is_release_branch
      first_commit_hash, commit_message =
        find_first_release_commit

      if first_commit_hash.nil?
        raise CLI::Exit, "Could not find a release commit on #{pathspec}"
      end

      clean_checkout
    else
      dev_version = Debian::Versions::Development.
        new_from_working_directory(branch_name, latest_commit_hash)

      changelog.amend(dev_version, distribution)
    end
    name + "-" + changelog.version.to_s
  end
  FileUtils.mv(@dir, new_dir)
  @dir = new_dir
end