Class: Tenma::Prepare::ReleaseBranch
- Inherits:
-
Object
- Object
- Tenma::Prepare::ReleaseBranch
- Defined in:
- lib/tenma/prepare/release_branch.rb
Constant Summary collapse
- TEMP_DIR =
"tenma-build"
Instance Method Summary collapse
- #changelog(note) ⇒ Object
- #create ⇒ Object
- #create_changelog_file(changelog) ⇒ Object
-
#initialize(context) ⇒ ReleaseBranch
constructor
A new instance of ReleaseBranch.
Constructor Details
#initialize(context) ⇒ ReleaseBranch
Returns a new instance of ReleaseBranch.
11 12 13 |
# File 'lib/tenma/prepare/release_branch.rb', line 11 def initialize(context) @context = context end |
Instance Method Details
#changelog(note) ⇒ Object
46 47 48 49 50 |
# File 'lib/tenma/prepare/release_branch.rb', line 46 def changelog(note) return '' if note.nil? ERB.new(note).result(binding) end |
#create ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/tenma/prepare/release_branch.rb', line 15 def create @workdir = Dir.mktmpdir git = Git.clone(repo_url, TEMP_DIR, path: @workdir, depth: 1, branch: base_branch) git.branch(release_branch).checkout File.write(version_file, @context..raw.version) git.add(version_file) git.commit("version++") changelogs = @context.config.raw.release_branch&.changelogs changelogs&.each do |changelog| file = create_changelog_file(changelog) git.add(file) git.commit("Add changelog to #{changelog.path}") end git.push(git.remote("origin"), release_branch) end |
#create_changelog_file(changelog) ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/tenma/prepare/release_branch.rb', line 35 def create_changelog_file(changelog) FileUtils::mkdir_p(File.join(@workdir, TEMP_DIR, changelog.path)) file = changelog_file(changelog.path) File.open(file, 'w') do |file| file.puts changelog(changelog.body) end return file end |