本文整理汇总了Python中gittle.Gittle.get_previous_commit方法的典型用法代码示例。如果您正苦于以下问题:Python Gittle.get_previous_commit方法的具体用法?Python Gittle.get_previous_commit怎么用?Python Gittle.get_previous_commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gittle.Gittle
的用法示例。
在下文中一共展示了Gittle.get_previous_commit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle
# 需要导入模块: from gittle import Gittle [as 别名]
# 或者: from gittle.Gittle import get_previous_commit [as 别名]
def handle(self, *args, **options):
projects = Project.objects.all()
for project in projects:
print('Checking {0} for new commits'.format(project))
if project.git_url:
repo_path = '/tmp/' + project.slug
try:
repo = Gittle(repo_path, project.git_url)
repo.pull()
except:
try:
repo = Gittle.clone(project.git_url, repo_path)
except:
# put some logging here
repo = None
if repo:
new_commits = []
for commit in repo.commit_info():
try:
prev_commit = repo.get_previous_commit(commit['sha'])
time = (datetime.fromtimestamp(commit['time']) + timedelta(hours=commit['timezone']/(60*60))).replace(tzinfo=pytz.utc)
try:
user_author = get_user_model().objects.get(email=commit['author']['email'])
string_author = None
except:
string_author = commit['author']['name']
user_author = None
summary = commit['message'].split('\n')[0][:45]
pcommit = ProjectCommit.objects.create(
project=project,
chash=commit['sha'],
message=commit['message'],
summary=summary,
user_author=user_author,
string_author=string_author,
created=time,
time=time,
diff=repo.diff(commit['sha'], prev_commit).next()['diff']
)
print(pcommit, ' added.')
new_commits.append(pcommit)
except:
pass