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: fix git diff --exit-code logic #732

Merged
merged 1 commit into from
Sep 4, 2024
Merged
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
14 changes: 11 additions & 3 deletions src/west/app/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def _handle_failed(self, args, failed):
# and report errors if anything failed.

if not failed:
self.dbg(f'git {self.name} failed for zero project')
return
elif len(failed) < 20:
s = 's:' if len(failed) > 1 else ''
Expand Down Expand Up @@ -804,13 +805,20 @@ def do_run(self, args, user_args):
extra_args=user_args,
capture_stdout=True, capture_stderr=True,
check=False)
if cp.returncode == 0:

# We cannot trust --exit-code alone, for instance merge
# conflicts return 0 with (at least) git version 2.46.0. See
# west issue #731
some_diff = cp.returncode == 1 or (cp.returncode == 0 and len(cp.stdout) > 0)
if not some_diff:
no_diff += 1
if cp.returncode == 1 or self.verbosity >= Verbosity.DBG:
if some_diff or self.verbosity >= Verbosity.DBG:
self.banner(f'diff for {project.name_and_path}:')
self.inf(cp.stdout.decode('utf-8'))
elif cp.returncode:
self.inf(cp.stderr.decode('utf-8'))
if cp.returncode > 1:
failed.append(project)

if failed:
self._handle_failed(args, failed)
elif self.verbosity <= Verbosity.INF:
Expand Down
Loading