Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 2
Message 1 of 6

How to get two dot diff from Github API

Solved! Go to Solution.

Hello,

From this: https://help.github.com/articles/about-comparing-branches-in-pull-requests/#three-dot-and-two-dot-gi...

We are wondering if there is an api to get the two dot diff from two commits. 

 

Thanks!

5 Replies
Community Manager
Message 2 of 6

Re: How to get two dot diff from Github API

Hi @aTonyXiao,

 

Thanks for being here! Check out the documentation on comparing commits across time.

 

I hope this helps!

 

Thanks for being here, sharing, and keeping our community awesome!
Best,
AndreaG

Mark helpful posts with Accept as Solution to help other users locate important info. Don't forget to give Kudos for great content!

Copilot Lvl 2
Message 3 of 6

Re: How to get two dot diff from Github API

Hi @AndreaGriffiths11,

 

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 

4eff613a6c96579d11dad72e63200b74afc39433 and 2b58c5f5c142588b7b944f3b79a0371378da3db6

The API gives: https://api.github.com/repos/python/mypy/compare/4eff613a6c96579d11dad72e63200b74afc39433...2b58c5f5...

Which is the same as three dot diff on:

https://github.com/python/mypy/compare/4eff613a6c96579d11dad72e63200b74afc39433...2b58c5f5c142588b7b...

but we wonder if we can get this through API

https://github.com/python/mypy/compare/4eff613a6c96579d11dad72e63200b74afc39433..2b58c5f5c142588b7b9...

 

Thanks!

 

Solution
Community Manager
Message 4 of 6

Re: How to get two dot diff from Github API

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!

 

Thanks for being here, sharing, and keeping our community awesome!
Best,
AndreaG

Mark helpful posts with Accept as Solution to help other users locate important info. Don't forget to give Kudos for great content!

Copilot Lvl 3
Message 5 of 6

Re: How to get two dot diff from Github API

@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)?

Copilot Lvl 2
Message 6 of 6

Re: How to get two dot diff from Github API

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