Skip to content

Conversation

dylanlerch
Copy link

@dylanlerch dylanlerch commented Jun 9, 2025

Fixes #3016


Before the change?

The RepositoryContentsClient.DeleteFile currently only returns a Task. 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 the RepositoryContentsClient and ObservableRepositoryContentsClient now return a RepositoryContentChangeSet like the CreateFile and UpdateFile methods.

The Commit property will contain details of the commit that was created to delete the file, and the Content 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 or UpdateFile 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

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

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 like DeleteFileAndReturnResult (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!

  • Yes
  • No

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🆕 Triage
Development

Successfully merging this pull request may close these issues.

[FEAT]: Return RepositoryContentChangeSet from RepositoryContentsClient.DeleteFile
1 participant