KiCad PCB EDA Suite
Loading...
Searching...
No Matches
kigit_transport.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
27
28#ifndef KIGIT_TRANSPORT_H
29#define KIGIT_TRANSPORT_H
30
31#include <import_export.h>
32
33#include <git2.h>
34#include <wx/string.h>
35
36#include <functional>
37#include <memory>
38#include <vector>
39
41struct KIGIT_ERROR_INFO;
42
43namespace KIGIT
44{
45
47{
48public:
55 explicit REMOTE_TRANSPORT( KIGIT_REPO_MIXIN* aHandler, git_remote* aRemote = nullptr,
56 bool aFollowRedirects = true );
58
61
63 int Fetch( std::vector<wxString>* aBranches = nullptr );
64
69 int Push( const std::function<wxString()>& aConnected );
70
72 int Check();
73
75 int Clone( const wxString& aUrl, const wxString& aPath, git_repository** aRepo );
76
78 const KIGIT_ERROR_INFO& Error() const;
79
80 struct STATE;
81
82private:
83 int connect( git_direction aDirection, const git_remote_callbacks& aCallbacks );
84
85 std::unique_ptr<STATE> m_state;
86 git_remote* m_remote;
88};
89
90} // namespace KIGIT
91
92#endif // KIGIT_TRANSPORT_H
std::unique_ptr< STATE > m_state
REMOTE_TRANSPORT(const REMOTE_TRANSPORT &)=delete
REMOTE_TRANSPORT(KIGIT_REPO_MIXIN *aHandler, git_remote *aRemote=nullptr, bool aFollowRedirects=true)
aHandler supplies the session and records progress, the credentials offered and why a call failed.
int Fetch(std::vector< wxString > *aBranches=nullptr)
Fetch as git fetch would. aBranches, when given, receives the branches the remote advertised.
int Check()
Connect, which proves the credentials and the host key without transferring anything.
REMOTE_TRANSPORT & operator=(const REMOTE_TRANSPORT &)=delete
int Clone(const wxString &aUrl, const wxString &aPath, git_repository **aRepo)
Clone aUrl into aPath. The new repository is returned in aRepo for the caller to free.
int Push(const std::function< wxString()> &aConnected)
Connect, then push the refspec aConnected answers, so the caller can check what it pushes after a con...
int connect(git_direction aDirection, const git_remote_callbacks &aCallbacks)
#define APIEXPORT
Macros which export functions from a DLL/DSO.
What libgit2 reported for a failed call, read before anything else can replace it.