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
40
41
64
65
75
76
79{
81 wxString remoteName;
82 wxString url;
83 bool authFailed = false;
84
85 std::optional<KIGIT::HOST_KEY_FAILURE> hostKey;
86 wxString hostKeyRefusal;
87 wxString pushRefusal;
88 wxString serverMessage;
89};
90
91
98
99
102{
103 wxString summary;
104 wxString trustCommand;
107};
108
109
110namespace KIGIT
111{
112
121 const KIGIT_FAILURE_CONTEXT& aContext );
122
124APIEXPORT wxString UnexplainedFailure( KIGIT_OPERATION aOperation, const wxString& aUrl );
125
128
130constexpr size_t MAX_SERVER_TEXT = 4096;
131
133APIEXPORT wxString DecodeServerText( const char* aData, size_t aLength );
134
136APIEXPORT wxString StripEmbeddedUserinfo( const wxString& aText );
137
142APIEXPORT wxString PrintableServerText( const wxString& aText );
143
151APIEXPORT KIGIT_OWNERSHIP_REFUSAL DescribeOwnershipRefusal( const wxString& aStartDir, const wxString& aGitDir );
152
153} // namespace KIGIT
154
155#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.
@ 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.
KIGIT_COMMON::GIT_CONN_TYPE connType
std::vector< wxString > keysTried
Key files offered, in order.
bool agentTried
The SSH agent was offered before any key file.
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.
wxString trustCommand
Kept apart from the summary so it can be shown in full and copied.