show the status output on failure (MR 2472)

There is a lot of context and state management needed when using
pmbootstrap, sometimes it can be a lot to keep in your head. Let's print
the output of "pmbootstrap status" when stuff goes wrong, this might
help remind people if e.g. their pmaports checkout is on the wrong
branch, or they're building for the wrong device.

Additionally, don't print the "run pmbootstrap log for details" message
if pmbootstrap was called with --details-to-stdout

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
Caleb Connolly 2024-11-02 17:15:27 +01:00 committed by Robert Eckelmann
parent 3b4b9cd061
commit 39235fedfb
No known key found for this signature in database
GPG key ID: 0583312B195F64B6
4 changed files with 18 additions and 10 deletions

View file

@ -65,7 +65,9 @@ def clone(name_repo: str) -> None:
open(fetch_head, "w").close()
def rev_parse(path: Path, revision: str = "HEAD", extra_args: list = []) -> str:
def rev_parse(
path: Path, revision: str = "HEAD", extra_args: list = [], silent: bool = False
) -> str:
"""Run "git rev-parse" in a specific repository dir.
:param path: to the git repository
@ -75,7 +77,7 @@ def rev_parse(path: Path, revision: str = "HEAD", extra_args: list = []) -> str:
or (with ``--abbrev-ref``): the branch name, e.g. "master"
"""
command = ["git", "rev-parse"] + extra_args + [revision]
rev = pmb.helpers.run.user_output(command, path)
rev = pmb.helpers.run.user_output(command, path, output="null" if silent else "log")
return rev.rstrip()
@ -90,10 +92,10 @@ def can_fast_forward(path: Path, branch_upstream: str, branch: str = "HEAD") ->
raise RuntimeError("Unexpected exit code from git: " + str(ret))
def clean_worktree(path: Path) -> bool:
def clean_worktree(path: Path, silent: bool = False) -> bool:
"""Check if there are not any modified files in the git dir."""
command = ["git", "status", "--porcelain"]
return pmb.helpers.run.user_output(command, path) == ""
return pmb.helpers.run.user_output(command, path, output="null" if silent else "log") == ""
def list_remotes(aports: Path) -> list[str]: