How to get two dot diff from Github API #24877
-
Hello, We are wondering if there is an api to get the two dot diff from two commits. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments
-
Hi @atonyxiao, Thanks for being here! Check out the documentation on comparing commits across time. I hope this helps! |
Beta Was this translation helpful? Give feedback.
-
Thanks for the reply. We read the documentation and find it cannot solve our problem. Here is an example: We want to compare two commits with sha
The API gives: https://api.github.com/repos/python/mypy/compare/4eff613a6c96579d11dad72e63200b74afc39433…2b58c5f5c142588b7b944f3b79a0371378da3db6 Which is the same as three dot diff on: but we wonder if we can get this through API Thanks! |
Beta Was this translation helpful? Give feedback.
-
Hi @atonyxiao, Thank you for taking the time to write back with more information. Unfortunately, there’s no way to do that with the GitHub REST API – you can’t pick which information will be returned. One option would be to pull each commit via the API or Git and then do a two-dot diff locally. I hope this helps! |
Beta Was this translation helpful? Give feedback.
-
@andreagriffiths11 is it accurate to say there’s no way with the API (or with a single request) to get the actual diff of a forced push (i.e. compare old head with new head)? |
Beta Was this translation helpful? Give feedback.
-
Surprised to see that go unanswered. Edit: I had added an additional question which also went unanswered so I’ll answer it myself. I asked: On the web, is there a way to diff this by version and all of .27 to .28? https://github.com/alpacahq/pylivetrader Yes: https://github.com/alpacahq/pylivetrader/compare/v0.0.27…v0.0.28?expand=0 or https://github.com/alpacahq/pylivetrader/compare/v0.0.27…v0.0.28?expand=0 … or with expand=1 |
Beta Was this translation helpful? Give feedback.
-
@chrisdothtmldid you come up with any alternatives to get the actual diff of a forced push? That was exactly my use case as well, and I can’t find a good way to do it (without an order of magnitude increase in API calls) Thanks! |
Beta Was this translation helpful? Give feedback.
-
Not really. Depending on your use-case there are different approaches you can take. For example, if you need to know the net change of an entire pull request after a force push, you can just compare the base branch with the head branch. I may be able to help more if you give a bit more info on why you need this as I spent quite a lot of time around this particular issue |
Beta Was this translation helpful? Give feedback.
Hi @atonyxiao,
Thank you for taking the time to write back with more information. Unfortunately, there’s no way to do that with the GitHub REST API – you can’t pick which information will be returned. One option would be to pull each commit via the API or Git and then do a two-dot diff locally.
I hope this helps!