Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,14 @@ public interface IObservableRepositoryContentsClient
/// <param name="name">The name of the repository</param>
/// <param name="path">The path to the file</param>
/// <param name="request">Information about the file to delete</param>
IObservable<Unit> DeleteFile(string owner, string name, string path, DeleteFileRequest request);
IObservable<RepositoryContentChangeSet> DeleteFile(string owner, string name, string path, DeleteFileRequest request);

/// <summary>
/// Creates a commit that deletes a file in a repository.
/// </summary>
/// <param name="repositoryId">The Id of the repository</param>
/// <param name="path">The path to the file</param>
/// <param name="request">Information about the file to delete</param>
IObservable<Unit> DeleteFile(long repositoryId, string path, DeleteFileRequest request);
IObservable<RepositoryContentChangeSet> DeleteFile(long repositoryId, string path, DeleteFileRequest request);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ public IObservable<RepositoryContentChangeSet> UpdateFile(long repositoryId, str
/// <param name="name">The name of the repository</param>
/// <param name="path">The path to the file</param>
/// <param name="request">Information about the file to delete</param>
public IObservable<Unit> DeleteFile(string owner, string name, string path, DeleteFileRequest request)
public IObservable<RepositoryContentChangeSet> DeleteFile(string owner, string name, string path, DeleteFileRequest request)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Expand All @@ -447,7 +447,7 @@ public IObservable<Unit> DeleteFile(string owner, string name, string path, Dele
/// <param name="repositoryId">The Id of the repository</param>
/// <param name="path">The path to the file</param>
/// <param name="request">Information about the file to delete</param>
public IObservable<Unit> DeleteFile(long repositoryId, string path, DeleteFileRequest request)
public IObservable<RepositoryContentChangeSet> DeleteFile(long repositoryId, string path, DeleteFileRequest request)
{
Ensure.ArgumentNotNullOrEmptyString(path, nameof(path));
Ensure.ArgumentNotNull(request, nameof(request));
Expand Down
24 changes: 16 additions & 8 deletions Octokit.Tests.Integration/Clients/RepositoryContentsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -352,11 +352,12 @@ public async Task CrudTest()
Assert.Equal("New Content", contents.First().Content);
fileSha = contents.First().Sha;

await fixture.DeleteFile(
var delete = await fixture.DeleteFile(
repository.Owner.Login,
repository.Name,
"somefile.txt",
new DeleteFileRequest("Deleted file", fileSha));
Assert.Equal("Deleted file", delete.Commit.Message);

await Assert.ThrowsAsync<NotFoundException>(
() => fixture.GetAllContents(repository.Owner.Login, repository.Name, "somefile.txt"));
Expand Down Expand Up @@ -394,10 +395,11 @@ public async Task CrudTestWithRepositoryId()
Assert.Equal("New Content", contents.First().Content);
fileSha = contents.First().Sha;

await fixture.DeleteFile(
var delete = await fixture.DeleteFile(
repository.Id,
"somefile.txt",
new DeleteFileRequest("Deleted file", fileSha));
Assert.Equal("Deleted file", delete.Commit.Message);

await Assert.ThrowsAsync<NotFoundException>(
() => fixture.GetAllContents(repository.Owner.Login, repository.Name, "somefile.txt"));
Expand Down Expand Up @@ -440,11 +442,12 @@ public async Task CrudTestWithNamedBranch()
Assert.Equal("New Content", contents.First().Content);
fileSha = contents.First().Sha;

await fixture.DeleteFile(
var delete = await fixture.DeleteFile(
repository.Owner.Login,
repository.Name,
"somefile.txt",
new DeleteFileRequest("Deleted file", fileSha, branchName));
Assert.Equal("Deleted file", delete.Commit.Message);

await Assert.ThrowsAsync<NotFoundException>(
() => fixture.GetAllContents(repository.Owner.Login, repository.Name, "somefile.txt"));
Expand Down Expand Up @@ -485,10 +488,11 @@ public async Task CrudTestWithNamedBranchWithRepositoryId()
Assert.Equal("New Content", contents.First().Content);
fileSha = contents.First().Sha;

await fixture.DeleteFile(
var delete = await fixture.DeleteFile(
repository.Id,
"somefile.txt",
new DeleteFileRequest("Deleted file", fileSha, branchName));
Assert.Equal("Deleted file", delete.Commit.Message);

await Assert.ThrowsAsync<NotFoundException>(
() => fixture.GetAllContents(repository.Owner.Login, repository.Name, "somefile.txt"));
Expand Down Expand Up @@ -528,11 +532,12 @@ public async Task CrudTestWithExplicitBase64()
Assert.Equal("New Content", contents.First().Content);
fileSha = contents.First().Sha;

await fixture.DeleteFile(
var delete = await fixture.DeleteFile(
repository.Owner.Login,
repository.Name,
"somefile.txt",
new DeleteFileRequest("Deleted file", fileSha));
Assert.Equal("Deleted file", delete.Commit.Message);

await Assert.ThrowsAsync<NotFoundException>(
() => fixture.GetAllContents(repository.Owner.Login, repository.Name, "somefile.txt"));
Expand Down Expand Up @@ -570,10 +575,11 @@ public async Task CrudTestWithRepositoryIdWithExplicitBase64()
Assert.Equal("New Content", contents.First().Content);
fileSha = contents.First().Sha;

await fixture.DeleteFile(
var delete = await fixture.DeleteFile(
repository.Id,
"somefile.txt",
new DeleteFileRequest("Deleted file", fileSha));
Assert.Equal("Deleted file", delete.Commit.Message);

await Assert.ThrowsAsync<NotFoundException>(
() => fixture.GetAllContents(repository.Owner.Login, repository.Name, "somefile.txt"));
Expand Down Expand Up @@ -616,11 +622,12 @@ public async Task CrudTestWithNamedBranchWithExplicitBase64()
Assert.Equal("New Content", contents.First().Content);
fileSha = contents.First().Sha;

await fixture.DeleteFile(
var delete = await fixture.DeleteFile(
repository.Owner.Login,
repository.Name,
"somefile.txt",
new DeleteFileRequest("Deleted file", fileSha, branchName));
Assert.Equal("Deleted file", delete.Commit.Message);

await Assert.ThrowsAsync<NotFoundException>(
() => fixture.GetAllContents(repository.Owner.Login, repository.Name, "somefile.txt"));
Expand Down Expand Up @@ -661,10 +668,11 @@ public async Task CrudTestWithNamedBranchWithRepositoryIdWithExplicitBase64()
Assert.Equal("New Content", contents.First().Content);
fileSha = contents.First().Sha;

await fixture.DeleteFile(
var delete = await fixture.DeleteFile(
repository.Id,
"somefile.txt",
new DeleteFileRequest("Deleted file", fileSha, branchName));
Assert.Equal("Deleted file", delete.Commit.Message);

await Assert.ThrowsAsync<NotFoundException>(
() => fixture.GetAllContents(repository.Owner.Login, repository.Name, "somefile.txt"));
Expand Down
8 changes: 4 additions & 4 deletions Octokit.Tests/Clients/RepositoryContentsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ public async Task RequestsCorrectUrl()
string expectedUri = "repos/org/repo/contents/path/to/file";
await client.DeleteFile("org", "repo", "path/to/file", new DeleteFileRequest("message", "1234abc", "mybranch"));

connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == expectedUri), Arg.Any<object>());
connection.Received().Delete<RepositoryContentChangeSet>(Arg.Is<Uri>(u => u.ToString() == expectedUri), Arg.Any<object>());
}

[Fact]
Expand All @@ -540,7 +540,7 @@ public async Task RequestsCorrectUrlWithRepositoryId()
string expectedUri = "repositories/1/contents/path/to/file";
await client.DeleteFile(1, "path/to/file", new DeleteFileRequest("message", "1234abc", "mybranch"));

connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == expectedUri), Arg.Any<object>());
connection.Received().Delete<RepositoryContentChangeSet>(Arg.Is<Uri>(u => u.ToString() == expectedUri), Arg.Any<object>());
}

[Fact]
Expand All @@ -551,7 +551,7 @@ public async Task PassesRequestObject()

await client.DeleteFile("org", "repo", "path/to/file", new DeleteFileRequest("message", "1234abc", "mybranch"));

connection.Received().Delete(
connection.Received().Delete<RepositoryContentChangeSet>(
Arg.Any<Uri>(),
Arg.Is<DeleteFileRequest>(a =>
a.Message == "message"
Expand All @@ -567,7 +567,7 @@ public async Task PassesRequestObjectWithRepositoryId()

await client.DeleteFile(1, "path/to/file", new DeleteFileRequest("message", "1234abc", "mybranch"));

connection.Received().Delete(
connection.Received().Delete<RepositoryContentChangeSet>(
Arg.Any<Uri>(),
Arg.Is<DeleteFileRequest>(a =>
a.Message == "message"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ public void RequestsCorrectUrl()
string expectedUri = "repos/org/repo/contents/path/to/file";
client.DeleteFile("org", "repo", "path/to/file", new DeleteFileRequest("message", "1234abc", "mybranch"));

gitHubClient.Connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == expectedUri), Arg.Any<object>());
gitHubClient.Connection.Received().Delete<RepositoryContentChangeSet>(Arg.Is<Uri>(u => u.ToString() == expectedUri), Arg.Any<object>());
}

[Fact]
Expand All @@ -609,7 +609,7 @@ public void RequestsCorrectUrlWithRepositoryId()
string expectedUri = "repositories/1/contents/path/to/file";
client.DeleteFile(1, "path/to/file", new DeleteFileRequest("message", "1234abc", "mybranch"));

gitHubClient.Connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == expectedUri), Arg.Any<object>());
gitHubClient.Connection.Received().Delete<RepositoryContentChangeSet>(Arg.Is<Uri>(u => u.ToString() == expectedUri), Arg.Any<object>());
}

[Fact]
Expand All @@ -621,7 +621,7 @@ public void PassesRequestObject()

client.DeleteFile("org", "repo", "path/to/file", new DeleteFileRequest("message", "1234abc", "mybranch"));

gitHubClient.Connection.Received().Delete(
gitHubClient.Connection.Received().Delete<RepositoryContentChangeSet>(
Arg.Any<Uri>(),
Arg.Is<DeleteFileRequest>(a =>
a.Message == "message"
Expand All @@ -638,7 +638,7 @@ public void PassesRequestObjectWithRepositoryId()

client.DeleteFile(1, "path/to/file", new DeleteFileRequest("message", "1234abc", "mybranch"));

gitHubClient.Connection.Received().Delete(
gitHubClient.Connection.Received().Delete<RepositoryContentChangeSet>(
Arg.Any<Uri>(),
Arg.Is<DeleteFileRequest>(a =>
a.Message == "message"
Expand Down
4 changes: 2 additions & 2 deletions Octokit/Clients/IRepositoryContentsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,15 +285,15 @@ public interface IRepositoryContentsClient
/// <param name="name">The name of the repository</param>
/// <param name="path">The path to the file</param>
/// <param name="request">Information about the file to delete</param>
Task DeleteFile(string owner, string name, string path, DeleteFileRequest request);
Task<RepositoryContentChangeSet> DeleteFile(string owner, string name, string path, DeleteFileRequest request);

/// <summary>
/// Creates a commit that deletes a file in a repository.
/// </summary>
/// <param name="repositoryId">The Id of the repository</param>
/// <param name="path">The path to the file</param>
/// <param name="request">Information about the file to delete</param>
Task DeleteFile(long repositoryId, string path, DeleteFileRequest request);
Task<RepositoryContentChangeSet> DeleteFile(long repositoryId, string path, DeleteFileRequest request);
}

/// <summary>
Expand Down
8 changes: 4 additions & 4 deletions Octokit/Clients/RepositoryContentsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -499,15 +499,15 @@ public Task<RepositoryContentChangeSet> UpdateFile(long repositoryId, string pat
/// <param name="path">The path to the file</param>
/// <param name="request">Information about the file to delete</param>
[ManualRoute("DELETE", "/repos/{owner}/{repo}/contents/{path}")]
public Task DeleteFile(string owner, string name, string path, DeleteFileRequest request)
public Task<RepositoryContentChangeSet> DeleteFile(string owner, string name, string path, DeleteFileRequest request)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNullOrEmptyString(path, nameof(path));
Ensure.ArgumentNotNull(request, nameof(request));

var deleteUrl = ApiUrls.RepositoryContent(owner, name, path);
return ApiConnection.Delete(deleteUrl, request);
return ApiConnection.Delete<RepositoryContentChangeSet>(deleteUrl, request);
}

/// <summary>
Expand All @@ -517,13 +517,13 @@ public Task DeleteFile(string owner, string name, string path, DeleteFileRequest
/// <param name="path">The path to the file</param>
/// <param name="request">Information about the file to delete</param>
[ManualRoute("DELETE", "/repositorioes/{id}/contents/{path}")]
public Task DeleteFile(long repositoryId, string path, DeleteFileRequest request)
public Task<RepositoryContentChangeSet> DeleteFile(long repositoryId, string path, DeleteFileRequest request)
{
Ensure.ArgumentNotNullOrEmptyString(path, nameof(path));
Ensure.ArgumentNotNull(request, nameof(request));

var deleteUrl = ApiUrls.RepositoryContent(repositoryId, path);
return ApiConnection.Delete(deleteUrl, request);
return ApiConnection.Delete<RepositoryContentChangeSet>(deleteUrl, request);
}
}
}