Reputation: 1929
Is there a clear way to change file permissions with GitHub APIs (v3). This is a rare use case, but we have a reason. We couldn't find a one, any pointers would be helpful.
Thanks
Upvotes: 1
Views: 223
Reputation: 164809
While the V3 API has ways to update a file, there doesn't appear to be a way to change its permissions in a simple way.
File permissions are stored in the tree object (basically a directory), and V3 allows you direct access to the underlying objects. You can, conceivably, get the tree object holding the correct blob (file) and replace it with a new tree object with your changed permissions.
Github has also introduced its new V4 GraphQL API which has more extensive access to the repository, but requires understanding GraphQL. Again you can find the correct Tree and TreeEntry and create a new Tree and TreeEntry with the new mode.
While GraphQL is very powerful and worth learning if you're going to do a lot of work with the Github API, it might be simpler to just clone the repo and do it with Git.
Upvotes: 1