def get_last_commit_before_due_date(self, aname, group):
due_date_str = self.course_config[aname]["deadline"]
due_date_object = datetime.strptime(due_date_str, "%Y-%m-%d %H:%M")
due_date_object_utc = due_date_object.replace(tzinfo=tz.tzlocal()).astimezone(tz.tzutc())
# above: convert due date to utc because commits are in utc and we want to compare them to the due date
repo = self.repos[get_assessment_repo_name(group, self.config, aname)]
get_time_f = lambda commit: datetime.strptime(commit.commit.committer["date"], gh3_time_fmt)
# # hopefully committer is the better choice than author?
latest_commit = max(repo.commits(until=due_date_object_utc), key=get_time_f)
return latest_commit.sha
# note: in the unlikely event of two commits at the same time, i think max takes the first one. which is good because
# i'm guessing the commits are ordered anyway? ok this is not really relevant.
# TODO: fix this to work with multiple student teams
评论列表
文章目录