Mithrandir
Mithrandir

Reputation: 70

How to show the reviewer/approver of a pull request in Git (using GitBash)

I am currently trying to automate a logfile that gets created at the end of a Job build in Jenkins. On completion of the job - this logfile will show the git log of the repo which the jenkins job is running off of (Jenkins job is a pipeline script from GitHub). I want to be able to log the reviewers of the code that the jenkins job is running off of. Preferably, the source code should be the result of a pull request that was reviewed by someone else. This is exactly what the logfile should reflect (who committed the code/who reviewed the pull request/was the code a part of a pull request etc.)

I am getting stuck when trying to find who the reviewer of the code was. I know the Pull Request feature is inherently a GitHub functionality but I was wondering if there is a way to show this in the GitBash terminal.

git log --show-signature only shows the committer and not the reviewer of the code.

I expect something like:

commit: askjhkghjfdgdu37237f8327gf

Author: dev <[email protected]>

Reviewer: reviewer <[email protected]>

Date: Fri Sep 2 14:08:45 2019 -0400

Update file.groovy

Upvotes: 2

Views: 2240

Answers (1)

knittl
knittl

Reputation: 265191

No, this is not stored in Git history. As you have mentioned, pull requests are specific to GitHub and live one layer above the Git repository. Unless you have somehow customized your GitHub to automatically add this information to merge commits (e.g. as text), it will not be available in the Git history.

However, if you depend on this information at all costs, you could somehow script this with e.g. curl to extract this information from GitHub.

Depending on your use-case, the person who committed the merge/approved the PR is identical to the person who reviewed the PR, so the author/committer of the merge commit might be close enough to what you are looking for.

Upvotes: 5

Related Questions