Allow sha=None for InputGitTreeElement (#1327)

InputGitTreeElement is used to build tree objects for
Repository.create_git_tree(). However, the GitHub API allows passing
sha=null to delete a file, which we don't allow. Extend the checking in
InputGitTreeElement to also allow None, and add a test for good measure.

Fixes #1318
This commit is contained in:
Steve Kowalik
2019-12-29 10:50:23 +11:00
committed by GitHub
parent 732fd26abd
commit 60464f6554
3 changed files with 28 additions and 3 deletions
+5 -3
View File
@@ -53,7 +53,7 @@ class InputGitTreeElement(object):
:param mode: string
:param type: string
:param content: string
:param sha: string
:param sha: string or None
"""
assert isinstance(path, (str, six.text_type)), path
@@ -62,8 +62,10 @@ class InputGitTreeElement(object):
assert content is github.GithubObject.NotSet or isinstance(
content, (str, six.text_type)
), content
assert sha is github.GithubObject.NotSet or isinstance(
sha, (str, six.text_type)
assert (
sha is github.GithubObject.NotSet
or sha is None
or isinstance(sha, (str, six.text_type))
), sha
self.__path = path
self.__mode = mode