MCPcopy Index your code
hub / github.com/PyGithub/PyGithub / delete_file

Method delete_file

github/Repository.py:2880–2929  ·  view source on GitHub ↗

This method deletes a file in a repository. :calls: `DELETE /repos/{owner}/{repo}/contents/{path} `_ :param path: string, Required. The content path. :param message: string, Required. The commit

(
        self,
        path: str,
        message: str,
        sha: str,
        branch: Opt[str] = NotSet,
        committer: Opt[InputGitAuthor] = NotSet,
        author: Opt[InputGitAuthor] = NotSet,
    )

Source from the content-addressed store, hash-verified

2878 }
2879
2880 def delete_file(
2881 self,
2882 path: str,
2883 message: str,
2884 sha: str,
2885 branch: Opt[str] = NotSet,
2886 committer: Opt[InputGitAuthor] = NotSet,
2887 author: Opt[InputGitAuthor] = NotSet,
2888 ) -> dict[str, Commit | _NotSetType]:
2889 """
2890 This method deletes a file in a repository.
2891
2892 :calls: `DELETE /repos/{owner}/{repo}/contents/{path} <https://docs.github.com/en/rest/reference/repos#delete-a-
2893 file>`_
2894 :param path: string, Required. The content path.
2895 :param message: string, Required. The commit message.
2896 :param sha: string, Required. The blob SHA of the file being replaced.
2897 :param branch: string. The branch name. Default: the repository’s default branch (usually master)
2898 :param committer: InputGitAuthor, (optional), if no information is given the authenticated user&#x27;s information
2899 will be used. You must specify both a name and email.
2900 :param author: InputGitAuthor, (optional), if omitted this will be filled in with committer information. If
2901 passed, you must specify both a name and email.
2902 :rtype: { 'content': :class:`null <NotSet>`:, 'commit': :class:`Commit <github.Commit.Commit>`}
2903
2904 """
2905 assert isinstance(path, str), "path must be str/unicode object"
2906 assert isinstance(message, str), "message must be str/unicode object"
2907 assert isinstance(sha, str), "sha must be a str/unicode object"
2908 assert is_optional(branch, str), "branch must be a str/unicode object"
2909 assert is_optional(author, github.InputGitAuthor), "author must be a github.InputGitAuthor object"
2910 assert is_optional(committer, github.InputGitAuthor), "committer must be a github.InputGitAuthor object"
2911
2912 url_parameters: dict[str, Any] = {"message": message, "sha": sha}
2913 if is_defined(branch):
2914 url_parameters["branch"] = branch
2915 if is_defined(author):
2916 url_parameters["author"] = author._identity
2917 if is_defined(committer):
2918 url_parameters["committer"] = committer._identity
2919
2920 headers, data = self._requester.requestJsonAndCheck(
2921 "DELETE",
2922 f"{self.url}/contents/{urllib.parse.quote(path)}",
2923 input=url_parameters,
2924 )
2925
2926 return {
2927 "commit": github.Commit.Commit(self._requester, headers, data["commit"], completed=True),
2928 "content": NotSet,
2929 }
2930
2931 @deprecated(
2932 """

Callers 1

testDeleteFileMethod · 0.80

Calls 3

is_optionalFunction · 0.90
is_definedFunction · 0.90
requestJsonAndCheckMethod · 0.80

Tested by

no test coverage detected