Add committer/author to Repository.delete_file (#678)

This commit is contained in:
Ilya Konstantinov
2018-01-16 14:17:47 -08:00
committed by Jason White
parent 45d18436fd
commit 3baa682cf8
+19 -3
View File
@@ -1283,8 +1283,8 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param message: string, (required), commit message
:param content: string, (required), the actual data in the file
:param branch: string, (optional), branch to create the commit on. Defaults to the default branch of the repository
:param committer: dict, (optional), if no information is given the authenticated user's information will be used. You must specify both a name and email.
:param author: dict, (optional), if omitted this will be filled in with committer information. If passed, you must specify both a name and email.
:param committer: InputGitAuthor, (optional), if no information is given the authenticated user's information will be used. You must specify both a name and email.
:param author: InputGitAuthor, (optional), if omitted this will be filled in with committer information. If passed, you must specify both a name and email.
:rtype: {
'content': :class:`ContentFile <github.ContentFile.ContentFile>`:,
'commit': :class:`Commit <github.Commit.Commit>`}
@@ -1342,6 +1342,8 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param content: string, Required. The updated file content, Base64 encoded.
:param sha: string, Required. The blob SHA of the file being replaced.
:param branch: string. The branch name. Default: the repositorys default branch (usually master)
:param committer: InputGitAuthor, (optional), if no information is given the authenticated user's information will be used. You must specify both a name and email.
:param author: InputGitAuthor, (optional), if omitted this will be filled in with committer information. If passed, you must specify both a name and email.
:rtype: {
'content': :class:`ContentFile <github.ContentFile.ContentFile>`:,
'commit': :class:`Commit <github.Commit.Commit>`}
@@ -1393,13 +1395,17 @@ class Repository(github.GithubObject.CompletableGithubObject):
'content': github.ContentFile.ContentFile(self._requester, headers, data["content"], completed=False)}
def delete_file(self, path, message, sha,
branch=github.GithubObject.NotSet):
branch=github.GithubObject.NotSet,
committer=github.GithubObject.NotSet,
author=github.GithubObject.NotSet):
"""This method delete a file in a repository
:calls: `DELETE /repos/:owner/:repo/contents/:path <https://developer.github.com/v3/repos/contents/#delete-a-file>`_
:param path: string, Required. The content path.
:param message: string, Required. The commit message.
:param sha: string, Required. The blob SHA of the file being replaced.
:param branch: string. The branch name. Default: the repositorys default branch (usually master)
:param committer: InputGitAuthor, (optional), if no information is given the authenticated user's information will be used. You must specify both a name and email.
:param author: InputGitAuthor, (optional), if omitted this will be filled in with committer information. If passed, you must specify both a name and email.
:rtype: {
'content': :class:`null <github.GithubObject.NotSet>`:,
'commit': :class:`Commit <github.Commit.Commit>`}
@@ -1413,10 +1419,20 @@ class Repository(github.GithubObject.CompletableGithubObject):
assert branch is github.GithubObject.NotSet \
or isinstance(branch, (str, unicode)), \
'branch must be a str/unicode object'
assert author is github.GithubObject.NotSet \
or isinstance(author, github.InputGitAuthor), \
'author must be a github.InputGitAuthor object'
assert committer is github.GithubObject.NotSet \
or isinstance(committer, github.InputGitAuthor), \
'committer must be a github.InputGitAuthor object'
url_parameters = {'message': message, 'sha': sha}
if branch is not github.GithubObject.NotSet:
url_parameters['branch'] = branch
if author is not github.GithubObject.NotSet:
url_parameters["author"] = author._identity
if committer is not github.GithubObject.NotSet:
url_parameters["committer"] = committer._identity
headers, data = self._requester.requestJsonAndCheck(
"DELETE",