Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix type of commit for create_file #2120

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions github/Repository.py
Expand Up @@ -2188,7 +2188,7 @@ def create_file(
: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>`}
'commit': :class:`Commit <github.GitCommit.GitCommit>`}
"""
assert isinstance(path, str)
assert isinstance(message, str)
Expand Down Expand Up @@ -2223,7 +2223,7 @@ def create_file(
"content": github.ContentFile.ContentFile(
self._requester, headers, data["content"], completed=False
),
"commit": github.Commit.Commit(
"commit": github.GitCommit.GitCommit(
self._requester, headers, data["commit"], completed=True
),
}
Expand Down
2 changes: 1 addition & 1 deletion github/Repository.pyi
Expand Up @@ -142,7 +142,7 @@ class Repository(CompletableGithubObject):
branch: Union[str, _NotSetType] = ...,
committer: Union[InputGitAuthor, _NotSetType] = ...,
author: Union[InputGitAuthor, _NotSetType] = ...,
) -> Dict[str, Union[ContentFile, Commit]]: ...
) -> Dict[str, Union[ContentFile, GitCommit]]: ...
def create_git_blob(self, content: str, encoding: str) -> GitBlob: ...
def create_git_commit(
self,
Expand Down
25 changes: 24 additions & 1 deletion tests/Repository.py
Expand Up @@ -1412,14 +1412,37 @@ def testCreateFile(self):
"Enix Yu", "enix223@163.com", "2016-01-15T16:13:30+12:00"
)
self.assertEqual(repr(author), 'InputGitAuthor(name="Enix Yu")')
self.repo.create_file(
result = self.repo.create_file(
path=newFile,
message="Create file for testCreateFile",
content=content,
branch="master",
committer=author,
author=author,
)
commit = result["commit"]
raw_keys = set(commit.raw_data.keys())
self.assertLessEqual(
{
"sha",
"parents",
"tree",
"author",
"committer",
"url",
"html_url",
# missing from replay data but documented in schema
# "node_id",
# "message",
# "verification",
},
raw_keys,
"raw data should match (be a subset of) git-commit keys",
)
self.assertFalse(
{"comments_url", "commit", "stats", "files"} & raw_keys,
"characteristic attributes of commit should not be in the raw data",
)

def testUpdateFile(self):
updateFile = "doc/testCreateUpdateDeleteFile.md"
Expand Down