7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-18 19:29:17 +00:00

Fix git push for some configurations

Reset ssh test keys prior to pushing.  Specify head reference
This commit is contained in:
Seth Hillbrand 2025-02-12 13:00:46 -08:00
parent 38359fe568
commit 7edacd4fb8
2 changed files with 31 additions and 7 deletions

View File

@ -53,13 +53,17 @@ PushResult GIT_PUSH_HANDLER::PerformPush()
remoteCallbacks.transfer_progress = transfer_progress_cb;
remoteCallbacks.update_tips = update_cb;
remoteCallbacks.push_transfer_progress = push_transfer_progress_cb;
remoteCallbacks.credentials = credentials_cb;
remoteCallbacks.payload = this;
m_testedTypes = 0;
ResetNextKey();
if( git_remote_connect( remote, GIT_DIRECTION_PUSH, &remoteCallbacks, nullptr, nullptr ) )
{
git_remote_free( remote );
AddErrorString( wxString::Format( _( "Could not connect to remote: %s" ),
git_error_last()->message ) );
git_remote_free( remote );
return PushResult::Error;
}
@ -67,14 +71,34 @@ PushResult GIT_PUSH_HANDLER::PerformPush()
git_push_init_options( &pushOptions, GIT_PUSH_OPTIONS_VERSION );
pushOptions.callbacks = remoteCallbacks;
if( git_remote_push( remote, nullptr, &pushOptions ) )
// Get the current HEAD reference
git_reference* head = nullptr;
if( git_repository_head( &head, m_repo ) != 0 )
{
AddErrorString( _( "Could not get repository head" ) );
git_remote_free( remote );
AddErrorString( wxString::Format( _( "Could not push to remote: %s" ),
git_error_last()->message ) );
return PushResult::Error;
}
// Create refspec for current branch
const char* refs[1];
refs[0] = git_reference_name( head );
const git_strarray refspecs = { (char**) refs, 1 };
git_reference_free(head);
if( git_remote_push( remote, &refspecs, &pushOptions ) )
{
AddErrorString( wxString::Format( _( "Could not push to remote: %s" ),
git_error_last()->message ) );
git_remote_disconnect( remote );
git_remote_free( remote );
return PushResult::Error;
}
git_remote_disconnect( remote );
git_remote_free( remote );
return result;
}

View File

@ -678,15 +678,15 @@ extern "C" int update_cb( const char* aRefname, const git_oid* aFirst, const git
extern "C" int push_transfer_progress_cb( unsigned int aCurrent, unsigned int aTotal, size_t aBytes,
void* aPayload )
{
int64_t progress = 100;
long long progress = 100;
KIGIT_COMMON* parent = (KIGIT_COMMON*) aPayload;
if( aTotal != 0 )
{
progress = ( aCurrent * 100 ) / aTotal;
progress = ( aCurrent * 100ll ) / aTotal;
}
wxString progressMessage = wxString::Format( _( "Writing objects: %d%% (%d/%d), %d bytes" ),
wxString progressMessage = wxString::Format( _( "Writing objects: %lld%% (%u/%u), %zu bytes" ),
progress, aCurrent, aTotal, aBytes );
parent->UpdateProgress( aCurrent, aTotal, progressMessage );