{"action":"created","issue":{"url":"https://api.github.com/repos/octokit/rest.js/issues/509","repository_url":"https://api.github.com/repos/octokit/rest.js","labels_url":"https://api.github.com/repos/octokit/rest.js/issues/509/labels{/name}","comments_url":"https://api.github.com/repos/octokit/rest.js/issues/509/comments","events_url":"https://api.github.com/repos/octokit/rest.js/issues/509/events","html_url":"https://github.com/octokit/rest.js/issues/509","id":209797202,"node_id":"MDU6SXNzdWUyMDk3OTcyMDI=","number":509,"title":"Pushing multiple files to a repo","user":{"login":"Nnoromuche","id":6270858,"node_id":"MDQ6VXNlcjYyNzA4NTg=","avatar_url":"https://avatars1.githubusercontent.com/u/6270858?v=4","gravatar_id":"","url":"https://api.github.com/users/Nnoromuche","html_url":"https://github.com/Nnoromuche","followers_url":"https://api.github.com/users/Nnoromuche/followers","following_url":"https://api.github.com/users/Nnoromuche/following{/other_user}","gists_url":"https://api.github.com/users/Nnoromuche/gists{/gist_id}","starred_url":"https://api.github.com/users/Nnoromuche/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nnoromuche/subscriptions","organizations_url":"https://api.github.com/users/Nnoromuche/orgs","repos_url":"https://api.github.com/users/Nnoromuche/repos","events_url":"https://api.github.com/users/Nnoromuche/events{/privacy}","received_events_url":"https://api.github.com/users/Nnoromuche/received_events","type":"User","site_admin":false},"labels":[{"id":1123075562,"node_id":"MDU6TGFiZWwxMTIzMDc1NTYy","url":"https://api.github.com/repos/octokit/rest.js/labels/plugin","name":"plugin","color":"111111","default":false},{"id":736976101,"node_id":"MDU6TGFiZWw3MzY5NzYxMDE=","url":"https://api.github.com/repos/octokit/rest.js/labels/question","name":"question","color":"111111","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":18,"created_at":"2017-02-23T15:38:56Z","updated_at":"2018-12-13T22:47:57Z","closed_at":"2018-12-13T22:47:57Z","author_association":"NONE","body":"Hi, so I am building a web application with an on browser code editor and I thought to integrate with Github to enable concurrent programming. \r\n\r\nHere are my two questions please:\r\n1) Inorder to push multiple files at once to a repo do I use the createFile method multiple times?  \r\n2) I have been able to do a pull using the ‘repos.getContent’ method, however, how do I sync the new changes into the current working file of the web editor application, essentially simulating a desktop file management system? \r\n\r\nPlease could you kindly advice in terms of suitable Api architecture, Thank you.\r\n\r\nKindly find below my push function which is having referencing issues: \r\nrefs/heads/master is at b100befe9ba8ec023a47a40b2363bf545fc6c65a but expected 8e8a2614f866370bc89486e2691194962883fdc7\r\n\r\n```\r\napp.post('/GITPUSH/GIT', function(req, res) {\r\n          for(var i=0;i<req.body.project.length;i++){\r\n          var formattedText = new Buffer(req.body.project[i].code).toString('base64');\r\n          var name = req.body.project[i].title;\r\n            client.repos.getContent({\r\n                    owner:'Nnoromuche',\r\n                    repo:'test',\r\n                    path: name\r\n                },function(err, result){\r\n                    if(err){  \r\n                            client.repos.createFile({\r\n                                owner:'Nnoromuche',\r\n                                repo:'test',\r\n                                path:name,\r\n                                message: 'A file',\r\n                                content: formattedText\r\n                           },function(err, res1){                            \r\n                               if(err){\r\n                                    console.log(JSON.stringify(err));\r\n                               }else \r\n                                 console.log(JSON.stringify(res1));\r\n                            });        \r\n                    } else {                     \r\n                           client.repos.updateFile({\r\n                                owner:'Nnoromuche',\r\n                                repo:'test',\r\n                                path: name,\r\n                                message: 'Updating content',\r\n                                content: formattedText,\r\n                                sha: result.data.sha\r\n                            },function(err, res2){\r\n                                if(err){\r\n                                    console.log(JSON.stringify(err));\r\n                                }else\r\n                                console.log(JSON.stringify(res2));\r\n                            });\r\n                    };\r\n                });   \r\n        }\r\n});\r\n\r\n```\r\n\r\n// =====================================\r\nNote: req.body.project = [{ title:'Hello.js’, \r\n        code: 'console.log(“hello world\");'},\r\n        { title:'index.js', \r\n        code: 'console.log(“index world\");’}]\r\n// ====================================="},"comment":{"url":"https://api.github.com/repos/octokit/rest.js/issues/comments/447149274","html_url":"https://github.com/octokit/rest.js/issues/509#issuecomment-447149274","issue_url":"https://api.github.com/repos/octokit/rest.js/issues/509","id":447149274,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0NzE0OTI3NA==","user":{"login":"gr2m","id":39992,"node_id":"MDQ6VXNlcjM5OTky","avatar_url":"https://avatars3.githubusercontent.com/u/39992?v=4","gravatar_id":"","url":"https://api.github.com/users/gr2m","html_url":"https://github.com/gr2m","followers_url":"https://api.github.com/users/gr2m/followers","following_url":"https://api.github.com/users/gr2m/following{/other_user}","gists_url":"https://api.github.com/users/gr2m/gists{/gist_id}","starred_url":"https://api.github.com/users/gr2m/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gr2m/subscriptions","organizations_url":"https://api.github.com/users/gr2m/orgs","repos_url":"https://api.github.com/users/gr2m/repos","events_url":"https://api.github.com/users/gr2m/events{/privacy}","received_events_url":"https://api.github.com/users/gr2m/received_events","type":"User","site_admin":false},"created_at":"2018-12-13T22:47:57Z","updated_at":"2018-12-13T22:47:57Z","author_association":"COLLABORATOR","body":"I figured out how to delete: you have to skip the `base_tree` parameter and pass in the _entire_ tree 0_o every item that is left out is considered deleted.\r\n\r\nGood news is I created a plugin that should make it easier to create a pull request with multiple file changes, please give it a try and let me know what you think! Some features are still missing, pull requests welcome :)\r\n\r\nhttps://github.com/gr2m/octokit-create-pull-request\r\n\r\nAnd with that I think we can close this issue 🎉 "}}
{"actor":{"display_login":"gr2m"}}