本文整理汇总了Python中account.models.User.from_commit方法的典型用法代码示例。如果您正苦于以下问题:Python User.from_commit方法的具体用法?Python User.from_commit怎么用?Python User.from_commit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类account.models.User
的用法示例。
在下文中一共展示了User.from_commit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_from_sha
# 需要导入模块: from account.models import User [as 别名]
# 或者: from account.models.User import from_commit [as 别名]
def create_from_sha(project, new_rev, create=True):
from account.models import User
new_rev_commit = project.git.commit(new_rev)
# Extract the project tree and diffs
parents = [p for p in new_rev_commit.parents]
# Extract formatted author details
new_author = new_rev_commit.author
author_info = User.from_commit(new_author, project)
author, author_name, author_email = author_info
# Extract formatted committer details
new_committer = new_rev_commit.committer
committer_info = User.from_commit(new_committer, project)
committer, committer_name, committer_email = committer_info
fts = datetime.datetime.utcfromtimestamp
utc = pytz.timezone("UTC")
author_time = new_rev_commit.author_time
author_time = utc.localize(fts(author_time))
commit_time = new_rev_commit.commit_time
commit_time = utc.localize(fts(commit_time))
# The actual Commit object is fairly heavy
c = Commit(
commit_time=commit_time,
sha1sum=new_rev_commit.sha().hexdigest(),
author=author,
author_name=author_name,
author_email=author_email,
author_time=author_time,
committer=committer,
committer_name=committer_name,
committer_email=committer_email,
message=new_rev_commit.message,
diff=[],
tree=[],
parents=parents,
project=project,
)
if create:
c.save()
return c