mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
diffmanifests: support custom git pretty format strings
Change-Id: I29f4f1351c421f393328514d145df1a96aed9ee2
This commit is contained in:
parent
cee5c77166
commit
7ecccf6225
13
project.py
13
project.py
@ -2437,7 +2437,7 @@ class Project(object):
|
|||||||
def _allrefs(self):
|
def _allrefs(self):
|
||||||
return self.bare_ref.all
|
return self.bare_ref.all
|
||||||
|
|
||||||
def _getLogs(self, rev1, rev2, oneline=False, color=True):
|
def _getLogs(self, rev1, rev2, oneline=False, color=True, pretty_format=None):
|
||||||
"""Get logs between two revisions of this project."""
|
"""Get logs between two revisions of this project."""
|
||||||
comp = '..'
|
comp = '..'
|
||||||
if rev1:
|
if rev1:
|
||||||
@ -2448,6 +2448,8 @@ class Project(object):
|
|||||||
out = DiffColoring(self.config)
|
out = DiffColoring(self.config)
|
||||||
if out.is_on and color:
|
if out.is_on and color:
|
||||||
cmd.append('--color')
|
cmd.append('--color')
|
||||||
|
if pretty_format is not None:
|
||||||
|
cmd.append('--pretty=format:%s' % pretty_format)
|
||||||
if oneline:
|
if oneline:
|
||||||
cmd.append('--oneline')
|
cmd.append('--oneline')
|
||||||
|
|
||||||
@ -2464,14 +2466,17 @@ class Project(object):
|
|||||||
raise
|
raise
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def getAddedAndRemovedLogs(self, toProject, oneline=False, color=True):
|
def getAddedAndRemovedLogs(self, toProject, oneline=False, color=True,
|
||||||
|
pretty_format=None):
|
||||||
"""Get the list of logs from this revision to given revisionId"""
|
"""Get the list of logs from this revision to given revisionId"""
|
||||||
logs = {}
|
logs = {}
|
||||||
selfId = self.GetRevisionId(self._allrefs)
|
selfId = self.GetRevisionId(self._allrefs)
|
||||||
toId = toProject.GetRevisionId(toProject._allrefs)
|
toId = toProject.GetRevisionId(toProject._allrefs)
|
||||||
|
|
||||||
logs['added'] = self._getLogs(selfId, toId, oneline=oneline, color=color)
|
logs['added'] = self._getLogs(selfId, toId, oneline=oneline, color=color,
|
||||||
logs['removed'] = self._getLogs(toId, selfId, oneline=oneline, color=color)
|
pretty_format=pretty_format)
|
||||||
|
logs['removed'] = self._getLogs(toId, selfId, oneline=oneline, color=color,
|
||||||
|
pretty_format=pretty_format)
|
||||||
return logs
|
return logs
|
||||||
|
|
||||||
class _GitGetByExec(object):
|
class _GitGetByExec(object):
|
||||||
|
@ -71,6 +71,10 @@ synced and their revisions won't be found.
|
|||||||
p.add_option('--no-color',
|
p.add_option('--no-color',
|
||||||
dest='color', action='store_false', default=True,
|
dest='color', action='store_false', default=True,
|
||||||
help='does not display the diff in color.')
|
help='does not display the diff in color.')
|
||||||
|
p.add_option('--pretty-format',
|
||||||
|
dest='pretty_format', action='store',
|
||||||
|
metavar='<FORMAT>',
|
||||||
|
help='print the log using a custom git pretty format string')
|
||||||
|
|
||||||
def _printRawDiff(self, diff):
|
def _printRawDiff(self, diff):
|
||||||
for project in diff['added']:
|
for project in diff['added']:
|
||||||
@ -92,7 +96,7 @@ synced and their revisions won't be found.
|
|||||||
otherProject.revisionExpr))
|
otherProject.revisionExpr))
|
||||||
self.out.nl()
|
self.out.nl()
|
||||||
|
|
||||||
def _printDiff(self, diff, color=True):
|
def _printDiff(self, diff, color=True, pretty_format=None):
|
||||||
if diff['added']:
|
if diff['added']:
|
||||||
self.out.nl()
|
self.out.nl()
|
||||||
self.printText('added projects : \n')
|
self.printText('added projects : \n')
|
||||||
@ -124,7 +128,8 @@ synced and their revisions won't be found.
|
|||||||
self.printText(' to ')
|
self.printText(' to ')
|
||||||
self.printRevision(otherProject.revisionExpr)
|
self.printRevision(otherProject.revisionExpr)
|
||||||
self.out.nl()
|
self.out.nl()
|
||||||
self._printLogs(project, otherProject, raw=False, color=color)
|
self._printLogs(project, otherProject, raw=False, color=color,
|
||||||
|
pretty_format=pretty_format)
|
||||||
self.out.nl()
|
self.out.nl()
|
||||||
|
|
||||||
if diff['unreachable']:
|
if diff['unreachable']:
|
||||||
@ -139,9 +144,13 @@ synced and their revisions won't be found.
|
|||||||
self.printText(' not found')
|
self.printText(' not found')
|
||||||
self.out.nl()
|
self.out.nl()
|
||||||
|
|
||||||
def _printLogs(self, project, otherProject, raw=False, color=True):
|
def _printLogs(self, project, otherProject, raw=False, color=True,
|
||||||
logs = project.getAddedAndRemovedLogs(otherProject, oneline=True,
|
pretty_format=None):
|
||||||
color=color)
|
|
||||||
|
logs = project.getAddedAndRemovedLogs(otherProject,
|
||||||
|
oneline=(pretty_format is None),
|
||||||
|
color=color,
|
||||||
|
pretty_format=pretty_format)
|
||||||
if logs['removed']:
|
if logs['removed']:
|
||||||
removedLogs = logs['removed'].split('\n')
|
removedLogs = logs['removed'].split('\n')
|
||||||
for log in removedLogs:
|
for log in removedLogs:
|
||||||
@ -192,4 +201,4 @@ synced and their revisions won't be found.
|
|||||||
if opt.raw:
|
if opt.raw:
|
||||||
self._printRawDiff(diff)
|
self._printRawDiff(diff)
|
||||||
else:
|
else:
|
||||||
self._printDiff(diff, color=opt.color)
|
self._printDiff(diff, color=opt.color, pretty_format=opt.pretty_format)
|
||||||
|
Loading…
Reference in New Issue
Block a user