Get github commits on all branches from API
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

Objective:

  • a single or set of curl commands that hits the github api (v3) that will list every commit of a repository REGARDLESS of the branch the commit was on
  • needs to support the 'since' parameter, i.e. give me all commits from all branches since a particular timestamp
def willing to tip!
aleemstreak almost 7 years ago
@aleemstreak: In which language do you need this?
alixaxel almost 7 years ago
i would prefer just a series of CURL commands I can type into the terminal, but if you want to use one of their libraries then use the java github libs
aleemstreak almost 7 years ago
awarded to weslly
Tags
git

Crowdsource coding tasks.

1 Solution


for line in `curl "https://api.github.com/repos/:user/:repo/branches" | grep -o '"name":.*,' | sed 's/"name": "//g' | sed 's/",//g'`; do; curl "https://api.github.com/repos/:user/:repo/commits?sha=$line" >> result.json ; done;

With since parameter:

for line in `curl "https://api.github.com/repos/:user/:repo/branches" | grep -o '"name":.*,' | sed 's/"name": "//g' | sed 's/",//g'`; do; curl "https://api.github.com/repos/:user/:repo/commits?sha=$line&since=2013-01-13" >> result.json ; done;
I don't think this gets commits across all branches of a repository.
aleemstreak almost 7 years ago
Updated :)
weslly almost 7 years ago
Going to award this answer but if you have a java version that uses the github java library, I'll tip an extra $5!
aleemstreak almost 7 years ago
Ok, I'll do it :)
weslly almost 7 years ago
how do you specifiy the since param?
aleemstreak almost 7 years ago
I didn't find how to do this with the java library but probably it should work if you append a &since= GET parameter after brc.getName() at line 23
weslly almost 7 years ago
awesome thanks!
aleemstreak almost 7 years ago
View Timeline