Class: Decidim::GitBackportManager
- Inherits:
-
Object
- Object
- Decidim::GitBackportManager
- Defined in:
- lib/decidim/git_backport_manager.rb
Overview
Handles the backport of a given pull request to a branch Uses the git commnad line client
Class Method Summary collapse
-
.checkout_develop ⇒ void
Switch to the develop branch In case that it cannot do that, exits.
Instance Method Summary collapse
-
#call ⇒ void
Handles all the different tasks involved on a backport with the git command line utility It does the following tasks: * Creates a branch based on a release branch * Apply a commit to this branch * Push it to the remote repository.
-
#initialize(pull_request_id:, release_branch:, backport_branch:, working_dir: Dir.pwd, exit_with_unstaged_changes: false) ⇒ GitBackportManager
constructor
A new instance of GitBackportManager.
Constructor Details
#initialize(pull_request_id:, release_branch:, backport_branch:, working_dir: Dir.pwd, exit_with_unstaged_changes: false) ⇒ GitBackportManager
Returns a new instance of GitBackportManager.
15 16 17 18 19 20 21 |
# File 'lib/decidim/git_backport_manager.rb', line 15 def initialize(pull_request_id:, release_branch:, backport_branch:, working_dir: Dir.pwd, exit_with_unstaged_changes: false) @pull_request_id = pull_request_id @release_branch = release_branch @backport_branch = sanitize_branch(backport_branch) @working_dir = working_dir @exit_with_unstaged_changes = exit_with_unstaged_changes end |
Class Method Details
.checkout_develop ⇒ void
This method returns an undefined value.
Switch to the develop branch In case that it cannot do that, exits
53 54 55 56 57 58 59 60 61 |
# File 'lib/decidim/git_backport_manager.rb', line 53 def self.checkout_develop `git checkout develop` = <<-EOERROR Could not checkout the develop branch. Please make sure you do not have any uncommitted changes in the current branch. EOERROR exit_with_errors() unless $CHILD_STATUS.exitstatus.zero? end |
Instance Method Details
#call ⇒ void
This method returns an undefined value.
Handles all the different tasks involved on a backport with the git command line utility It does the following tasks:
-
Creates a branch based on a release branch
-
Apply a commit to this branch
-
Push it to the remote repository
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/decidim/git_backport_manager.rb', line 30 def call Dir.chdir(working_dir) do exit_if_unstaged_changes if @exit_with_unstaged_changes self.class.checkout_develop sha_commit = sha_commit_to_backport = <<-EOERROR Could not find commit for pull request #{pull_request_id}. Please make sure you have pulled the latest changes. EOERROR exit_with_errors() unless sha_commit create_backport_branch! cherrypick_commit!(sha_commit) push_backport_branch! end end |