本文整理汇总了Python中git.Commit.create_from_tree方法的典型用法代码示例。如果您正苦于以下问题:Python Commit.create_from_tree方法的具体用法?Python Commit.create_from_tree怎么用?Python Commit.create_from_tree使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类git.Commit
的用法示例。
在下文中一共展示了Commit.create_from_tree方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _do_commit
# 需要导入模块: from git import Commit [as 别名]
# 或者: from git.Commit import create_from_tree [as 别名]
def _do_commit (self, repo, head, tree_binsha, msg, parent=None):
""" if parent parameter is None, we make it default to be [head.commit]
return new commit's hexsha, on error return None and output error
"""
assert (repo)
assert head is None or isinstance (head, HEAD) or isinstance (head, Head)
assert msg != None
if parent is None:
try:
parent = [head.commit]
except ValueError:
pass
new_commit = Commit.create_from_tree (repo, Tree (repo, tree_binsha), msg, \
parent_commits=parent, head=False) # because the first commit has no parent, parameter head==True likely fails
head.commit = new_commit #modify head's ref to commit
return new_commit