-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
Type: BugSomething isn't working as documentedSomething isn't working as documentedType: SupportAny questions, information, or general needs around the SDK or GitHub APIsAny questions, information, or general needs around the SDK or GitHub APIs
Description
What happened?
I'd like to delete multiple files within one commit, so was constructing a tree with multiple objects with a null sha, as per documentation. I get an API error Must supply either tree.sha or tree.content. Request will be rejected if both are present.. When I run an identical API request via Postmark with sha set to null, it succeeds in creating the tree. When I run the request with sha not present, I see that API error.
I imagine its something in the serializer stripping out null fields, when in this case I would like them to be preserved.
I can't use the client.Repository.Content.DeleteFile api, as that creates a new commit for every file you delete.
Example failing code below.
var toDelete = new List<string>() { "file1", "file2" };
var repository = await client.Repository.Get("ORGID", "REPONAME");
var headOfDefault = await client.Git.Reference.Get(repository.Id, $"heads/{repository.DefaultBranch}");
var tree = new NewTree() {
BaseTree = headOfDefault.Object.Sha
};
foreach (var file in toDelete) {
tree.Tree.Add(
new NewTreeItem()
{
Type = TreeType.Blob,
Mode = FileMode.File,
Path = file
Sha = null
});
}
var newTree = await client Git.Tree.Create(repository.Id, tree);
Versions
Octokit 9.0.0 running on net6.0
Relevant log output
No response
Code of Conduct
- I agree to follow this project's Code of Conduct
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Type: BugSomething isn't working as documentedSomething isn't working as documentedType: SupportAny questions, information, or general needs around the SDK or GitHub APIsAny questions, information, or general needs around the SDK or GitHub APIs
Type
Projects
Status
🔥 Backlog