We use GitHub Enterprise for our internal code base. A common issue that we face across teams is the "pull-request review turnaround time" can sometimes be a few "physical days" (many ideal hours).
We're tweaking some engineering practices to prevent PRs from being unnecessarily large and allow for faster turnaround times on reviews. However, I couldn't find anything to help accurately track how long PRs were open before they were merged.
We'd like to use objective metrics to validate some of our approaches to see if we make meaningful differences to the review times and "open-PR duration till merging" is an important metric to track.
Does git/GitHub have anything that could help obtain such metrics? I tried looking but nothing shows up anywhere.
You can also find pull requests that you've been asked to review. At the top of any page, click Pull requests or Issues. Optionally, choose a filter or use the search bar to filter for more specific results.
A study of a Cisco Systems programming team revealed that a review of 200-400 LOC over 60 to 90 minutes should yield 70-90% defect discovery. With this number in mind, a good pull request should not have more than 250 lines of code changed.
The GitHub Repository Statistics API endpoint is located at https://api.github.com/repos/:owner/:repo/stats/. You can find the GitHub portal / hompage here.
In GitHub Desktop, click Current Branch. At the top of the drop-down menu, click Pull Requests. In the list of pull requests, click the pull request you want to view.
The graphQL API of GitHub could help you to get pull requests metadata such as when the PR has been created (createdAt) and when it have been merged (mergedAt) https://developer.github.com/v4/object/pullrequest/ You could search all pull request with the search query https://developer.github.com/v4/query/#connections then compute the time to merge.
Also you might be interested in this tool https://github.com/change-metrics/monocle as it provides Pull Request metrics for GitHub repositories. Among other various metrics the tools computes the "Mean time to merge" metrics. Thanks to the filters you could set, you could get the mean time to merge for the whole GitHub organization, a specific repository, or developer, or a group of developers.
You can use the Github Rest Api to get the details. I have added an example with a sample repo. I think for enterprise editions you have to access the repo information using tokens (https://github.com/settings/tokens). In that case the request uri will be
https://api.github.com/repos/srajagop/page-test/pulls?token=xxxxxxxxxxxxxxxxx
for example
async function timeElapsed(){
let response = await fetch('https://api.github.com/repos/srajagop/page-test/pulls');
let jsonData = await response.json();
let diff = new Date().getTime() - new Date(Date.parse('2019-04-26T05:56:33Z')).getTime();
let hoursElapsed = Math.ceil(diff / (1000 * 60 * 60));
return hoursElapsed;
}
timeElapsed().then(data => console.log("Hours elapsed", data));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With