A base package will offer the statistic to display for other apps. A blazor app and a console app are offered as examples. They will call the package which then calls the github api to query the branch statistics.
Data from the book "Accelerate" and "State of DevOps Report" have shown that consistently merging code to trunk (repository main branch) multiple times a day delivers high performance in technology organizations.
https://techbeacon.com/app-dev-testing/how-trunk-based-delivery-key-faster-more-reliable-software
At the time of writing I have not found any library which offers to measure the amount of time spent developing on non-trunk branches. Measuring the lifespan of your organisation's feature branches will give insight into:
- the state of software delivery in general
- the average batch size being delivered
- the average lead time to deliver a feature
There is no branch creation date in github as a branch is merely a pointer to a commit. So the most sane thing I came up with was the oldest commit on a branch.
https://api.github.com/repos/markus-codechefs/github-branch-lifetime/pulls
- Uses the MergedAt date as the end date of the measurement.
https://api.github.com/repos/{org}/{repo}/pulls/{PR.Number}/commits
- Uses CreatedAt of the oldest commit on a branch for the start of the measurement.
Released under MIT by @markus-codechefs.