本文整理汇总了Python中git.Repo.commits方法的典型用法代码示例。如果您正苦于以下问题:Python Repo.commits方法的具体用法?Python Repo.commits怎么用?Python Repo.commits使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类git.Repo
的用法示例。
在下文中一共展示了Repo.commits方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: info
# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import commits [as 别名]
def info(request):
path = os.path.abspath(os.path.join(BASE_DIR, '.git'))
repo = Repo(path)
return HttpResponse(json.dumps({
'branch': repo.active_branch,
'commit': repo.commits(repo.active_branch)[0].id,
}))
示例2: get_git_sha1
# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import commits [as 别名]
def get_git_sha1():
try:
from git import Repo
except ImportError:
print >> sys.stderr, "could not import gitpython"
return None
repo = Repo(os.path.dirname(__file__))
sha1 = repo.commits()[0].id
return sha1
示例3: get_git_commit
# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import commits [as 别名]
def get_git_commit(fail_silently=True):
"""Returns the current git commit hash for the project.
NOTE: This depends on GitPython being available."""
try:
from git import Repo
repo = Repo(settings.ROOT)
return repo.commits(repo.active_branch, max_count=1)[0].id_abbrev
except:
if fail_silently:
return 'Unknown'
raise
示例4: check_state_commits
# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import commits [as 别名]
def check_state_commits(state):
repo = Repo('..')
data = {}
commits = repo.commits(path='scripts/'+state, max_count=1000)
if commits:
data['num_commits'] = len(commits)
data['latest_commit'] = time.strftime('%Y-%m-%d', commits[0].committed_date)
authors = set()
for c in commits:
authors.add(c.author.name)
data['authors'] = ', '.join(authors)
return data
示例5: Repo
# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import commits [as 别名]
# Begin main body
# Parse arguments
username = sys.argv[1] # bob
password = sys.argv[2] # foobar
ftpsite = sys.argv[3] # example.com
base = sys.argv[4] # /www/www (must already exist!)
reposite = sys.argv[5] # /home/bob/website
# Windows doesn't like env
Git.git_binary = "git"
repo = Repo(reposite)
commit = repo.commits("master", 1)[0]
tree = commit.tree
ftp = ftplib.FTP(ftpsite, username, password)
# Check revision
hashFile = cStringIO.StringIO()
try:
ftp.retrbinary("RETR " + base + "/git-rev.txt", hashFile.write)
hash = hashFile.getvalue()
except ftplib.error_perm:
hash = 0
if not hash:
# Perform full upload
uploadAll(tree, ftp, base)
else:
示例6: Repo
# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import commits [as 别名]
import datetime
repo = Repo(".")
current_day = 0
current_month = 0
current_year = 0
commits = {}
summup = {}
markers = ["#", "*", "/", "$", "="]
authors_marker_mapping = {}
print repo.commit_count()
for commit in repo.commits(max_count=repo.commit_count()):
print dir(commit)
break
author = str(commit.author)
if not authors_marker_mapping.has_key(author):
marker = markers.pop()
authors_marker_mapping[author] = marker
commit_date = commit.committed_date
new_day = commit_date.tm_mday
new_month = commit_date.tm_mon
new_year = commit_date.tm_year
if not summup.has_key(new_year):