You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add utility methods for modifying files via the Git API #1052
Recently, I ran into a size limit with the Contents API: the blob I was trying to update exceeded 1MB. To fix this, GitHub recommends the following:
As an example, if you wanted to commit a change to a file in your repository, you would:
Get the current commit object
Retrieve the tree it points to
Retrieve the content of the blob object that tree has for that particular file path
Change the content somehow and post a new blob object with that new content, getting a blob SHA back
Post a new tree object with that file path pointer replaced with your new blob SHA getting a tree SHA back
Create a new commit object with the current commit SHA as the parent and the new tree SHA, getting a commit SHA back
Update the reference of your branch to point to the new commit SHA
It seems to me that a fairly common use of this library is to update contents of a blob. I do it in several projects (this morning, in sourcegraph/checkup). To get around the size restriction of the Contents API, the user must jump through these hoops each time. It's not ideal.
What do you think about shipping a series of utility methods which allow users to Create, Update, and Delete files using the Git API?
While the above description is fairly straightforward, it can seem complicated and overwhelming for something that is so transparent to the end user. I'd love to implement this once, in this library, and never have to think about implementing it again. 😄
Hmmm... this sounds interesting... and I've got mixed feelings. The purist in me thinks that the Git API should stay out of a GitHub API repo. The pragmatist in me thinks that this might be a handy place to have that functionality.
I'm thinking that the purist in me is winning... and that a separate "companion" repo could handle the details of the Git API.
Thoughts from other contributors or users? Let's keep this open a while for discussion.
I'd be interested in getting to a solution to this issue as well. My use case is not as complex as the above but the core issue remains the same i.e that the contents API does not support returning file contents for file sizes more than 1 MB.
My use case is to simply get content of certain files from a Git repo and stick the file into another Git repo.
I tried using the Git Data API to get the blob: https://developer.github.com/v3/git/blobs/#get-a-blob. I need the file sha to get the blob. The easy way to get SHA as far as I know is through https://developer.github.com/v3/repos/contents/#get-the-readme which does not allow file sizes more than 1 MB. Another way could be to
Get the current commit object
Retrieve the tree it points to
Retrieve the content of the blob object that tree has for that particular file path
Activity
gmlewis commentedon Nov 15, 2018
Hmmm... this sounds interesting... and I've got mixed feelings. The purist in me thinks that the Git API should stay out of a GitHub API repo. The pragmatist in me thinks that this might be a handy place to have that functionality.
I'm thinking that the purist in me is winning... and that a separate "companion" repo could handle the details of the Git API.
Thoughts from other contributors or users? Let's keep this open a while for discussion.
NeenuAVarghese commentedon Mar 30, 2020
I'd be interested in getting to a solution to this issue as well. My use case is not as complex as the above but the core issue remains the same i.e that the contents API does not support returning file contents for file sizes more than 1 MB.
My use case is to simply get content of certain files from a Git repo and stick the file into another Git repo.
I tried using the Git Data API to get the blob: https://developer.github.com/v3/git/blobs/#get-a-blob. I need the file sha to get the blob. The easy way to get SHA as far as I know is through https://developer.github.com/v3/repos/contents/#get-the-readme which does not allow file sizes more than 1 MB. Another way could be to
Any other suggestions ?
gmlewis commentedon Mar 30, 2020
Have either of you tried using go-git or go.git-scm in conjunction with this GitHub API client library?
If so, could you please post the results here (pros/cons, if it worked or not, etc.)?
alexellis commentedon Oct 20, 2020
For anyone else landing here, go-git has moved to https://github.com/go-git/go-git
gmlewis commentedon Aug 6, 2021
Closing issue for lack of activity/interest.