Offer to send the log to us when an install or update fails
When update or install.sh fails and there's a terminal, ask whether to send its log to the CoreDesktop team, with the option of reading exactly what would be sent first. Nothing is sent without a yes, and nothing is asked without a terminal. The new report command sends a log later (report, report FILE) or shows what would be sent (report --view). Before sending, the log is cleaned of terminal codes, and the home folder, user name, host name, email addresses, IPv4 addresses and Tailscale names are replaced. CoreDesktop's version, the kernel's, the failed steps and sibling versions go along with it. The request format the receiver on federated.sh implements is described at the top of report. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+22
-2
@@ -11,7 +11,7 @@ setup() {
|
||||
CD="$HOME/.local/share/coredesktop"
|
||||
mkdir -p "$CD/updates.d" "$HOME/.local/bin"
|
||||
cp "$REPO/update" "$CD/update"
|
||||
for script in refresh sibling version configure audit; do
|
||||
for script in refresh sibling version configure audit report; do
|
||||
echo '#!/bin/bash' > "$CD/$script"
|
||||
done
|
||||
|
||||
@@ -51,7 +51,7 @@ ran() {
|
||||
[[ "$output" == *"Done."* ]]
|
||||
called git -C "$CD" pull --ff-only
|
||||
ran a b
|
||||
for script in update refresh sibling version configure audit; do
|
||||
for script in update refresh sibling version configure audit report; do
|
||||
[ -x "$HOME/.local/bin/$script" ]
|
||||
done
|
||||
}
|
||||
@@ -188,6 +188,26 @@ ran() {
|
||||
[[ "$output" == *"The full output is in $HOME/.local/state/coredesktop/logs/update-"*".log"* ]]
|
||||
}
|
||||
|
||||
@test "when a step fails, update offers to send its log, naming what failed" {
|
||||
printf '#!/bin/bash\nprintf "%%s\\n" "$@" > "$BATS_TEST_TMPDIR/report-args"\n' > "$CD/report"
|
||||
hook 10-a 'return 1'
|
||||
hook 20-b 'return 1'
|
||||
|
||||
run "$CD/update"
|
||||
[ "$status" -eq 1 ]
|
||||
log=("$HOME"/.local/state/coredesktop/logs/update-*.log)
|
||||
[ "$(cat "$BATS_TEST_TMPDIR/report-args")" = "$(printf '%s\n' --offer "${log[0]}" 10-a.sh 20-b.sh)" ]
|
||||
}
|
||||
|
||||
@test "update doesn't offer to send its log when nothing failed" {
|
||||
printf '#!/bin/bash\ntouch "$BATS_TEST_TMPDIR/report-ran"\n' > "$CD/report"
|
||||
hook 10-a 'true'
|
||||
|
||||
run "$CD/update"
|
||||
[ "$status" -eq 0 ]
|
||||
[ ! -e "$BATS_TEST_TMPDIR/report-ran" ]
|
||||
}
|
||||
|
||||
@test "clean_log leaves only the text of a terminal session's log" {
|
||||
eval "$(sed -n '/^clean_log() {/,/^}/p' "$REPO/update")"
|
||||
log="$BATS_TEST_TMPDIR/session.log"
|
||||
|
||||
Reference in New Issue
Block a user