Class: CollavreGithub::Tools::GithubPrDetailsService

Inherits:
Object
  • Object
show all
Extended by:
T::Sig, ToolMeta
Includes:
Concerns::GithubClientFinder
Defined in:
app/services/collavre_github/tools/github_pr_details_service.rb

Instance Method Summary collapse

Instance Method Details

#call(creative_id:, repo:, pr_number:) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/services/collavre_github/tools/github_pr_details_service.rb', line 24

def call(creative_id:, repo:, pr_number:)
  with_github_client(creative_id: creative_id, repo: repo, error_context: "fetch PR details") do |client|
    pr = client.pull_request_details(repo, pr_number)
    return { error: "Pull request not found" } unless pr

    {
      number: pr.number,
      title: pr.title,
      body: pr.body.to_s.truncate(2000),
      state: pr.state,
      merged: pr.merged,
      author: pr.user&.,
      created_at: pr.created_at&.iso8601,
      updated_at: pr.updated_at&.iso8601,
      merged_at: pr.merged_at&.iso8601,
      additions: pr.additions,
      deletions: pr.deletions,
      changed_files: pr.changed_files,
      html_url: pr.html_url,
      base_branch: pr.base&.ref,
      head_branch: pr.head&.ref
    }
  end
end