diff --git a/Octokit.Tests.Integration/Clients/TreeClientTests.cs b/Octokit.Tests.Integration/Clients/TreeClientTests.cs
index ac54e69b0b..46af32db15 100644
--- a/Octokit.Tests.Integration/Clients/TreeClientTests.cs
+++ b/Octokit.Tests.Integration/Clients/TreeClientTests.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Threading.Tasks;
using Octokit;
using Octokit.Tests.Integration;
@@ -144,6 +144,26 @@ public async Task CanGetACreatedTreeWithRepositoryId()
Assert.Single(result.Tree);
}
+ [IntegrationTest]
+ public async Task CanDeleteACreatedTreeWithRepositoryId()
+ {
+ var newTree = new NewTree();
+ newTree.Tree.Add(new NewTreeItem
+ {
+ Type = TreeType.Blob,
+ Path = "README.md",
+ Sha = null,
+ Mode = FileMode.File
+ });
+
+ var tree = await _fixture.Create(_context.Repository.Id, newTree);
+
+ var result = await _fixture.Get(_context.Repository.Id, tree.Sha);
+
+ Assert.NotNull(result);
+ Assert.Empty(result.Tree);
+ }
+
public void Dispose()
{
_context.Dispose();
diff --git a/Octokit/Models/Request/NewTreeItem.cs b/Octokit/Models/Request/NewTreeItem.cs
index 738b21c546..83de6b6ff6 100644
--- a/Octokit/Models/Request/NewTreeItem.cs
+++ b/Octokit/Models/Request/NewTreeItem.cs
@@ -1,6 +1,7 @@
-using System.Diagnostics;
+using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
+using Octokit.Internal;
namespace Octokit
{
@@ -16,9 +17,9 @@ public class NewTreeItem
public string Path { get; set; }
///
- /// String of the file mode - one of 100644 for file (blob),
- /// 100755 for executable (blob), 040000 for subdirectory (tree),
- /// 160000 for submodule (commit) or
+ /// String of the file mode - one of 100644 for file (blob),
+ /// 100755 for executable (blob), 040000 for subdirectory (tree),
+ /// 160000 for submodule (commit) or
/// 120000 for a blob that specifies the path of a symlink
///
public string Mode { get; set; }
@@ -31,11 +32,12 @@ public class NewTreeItem
///
/// The SHA for this Tree item.
+ /// If both this and Content is null it will delete the item.
///
- public string Sha { get; set; }
+ [SerializeNull] public string Sha { get; set; }
///
- /// Gets or sets the content you want this file to have. GitHub will write this blob out and use that SHA
+ /// Gets or sets the content you want this file to have. GitHub will write this blob out and use that SHA
/// for this entry. Use either this, or tree.sha.
///
///
@@ -48,4 +50,4 @@ internal string DebuggerDisplay
get { return string.Format(CultureInfo.InvariantCulture, "SHA: {0}, Path: {1}, Type: {2}", Sha, Path, Type); }
}
}
-}
\ No newline at end of file
+}