Connector Improvement: Github: Add branch name for commits
Context:
We want to be running some analysis on our github data. In particular, we want to be able to analyse various pull request level metrics such as the lead time, the size of a PR or it's complexity. To do so, we need to be able to traverse all the commits for a PR. This can not be done at the moment with the data model exposed.
Problem:
As seen on the data model here https://docs.google.com/presentation/d/1lx6ez7-x-s-n2JCnCi3SjG4XMmx9ysNUvaNCaWc3I_I/edit , you can:
- Find the head commit for a pull request
- For each commit, locate the parent commits
- traverse the graph until you reach the base commit for a pull request
However, in case of a merge commit (ex: Merge branch main into my branch), it will have 2 parents:
- The previous commit in the branch
- The commit from main that was merged into your branch
=> there is no way to only get the commits of the branch, you end up with commits from main too. It is therefore not possible to calculate the size of your PR.
Proposed solution:
Assuming the connector is using the github commits API (https://docs.github.com/en/rest/reference/repos#list-commits--code-samples ), it can extract the branch name for each commit quite easily:
[...]
"tree": {
"url": "https://api.github.com/repos/octocat/Hello-World/tree/6dcb09b5b57875f334f61aebed695e2e4193db5e ",
"sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e"
},
[...]
"tree": {
"url": "https://api.github.com/repos/
"sha": "6dcb09b5b57875f334f61aebed69
},
[...]
Right now I suspect the connector is only extracting the sha. It would need to extract the branch name too from the URL parameter, in that case "Hello-World". Or provide the whole URL. It can then be made available in the "commits" table.
Please sign in to leave a comment.
Comments
0 comments