Guest User

Untitled

a guest
Apr 24th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. function getRepositoryContents(arg,cb){
  2. let masterTreeSHA;
  3. getLatestMasterTreeSha(arg,(master)=>{
  4.  
  5. masterTreeSHA = master['commit']['commit']['tree']['sha'];
  6. let options = {
  7. method:"GET",
  8. url: arg.baseRepoApiUrl+'/git/trees/'+masterTreeSHA+'?recursive=1',
  9. headers: {
  10. 'Authorization': arg.keyStr
  11. }
  12. };
  13. request(options, (error, response, body) =>{
  14. if(!error){
  15. cb(JSON.parse(body));
  16. }else {
  17. console.log("can't fetch latest tree ")
  18. }
  19. });
  20. });
  21. }
  22.  
  23. function getLatestMasterTreeSha(arg, cb){
  24. let options = {
  25. method:"GET",
  26. url: arg.baseRepoApiUrl+'/branches/master',
  27. headers: {
  28. 'Authorization': arg.keyStr
  29. }
  30. };
  31. request(options, (error, response, body) =>{
  32. if(!error){
  33. cb(JSON.parse(body));
  34. }else {
  35. console.log("can't fetch latest master commit ")
  36. }
  37. });
  38. }
Add Comment
Please, Sign In to add comment