Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion Octokit.Tests.Integration/Clients/TreeClientTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Threading.Tasks;
using Octokit;
using Octokit.Tests.Integration;
Expand Down Expand Up @@ -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();
Expand Down
16 changes: 9 additions & 7 deletions Octokit/Models/Request/NewTreeItem.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Diagnostics;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using Octokit.Internal;

namespace Octokit
{
Expand All @@ -16,9 +17,9 @@ public class NewTreeItem
public string Path { get; set; }

/// <summary>
/// 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
/// </summary>
public string Mode { get; set; }
Expand All @@ -31,11 +32,12 @@ public class NewTreeItem

/// <summary>
/// The SHA for this Tree item.
/// If both this and Content is null it will delete the item.
/// </summary>
public string Sha { get; set; }
[SerializeNull] public string Sha { get; set; }

/// <summary>
/// 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.
/// </summary>
/// <value>
Expand All @@ -48,4 +50,4 @@ internal string DebuggerDisplay
get { return string.Format(CultureInfo.InvariantCulture, "SHA: {0}, Path: {1}, Type: {2}", Sha, Path, Type); }
}
}
}
}
Loading