app: project: Allow to diff against manifest revision

Add an argument to the west diff command that allows to set the
manifest revision as the merge-base.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
This commit is contained in:
Pieter De Gendt 2024-07-19 15:55:16 +02:00 committed by Carles Cufí
parent 4c4dc04755
commit 0d5ee4eb08
1 changed files with 4 additions and 1 deletions

View File

@ -779,6 +779,8 @@ class Diff(_ProjectCommand):
defaults to active cloned projects''') defaults to active cloned projects''')
parser.add_argument('-a', '--all', action='store_true', parser.add_argument('-a', '--all', action='store_true',
help='include output for inactive projects') help='include output for inactive projects')
parser.add_argument('-m', '--manifest', action='store_true',
help='show changes relative to the manifest revision')
return parser return parser
def do_run(self, args, ignored): def do_run(self, args, ignored):
@ -792,9 +794,10 @@ class Diff(_ProjectCommand):
for project in self._cloned_projects(args, only_active=not args.all): for project in self._cloned_projects(args, only_active=not args.all):
# Use paths that are relative to the base directory to make it # Use paths that are relative to the base directory to make it
# easier to see where the changes are # easier to see where the changes are
merge_base = ['--merge-base', project.revision] if args.manifest else []
cp = project.git(['diff', f'--src-prefix={project.path}/', cp = project.git(['diff', f'--src-prefix={project.path}/',
f'--dst-prefix={project.path}/', f'--dst-prefix={project.path}/',
'--exit-code'] + color, '--exit-code'] + color + merge_base,
capture_stdout=True, capture_stderr=True, capture_stdout=True, capture_stderr=True,
check=False) check=False)
if cp.returncode == 0: if cp.returncode == 0: