github-api icon indicating copy to clipboard operation
github-api copied to clipboard

Cannot delete blob from tree

Open Cloudate9 opened this issue 3 years ago • 0 comments

Describe the bug While there is a way to create a tree (GHTreeBuilder) and to add an object to the tree (GHTreeBuilder#add), there is no clear way to remove an object (i.e. remove a file upon committing the tree + updating a ref). According to the GitHub REST api docs, one should be able to remove a file by passing in a null sha. This is not possible with GHTreeBuilder#add, as it requires a non-null content (not sha).

Is there something I'm missing here? Is that a separate method for this in the api? Note: GHRepository#getContent#delete will not suffice. That requires me to do a commit for every single file I want to delete, which is not ideal.

To Reproduce Steps to reproduce the behavior:

  1. Create a new GHTreeBuilder, with a baseTree
  2. Try to pass in a null value for content in GHTreeBuilder#add
  3. Be sad at the compile errors

Expected behavior Upon committing the tree and updating a ref, the file with a null sha passed should be deleted.

Cloudate9 avatar Jun 26 '22 06:06 Cloudate9