KiCad PCB EDA Suite
Loading...
Searching...
No Matches
kigit_failure.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.TXT for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 3
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef KIGIT_FAILURE_H_
21#define KIGIT_FAILURE_H_
22
25#include <import_export.h>
26
27#include <optional>
28#include <vector>
29
30#include <wx/string.h>
31
32
45
46
70
71
81
82
85{
87 wxString remoteName;
88 wxString url;
89 bool authFailed = false;
90
91 std::optional<KIGIT::HOST_KEY_FAILURE> hostKey;
92 wxString hostKeyRefusal;
93 wxString pushRefusal;
94 wxString serverMessage;
95};
96
97
104
105
108{
109 wxString summary;
110 wxString trustCommand;
113 bool coversHome = false;
115};
116
117
118namespace KIGIT
119{
120
129 const KIGIT_FAILURE_CONTEXT& aContext );
130
132APIEXPORT wxString UnexplainedFailure( KIGIT_OPERATION aOperation, const wxString& aUrl );
133
136
138constexpr size_t MAX_SERVER_TEXT = 4096;
139
141APIEXPORT wxString DecodeServerText( const char* aData, size_t aLength );
142
144APIEXPORT wxString StripEmbeddedUserinfo( const wxString& aText );
145
150APIEXPORT wxString PrintableServerText( const wxString& aText );
151
159APIEXPORT KIGIT_OWNERSHIP_REFUSAL DescribeOwnershipRefusal( const wxString& aStartDir, const wxString& aGitDir );
160
161} // namespace KIGIT
162
163#endif // KIGIT_FAILURE_H_
#define APIEXPORT
Macros which export functions from a DLL/DSO.
KIGIT_FAILURE
Why a transfer failed, in terms of what the user can do about it.
@ SERVER_REFUSED
The server answered with text alone. Its wording is shown but never interpreted.
@ AUTH_HTTPS_NEEDED
The server asked for a login before any password was offered.
@ HOST_KEY_UNVERIFIED
A key KiCad could not check, so there is nothing to offer to trust.
KIGIT_OPERATION
The transfer that failed, so a message nothing more specific explains can say what did not happen.
APIEXPORT wxString StripEmbeddedUserinfo(const wxString &aText)
Remove the user and password from every URL quoted in a message, since the remote's can carry a passw...
APIEXPORT wxString PrintableServerText(const wxString &aText)
Text a server sent, made safe to show: no terminal escapes, control or bidi characters,...
constexpr size_t MAX_SERVER_TEXT
The longest server text a failure keeps. A refusal's explanation comes last, after any transfer progr...
APIEXPORT KIGIT_OWNERSHIP_REFUSAL DescribeOwnershipRefusal(const wxString &aStartDir, const wxString &aGitDir)
The message for a repository git refuses to open because another user owns it.
APIEXPORT wxString DecodeServerText(const char *aData, size_t aLength)
Bytes a server sent, as UTF-8 or, when they are not valid UTF-8, one character for each byte.
APIEXPORT bool IsCredentialFailure(KIGIT_FAILURE aKind)
True for the failures another login, key or passphrase can fix, which the credential prompt answers.
APIEXPORT KIGIT_FAILURE_REPORT DescribeGitFailure(const KIGIT_ERROR_INFO &aError, const KIGIT_AUTH_ATTEMPT &aAuth, const KIGIT_FAILURE_CONTEXT &aContext)
Turn a failed transfer into a message the user can act on.
APIEXPORT wxString UnexplainedFailure(KIGIT_OPERATION aOperation, const wxString &aUrl)
The summary for an operation that failed without saying why, naming the server it was talking to.
What the credential callback handed out during one operation, kept to explain a rejection.
bool lastKeyRefused
The server refused the last key's public half.
wxString probing
The encrypted key whose public half is out to the server now.
bool passwordGiven
A password went with the last username offered.
KIGIT_COMMON::GIT_CONN_TYPE connType
wxString acceptedKey
An encrypted key whose public half the server accepted.
std::vector< wxString > keysTried
Key files offered, in order.
bool agentTried
The SSH agent was offered before any key file.
bool passphraseGiven
A passphrase went with the last key file offered.
What libgit2 reported for a failed call, read before anything else can replace it.
What the failed operation was doing, as far as the message needs it.
KIGIT_OPERATION operation
std::optional< KIGIT::HOST_KEY_FAILURE > hostKey
The host key the operation refused, if any.
wxString hostKeyRefusal
Why a key that cannot be trusted was refused.
bool authFailed
The credential callback had nothing left to offer.
wxString url
The address connected to. Messages show only its host and its stripped form.
wxString remoteName
Empty when the operation has no named remote, as for a clone.
wxString pushRefusal
The status the server gave a refused branch.
wxString serverMessage
Text the server sent for the user.
wxString summary
What happened and what to do next, in the user's terms. Never raw text.
wxString details
The raw error, the server's text and the address without its password.
Why git will not open a repository another user owns, and the command that trusts it.
bool coversHome
The repository's folder is the home folder or above it.
wxString trustCommand
Kept apart from the summary so it can be shown in full and copied.