KiCad PCB EDA Suite
Loading...
Searching...
No Matches
git_push_handler.cpp
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, you may find one here:
18 * http://www.gnu.org/licenses/gpl-3.0.html
19 * or you may search the http://www.gnu.org website for the version 3 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#include "git_push_handler.h"
26
27#include <iostream>
28
30{}
31
32
34{}
35
36
38{
39 PushResult result = PushResult::Success;
40
41 // Fetch updates from remote repository
42 git_remote* remote = nullptr;
43
44 if( git_remote_lookup( &remote, m_repo, "origin" ) != 0 )
45 {
46 AddErrorString( _( "Could not lookup remote" ) );
47 return PushResult::Error;
48 }
49
50 git_remote_callbacks remoteCallbacks;
51 git_remote_init_callbacks( &remoteCallbacks, GIT_REMOTE_CALLBACKS_VERSION );
52 remoteCallbacks.sideband_progress = progress_cb;
53 remoteCallbacks.transfer_progress = transfer_progress_cb;
54 remoteCallbacks.update_tips = update_cb;
55 remoteCallbacks.push_transfer_progress = push_transfer_progress_cb;
56 remoteCallbacks.payload = this;
57
58 if( git_remote_connect( remote, GIT_DIRECTION_PUSH, &remoteCallbacks, nullptr, nullptr ) )
59 {
60 git_remote_free( remote );
61 AddErrorString( wxString::Format( _( "Could not connect to remote: %s" ),
62 git_error_last()->message ) );
63 return PushResult::Error;
64 }
65
66 git_push_options pushOptions;
67 git_push_init_options( &pushOptions, GIT_PUSH_OPTIONS_VERSION );
68 pushOptions.callbacks = remoteCallbacks;
69
70 if( git_remote_push( remote, nullptr, &pushOptions ) )
71 {
72 git_remote_free( remote );
73 AddErrorString( wxString::Format( _( "Could not push to remote: %s" ),
74 git_error_last()->message ) );
75 return PushResult::Error;
76 }
77
78 return result;
79}
80
81
82void GIT_PUSH_HANDLER::UpdateProgress( int aCurrent, int aTotal, const wxString& aMessage )
83{
84 ReportProgress( aCurrent, aTotal, aMessage );
85}
void ReportProgress(int aCurrent, int aTotal, const wxString &aMessage)
Definition: git_progress.h:45
GIT_PUSH_HANDLER(KIGIT_COMMON *aRepo)
PushResult PerformPush()
void UpdateProgress(int aCurrent, int aTotal, const wxString &aMessage) override
git_repository * m_repo
void AddErrorString(const wxString aErrorString)
#define _(s)
PushResult
int update_cb(const char *aRefname, const git_oid *aFirst, const git_oid *aSecond, void *aPayload)
int transfer_progress_cb(const git_transfer_progress *aStats, void *aPayload)
int push_transfer_progress_cb(unsigned int aCurrent, unsigned int aTotal, size_t aBytes, void *aPayload)
int progress_cb(const char *str, int len, void *data)