Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

app: project: Allow to diff against manifest revision #719

Merged
merged 2 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/west/app/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,8 @@ def do_add_parser(self, parser_adder):
defaults to active cloned projects''')
parser.add_argument('-a', '--all', action='store_true',
help='include output for inactive projects')
parser.add_argument('-m', '--manifest', action='store_true',
help='show changes relative to the manifest revision')
return parser

def do_run(self, args, ignored):
Expand All @@ -792,9 +794,10 @@ def do_run(self, args, ignored):
for project in self._cloned_projects(args, only_active=not args.all):
# Use paths that are relative to the base directory to make it
# easier to see where the changes are
merge_base = ['--merge-base', project.revision] if args.manifest else []
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

project.revision is not OK: it can be a remote branch name and then git diff will fail. Or something else and who knows what might happen.

I just submitted a replacement of project.revision by manifest-rev in #748

Longer story in #747

cp = project.git(['diff', f'--src-prefix={project.path}/',
f'--dst-prefix={project.path}/',
'--exit-code'] + color,
'--exit-code'] + color + merge_base,
capture_stdout=True, capture_stderr=True,
check=False)
if cp.returncode == 0:
Expand Down
1 change: 1 addition & 0 deletions tests/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ def test_diff(west_init_tmpdir):
# Diff with no projects cloned shouldn't fail

cmd('diff')
cmd('diff --manifest')

# Neither should it fail after fetching one or both projects

Expand Down
Loading