Class: CollavreGithub::Tools::GithubPrCommitsService

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

Instance Method Summary collapse

Instance Method Details

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



25
26
27
28
29
30
31
32
33
34
# File 'app/services/collavre_github/tools/github_pr_commits_service.rb', line 25

def call(creative_id:, repo:, pr_number:)
  with_github_client(creative_id: creative_id, repo: repo, error_context: "fetch PR commits") do |client|
    messages = client.pull_request_commit_messages(repo, pr_number)

    {
      commits: messages.map.with_index(1) { |msg, i| { index: i, message: msg } },
      count: messages.size
    }
  end
end