Class: Geet::Services::MergePr
- Inherits:
-
Object
- Object
- Geet::Services::MergePr
- Includes:
- Helpers::ServicesWorkflowHelper, Geet::Shared
- Defined in:
- lib/geet/services/merge_pr.rb
Overview
Merges the PR for the current branch.
The workflow of this services is oriented to the a commondline usage: the user doesn’t need to lookup the merge for the working branch; this comes at the cost of extra operations and constraints, but speeds up the workflow.
Constant Summary collapse
Instance Method Summary collapse
- #execute(delete_branch: false) ⇒ Object
-
#initialize(repository, out: $stdout, git_client: DEFAULT_GIT_CLIENT) ⇒ MergePr
constructor
A new instance of MergePr.
Methods included from Helpers::ServicesWorkflowHelper
#checked_find_branch_pr, #find_merge_head
Constructor Details
#initialize(repository, out: $stdout, git_client: DEFAULT_GIT_CLIENT) ⇒ MergePr
Returns a new instance of MergePr.
19 20 21 22 23 |
# File 'lib/geet/services/merge_pr.rb', line 19 def initialize(repository, out: $stdout, git_client: DEFAULT_GIT_CLIENT) @repository = repository @out = out @git_client = git_client end |
Instance Method Details
#execute(delete_branch: false) ⇒ 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 51 52 53 |
# File 'lib/geet/services/merge_pr.rb', line 25 def execute(delete_branch: false) merge_owner, merge_head = find_merge_head pr = checked_find_branch_pr(merge_owner, merge_head) merge_pr(pr) if delete_branch branch = @git_client.current_branch delete_remote_branch(branch) end fetch_repository if upstream_branch_gone? pr_branch = @git_client.current_branch main_branch = @git_client.main_branch # The rebase could also be placed after the branch deletion. There are pros/cons; # currently, it's not important. # checkout_branch(main_branch) rebase delete_local_branch(pr_branch) end pr end |