Using Octokit to get the last commit message from a pull request

269 Views Asked by At

I am planning on using the Get() method to get the last commit of a pull request. But I am not sure how to get the reference to the commit.

Task<Commit> Get(string owner, string name, string reference);```
1

There are 1 best solutions below

0
AliZe198 On

I figured it out nevermind.

var pullRequest = await client.PullRequest.Get(owner, repo, pullRequestNumber);
var lastCommit = await client.Repository.Commit.Get(owner, repo, pullRequest.Head.Sha);
var commitMessage = lastCommit.Commit.Message;