[WIP] Return RepositoryContentChangeSet from RepositoryContentsClient.DeleteFile #3017
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #3016
Before the change?
The
RepositoryContentsClient.DeleteFile
currently only returns aTask
. The API returns details of the commit where the file was deleted, but this is not currently returned by Octokit.After the change?
DeleteFile
in both theRepositoryContentsClient
andObservableRepositoryContentsClient
now return aRepositoryContentChangeSet
like theCreateFile
andUpdateFile
methods.The
Commit
property will contain details of the commit that was created to delete the file, and theContent
property will always be null as documented in the Repository Contents API documentation.Testing
I've updated the unit tests to assert that we're calling the Delete method on the connection with the correct type, but I have not added any additional tests beyond that. This only changes the return type, and we don't test the mapping to this return type in the
CreateFile
orUpdateFile
tests, so it didn't feel necessary here.I've updated the integration tests to check that the commit message in the response matches what was passed in the request. The commit message feels like the most reliable, meaningful property to assert on (contents is
null
because we've just deleted the file). I've limited it to just one assertion as that aligns with the approach of the other requests in these integration tests, and gives enough confidence that the response is being mapped back correctly.Pull request checklist
Does this introduce a breaking change?
I've opted to update the return type in the existing
DeleteFile
methods. This keeps the client tidy, but makes this a breaking change. If we wanted to avoid a breaking change we could do something likeDeleteFileAndReturnResult
(naming TBD), but this would be inconsistent with anything else in this client.This is my first contribution, so I'm happy to follow the lead of someone with stronger opinions.
Please see our docs on breaking changes to help!