diff --git a/app/Models/Application.php b/app/Models/Application.php index 17bb7425a5..2699cbaf79 100644 --- a/app/Models/Application.php +++ b/app/Models/Application.php @@ -2627,9 +2627,22 @@ class Application extends BaseModel return '

Reason: '.e('The Git host sent an SSH host key that is not the saved or published key. Open Source > SSH host keys and use Fetch current host key. Compare the fingerprint with the Git host administrator before you accept it.'); } - $reason = collect(explode("\n", $errorOutput))->map(fn (string $line) => trim($line))->filter()->last(); + $lines = collect(explode("\n", $errorOutput))->map(fn (string $line) => trim($line))->filter()->values(); + // Git and SSH print progress, known-hosts and multiplexing notes, and a generic access hint around the real cause. + $reasonLines = $lines->reject(fn (string $line) => Str::startsWith($line, [ + 'Cloning into', + 'Warning: Permanently added', + 'Control socket connect(', + 'ControlSocket ', + 'mux_client_', + 'Please make sure you have the correct access rights', + 'and the repository exists.', + ]))->take(-10); + if ($reasonLines->isEmpty()) { + $reasonLines = $lines->take(-1); + } - return $reason ? '

Reason: '.e(str($reason)->limit(300)->value()) : ''; + return $reasonLines->isEmpty() ? '' : '

Reason: '.$reasonLines->map(fn (string $line) => e(str($line)->limit(300)->value()))->implode('
'); } /**