json - How do I get the SHA of the latest commit on a GitHub repository via jQuery? -


i've been @ several hours , have yet find useful information anywhere. i'm trying use jquery latest commit of github repository single user show on homepage. currently, have:

$.getjson("https://api.github.com/users/theinfection/repos", function(data) {         $(".lastcommit").html('<a href="https://github.com/theinfection/' + data[0].name + '/commit/' + data[0].sha + '">text</a>'); }); 

that outputs link: https://github.com/theinfection/blue-monday-hd/commit/undefined. sort of works shows latest commit of first repo listed in json file , doesn't sha of said commit.

now, want know is:

  • how sha of commits?
  • how sort commits in chronological order latest @ top?
  • how commit comment text?

this has been bothering me while appreciated!

would help?

$.getjson("https://api.github.com/users/theinfection/repos", function(data) {     $.getjson(data[0].commits_url.slice(0, -6), function(data) {         $('.lastcommit').text(data[0].sha);     }); }); 

in initial request repos, take repo want , it's commits. of course, if know repo name already, can call:

var repo = 'theinfection/blue-monday-hd'; $.getjson("https://api.github.com/repos/" + repo + "/commits", function(data) {     $('.lastcommit').text(data[0].sha); }); 

the list sorted in reverse-chronological order , message , author there: data[0].commit.message , data[0].commit.committer.name.

play on jsfiddle


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -