Class: Roger::Release::Finalizers::GitBranch
- Inherits:
-
Base
- Object
- Processors::Base
- Base
- Roger::Release::Finalizers::GitBranch
- Defined in:
- lib/roger/release/finalizers/git_branch.rb
Overview
Finalizes the release into a specific branch of a repository and pushes it
Instance Attribute Summary
Attributes inherited from Processors::Base
Instance Method Summary collapse
Methods inherited from Processors::Base
Instance Method Details
#default_options ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/roger/release/finalizers/git_branch.rb', line 16 def { remote: nil, branch: "gh-pages", cleanup: true, push: true } end |
#perform ⇒ Object
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 |
# File 'lib/roger/release/finalizers/git_branch.rb', line 25 def perform remote = find_git_remote(release.project.path) branch = @options[:branch] tmp_dir = Pathname.new(::Dir.mktmpdir) clone_dir = tmp_dir + "clone" # Check if remote already has branch if remote_has_branch?(remote, branch) release.log(self, "Cloning existing repo") clone_branch(clone_dir, remote, branch) else release.log(self, "Creating empty branch") create_empty_branch(clone_dir, remote, branch) end @release.log(self, "Working git magic in #{clone_dir}") commit_and_push_release(clone_dir, branch) if @options[:cleanup] FileUtils.rm_rf(tmp_dir) else tmp_dir end end |