Module: Geet::Helpers::ServicesWorkflowHelper

Included in:
Services::CommentPr, Services::MergePr, Services::OpenPr
Defined in:
lib/geet/helpers/services_workflow_helper.rb

Overview

Helper for services common workflow, for example, find the merge head.

Instance Method Summary collapse

Instance Method Details

#checked_find_branch_prObject

Expect to find only one.

Requires: @out, @repository.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/geet/helpers/services_workflow_helper.rb', line 16

def checked_find_branch_pr
  owner = if @repository.upstream?
    @repository.authenticated_user.username
  else
    @git_client.owner
  end

  head = @git_client.current_branch

  @out.puts "Finding PR with head (#{owner}:#{head})..."

  prs = @repository.prs(owner: owner, head: head)

  raise "Expected to find only one PR for the current branch; found: #{prs.size}" if prs.size != 1

  prs[0]
end