in ForgeGit/forgegit/model/git_repo.py [0:0]
def log(self, revs=None, path=None, exclude=None, id_only=True, limit=None, **kw):
"""
Returns a generator that returns information about commits reachable
by revs.
revs can be None or a list or tuple of revisions, each of which
can be anything parsable by self.commit(). If revs is None, the
default branch head will be used.
If path is not None, only commits which modify files under path
will be included.
Exclude can be None or a list or tuple of identifiers, each of which
can be anything parsable by self.commit(). If not None, then any
revisions reachable by any of the revisions in exclude will not be
included.
If id_only is True, returns only the commit ID, otherwise it returns
detailed information about each commit.
"""
path = path.strip('/') if path else None
if exclude is not None:
revs.extend(['^%s' % e for e in exclude])
args = ['--follow', '--name-status', revs, '--', path or '.']
kwargs = {}
if limit:
kwargs['n'] = limit
for ci, refs, renamed in self._iter_commits_with_refs(*args, **kwargs):
if id_only:
yield ci.hexsha
else:
size = None
rename_details = {}
if path:
if renamed and renamed['to'] == path:
rename_details['path'] = '/' + renamed['from']
# get first rev **before** rename
_iter = self._git.iter_commits(
revs, renamed['from'], max_count=2)
prev_rev = list(_iter)[1]
rename_details['commit_url'] = self._repo.url_for_commit(
prev_rev.hexsha
)
try:
node = ci.tree / path
size = node.size if node.type == 'blob' else None
except KeyError as e:
size = None
if rename_details:
path = rename_details['path'].strip('/')
yield {
'id': ci.hexsha,
'message': h.really_unicode(ci.message or '--none--'),
'authored': {
'name': h.really_unicode(ci.author.name or '--none--'),
'email': h.really_unicode(ci.author.email),
'date': datetime.utcfromtimestamp(ci.authored_date),
},
'committed': {
'name': h.really_unicode(ci.committer.name or '--none--'),
'email': h.really_unicode(ci.committer.email),
'date': datetime.utcfromtimestamp(ci.committed_date),
},
'refs': refs,
'parents': [pci.hexsha for pci in ci.parents],
'size': size,
'rename_details': rename_details,
}