0

From AWS CodeCommit, we can view the list of pull requests. However, it seems that we cannot display an "approver" column in the table.

https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-view-pull-request.html

How could I generate a report of pull requests with its approver(s)?

Pull Requests

Toshi
  • 145
  • 1
  • 9

2 Answers2

0

I believe there is no such an option. But you can achieve that by first getting the list of open pull requests like this:

aws codecommit list-pull-requests --pull-request-status OPEN --repository-name <REPO_NAME>

Then iterate over those pull request and run the following command to get the revision id:

aws codecommit get-pull-request \
--pull-request-id <PR_ID>

Once you have that information you can get the approvers like this:

aws codecommit get-pull-request-approval-states \
--pull-request-id <PR_ID> \
--revision-id <REVIONSION_ID>

I know, it shouldn't be that complicated.

Andres Bores
  • 212
  • 1
  • 14
0

You have to use a workaround like one below.

Use AWS CLI/SDKs: You can script a solution using AWS CLI or one of the AWS SDKs to fetch the list of pull requests and their respective approvers. This way, you can create a customized view or report for your team.

Here's a basic example using AWS CLI:

REPO_NAME="your-repo-name"

# List pull requests
pull_requests=$(aws codecommit list-pull-requests --repository-name $REPO_NAME --query "pullRequestIds" --output text)

for pr in $pull_requests; do
  # Get approval details for each pull request
  approval=$(aws codecommit get-pull-request-approval-states --pull-request-id $pr --query "approvals[?approvalState=='APPROVE'].userArn" --output text)
  echo "PR-$pr: $approval"
done

This script lists the pull requests and their respective approvers for a given repository.

Piyush Patil
  • 14,512
  • 6
  • 35
  • 54