danvk
danvk

Reputation: 16955

Is it possible to get the diff for just one file using the github API?

Using the github API's compare endpoint, I can request the unified diff between two commits:

curl -H 'Accept: application/vnd.github.3.diff' \
'https://api.github.com/repos/danvk/dygraphs/compare/01275da4...335011f'

Using the git command line tool, I can filter that diff to just a single file:

git diff 01275da4..335011f dygraph.js

Is there any way to do this with the github API? I realize that I can filter down to just that diff as a post-processing step, but this could run into API restrictions if the diff contains a large file in addition to a small file.

Upvotes: 4

Views: 1410

Answers (1)

random
random

Reputation: 9955

Can't be done with the current version (3) of the GitHub API.

You will have to deal with the mix of files until they add a parameter (much like how Listing method has the path flag) that allows you to specify what file to limit the view/compare commit method.

Upvotes: 1

Related Questions