mirror of
https://git.yoctoproject.org/poky
synced 2026-05-09 17:39:31 +00:00
buildhistory-diff: exclude paths from the output
Implemented -e/--exclude-path command line option to exclude paths from buildhistory-diff output. [YOCTO #11459] (From OE-Core rev: 86393230e0ce33bf7d6d69d3019113e704081d30) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
43ceb87454
commit
d72227fd2b
@@ -143,22 +143,25 @@ class ChangeRecord:
|
|||||||
out += '\n '.join(list(diff)[2:])
|
out += '\n '.join(list(diff)[2:])
|
||||||
out += '\n --'
|
out += '\n --'
|
||||||
elif self.fieldname in img_monitor_files or '/image-files/' in self.path:
|
elif self.fieldname in img_monitor_files or '/image-files/' in self.path:
|
||||||
fieldname = self.fieldname
|
if self.filechanges or (self.oldvalue and self.newvalue):
|
||||||
if '/image-files/' in self.path:
|
fieldname = self.fieldname
|
||||||
fieldname = os.path.join('/' + self.path.split('/image-files/')[1], self.fieldname)
|
if '/image-files/' in self.path:
|
||||||
out = 'Changes to %s:\n ' % fieldname
|
fieldname = os.path.join('/' + self.path.split('/image-files/')[1], self.fieldname)
|
||||||
|
out = 'Changes to %s:\n ' % fieldname
|
||||||
|
else:
|
||||||
|
if outer:
|
||||||
|
prefix = 'Changes to %s ' % self.path
|
||||||
|
out = '(%s):\n ' % self.fieldname
|
||||||
|
if self.filechanges:
|
||||||
|
out += '\n '.join(['%s' % i for i in self.filechanges])
|
||||||
|
else:
|
||||||
|
alines = self.oldvalue.splitlines()
|
||||||
|
blines = self.newvalue.splitlines()
|
||||||
|
diff = difflib.unified_diff(alines, blines, fieldname, fieldname, lineterm='')
|
||||||
|
out += '\n '.join(list(diff))
|
||||||
|
out += '\n --'
|
||||||
else:
|
else:
|
||||||
if outer:
|
out = ''
|
||||||
prefix = 'Changes to %s ' % self.path
|
|
||||||
out = '(%s):\n ' % self.fieldname
|
|
||||||
if self.filechanges:
|
|
||||||
out += '\n '.join(['%s' % i for i in self.filechanges])
|
|
||||||
else:
|
|
||||||
alines = self.oldvalue.splitlines()
|
|
||||||
blines = self.newvalue.splitlines()
|
|
||||||
diff = difflib.unified_diff(alines, blines, fieldname, fieldname, lineterm='')
|
|
||||||
out += '\n '.join(list(diff))
|
|
||||||
out += '\n --'
|
|
||||||
else:
|
else:
|
||||||
out = '%s changed from "%s" to "%s"' % (self.fieldname, self.oldvalue, self.newvalue)
|
out = '%s changed from "%s" to "%s"' % (self.fieldname, self.oldvalue, self.newvalue)
|
||||||
|
|
||||||
@@ -169,7 +172,7 @@ class ChangeRecord:
|
|||||||
for line in chg._str_internal(False).splitlines():
|
for line in chg._str_internal(False).splitlines():
|
||||||
out += '\n * %s' % line
|
out += '\n * %s' % line
|
||||||
|
|
||||||
return '%s%s' % (prefix, out)
|
return '%s%s' % (prefix, out) if out else ''
|
||||||
|
|
||||||
class FileChange:
|
class FileChange:
|
||||||
changetype_add = 'A'
|
changetype_add = 'A'
|
||||||
@@ -508,7 +511,8 @@ def compare_siglists(a_blob, b_blob, taskdiff=False):
|
|||||||
return '\n'.join(out)
|
return '\n'.join(out)
|
||||||
|
|
||||||
|
|
||||||
def process_changes(repopath, revision1, revision2='HEAD', report_all=False, report_ver=False, sigs=False, sigsdiff=False):
|
def process_changes(repopath, revision1, revision2='HEAD', report_all=False, report_ver=False,
|
||||||
|
sigs=False, sigsdiff=False, exclude_path=None):
|
||||||
repo = git.Repo(repopath)
|
repo = git.Repo(repopath)
|
||||||
assert repo.bare == False
|
assert repo.bare == False
|
||||||
commit = repo.commit(revision1)
|
commit = repo.commit(revision1)
|
||||||
@@ -601,6 +605,19 @@ def process_changes(repopath, revision1, revision2='HEAD', report_all=False, rep
|
|||||||
elif chg.path == chg2.path and chg.path.startswith('packages/') and chg2.fieldname in ['PE', 'PV', 'PR']:
|
elif chg.path == chg2.path and chg.path.startswith('packages/') and chg2.fieldname in ['PE', 'PV', 'PR']:
|
||||||
chg.related.append(chg2)
|
chg.related.append(chg2)
|
||||||
|
|
||||||
|
# filter out unwanted paths
|
||||||
|
if exclude_path:
|
||||||
|
for chg in changes:
|
||||||
|
if chg.filechanges:
|
||||||
|
fchgs = []
|
||||||
|
for fchg in chg.filechanges:
|
||||||
|
for epath in exclude_path:
|
||||||
|
if fchg.path.startswith(epath):
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
fchgs.append(fchg)
|
||||||
|
chg.filechanges = fchgs
|
||||||
|
|
||||||
if report_all:
|
if report_all:
|
||||||
return changes
|
return changes
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ def main():
|
|||||||
parser.add_option("-S", "--signatures-with-diff",
|
parser.add_option("-S", "--signatures-with-diff",
|
||||||
help = "Report on actual signature differences instead of output (requires signature data to have been generated, either by running the actual tasks or using bitbake -S)",
|
help = "Report on actual signature differences instead of output (requires signature data to have been generated, either by running the actual tasks or using bitbake -S)",
|
||||||
action="store_true", dest="sigsdiff", default=False)
|
action="store_true", dest="sigsdiff", default=False)
|
||||||
|
parser.add_option("-e", "--exclude-path", action="append",
|
||||||
|
help = "exclude path from the output")
|
||||||
|
|
||||||
options, args = parser.parse_args(sys.argv)
|
options, args = parser.parse_args(sys.argv)
|
||||||
|
|
||||||
@@ -75,7 +77,7 @@ def main():
|
|||||||
sys.stderr.write("Unable to find bitbake by searching parent directory of this script or PATH\n")
|
sys.stderr.write("Unable to find bitbake by searching parent directory of this script or PATH\n")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
import oe.buildhistory_analysis
|
from oe.buildhistory_analysis import process_changes
|
||||||
|
|
||||||
fromrev = 'build-minus-1'
|
fromrev = 'build-minus-1'
|
||||||
torev = 'HEAD'
|
torev = 'HEAD'
|
||||||
@@ -92,7 +94,9 @@ def main():
|
|||||||
|
|
||||||
import gitdb
|
import gitdb
|
||||||
try:
|
try:
|
||||||
changes = oe.buildhistory_analysis.process_changes(options.buildhistory_dir, fromrev, torev, options.report_all, options.report_ver, options.sigs, options.sigsdiff)
|
changes = process_changes(options.buildhistory_dir, fromrev, torev,
|
||||||
|
options.report_all, options.report_ver, options.sigs,
|
||||||
|
options.sigsdiff, options.exclude_path)
|
||||||
except gitdb.exc.BadObject as e:
|
except gitdb.exc.BadObject as e:
|
||||||
if len(args) == 1:
|
if len(args) == 1:
|
||||||
sys.stderr.write("Unable to find previous build revision in buildhistory repository\n\n")
|
sys.stderr.write("Unable to find previous build revision in buildhistory repository\n\n")
|
||||||
@@ -102,7 +106,9 @@ def main():
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
for chg in changes:
|
for chg in changes:
|
||||||
print('%s' % chg)
|
out = str(chg)
|
||||||
|
if out:
|
||||||
|
print(out)
|
||||||
|
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user