KiCad PCB EDA Suite
Loading...
Searching...
No Matches
panel_git_branches.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 modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
21
22#include <algorithm>
23#include <memory>
24#include <vector>
25
26#include <wx/richmsgdlg.h>
27#include <wx/textdlg.h>
28
29#include <confirm.h>
34#include <eda_base_frame.h>
37#include <git/kigit_failure.h>
38#include <project.h>
39
40
42 PANEL_GIT_BRANCHES_BASE( aParent ),
43 m_dialog( aDialog ),
44 m_frame( aFrame )
45{
46 m_branchSearch->SetDescriptiveText( _( "Search branches" ) );
47
48 m_branchesList->AppendColumn( _( "Branch" ), wxLIST_FORMAT_LEFT, FromDIP( 220 ) );
49 m_branchesList->AppendColumn( _( "Status" ), wxLIST_FORMAT_LEFT, FromDIP( 70 ) );
50 m_branchesList->AppendColumn( _( "Commit" ), wxLIST_FORMAT_LEFT, FromDIP( 100 ) );
51 m_branchesList->AppendColumn( _( "Date" ), wxLIST_FORMAT_LEFT, FromDIP( 90 ) );
52
55
57
58 // The detail pane appears once a branch is selected.
59 m_branchSashPos = FromDIP( 460 );
61
62 m_branchSearch->Bind( wxEVT_TEXT,
63 [this]( wxCommandEvent& )
64 {
66 } );
67
68 m_branchesList->Bind( wxEVT_LIST_ITEM_SELECTED,
69 [this]( wxListEvent& aEvent )
70 {
72 showBranchDetail( m_branchesList->GetItemText( aEvent.GetIndex(), 0 ) );
73 } );
74
75 m_branchesList->Bind( wxEVT_LIST_ITEM_DESELECTED,
76 [this]( wxListEvent& )
77 {
79 && m_branchesList->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED ) == -1 )
80 {
82 }
83 } );
84
85 // Double-clicking a branch switches the working tree to it.
86 m_branchesList->SetToolTip( _( "Double click a local branch to switch the project to it." ) );
87 m_branchesList->Bind( wxEVT_LIST_ITEM_ACTIVATED,
88 [this]( wxListEvent& aEvent )
89 {
90 int row = aEvent.GetIndex();
91
92 // A remote branch is someone else's work to start from, not
93 // somewhere to stand, so New Branch is the way to take it up.
94 if( row < static_cast<int>( m_branchIsRemote.size() ) && m_branchIsRemote[row] )
95 {
96 DisplayInfoMessage( this, _( "This branch is on the remote. Select it and "
97 "press New Branch to start your own branch "
98 "from it." ) );
99 return;
100 }
101
102 m_dialog->SwitchToBranch( m_branchesList->GetItemText( row, 0 ) );
103 } );
104
105 m_newBranchButton->Bind( wxEVT_BUTTON,
106 [this]( wxCommandEvent& )
107 {
108 onNewBranch();
109 } );
110 m_deleteBranchButton->Bind( wxEVT_BUTTON,
111 [this]( wxCommandEvent& )
112 {
114 } );
115 m_forcePushButton->Bind( wxEVT_BUTTON,
116 [this]( wxCommandEvent& )
117 {
119 onForcePush();
120 } );
121}
122
123
128
129
131{
132 m_push.Cancel();
133
134 // The completion never reaches a closed window to release it
135 m_pushBusy.Release();
136}
137
138
140{
141 if( !m_dialog->SessionStillCurrent() )
142 return;
143
144 m_detailQuery.Cancel();
145
146 auto branches = std::make_shared<std::vector<KIGIT_BRANCH_INFO>>();
147
148 m_listQuery.Run(
149 m_frame->Prj().GetGitCommon(),
150 [branches]( KIGIT_COMMON& aCommon )
151 {
152 *branches = aCommon.GetBranches();
153 KIGIT::SortBranchesForDisplay( *branches );
154 },
155 [this, branches]()
156 {
157 if( !m_dialog->SessionStillCurrent() )
158 return;
159
160 // Preserve selections and search edits made while the repository was being read.
161 wxString search = m_branchSearch->GetValue().Lower();
162 wxString selected = KIGIT::SelectedText( m_branchesList, 0 );
163 long selectRow = wxNOT_FOUND;
164
165 m_detailQuery.Cancel();
166 m_fillingBranches = true;
167 m_branchesList->DeleteAllItems();
168 m_branchIsRemote.clear();
169
170 for( const KIGIT_BRANCH_INFO& branch : *branches )
171 {
172 if( !search.IsEmpty() && !branch.name.Lower().Contains( search ) )
173 continue;
174
175 long idx = m_branchesList->InsertItem( m_branchesList->GetItemCount(), branch.name );
176
177 if( branch.isCurrent )
178 m_branchesList->SetItem( idx, 1, _( "current" ) );
179 else if( branch.isRemote )
180 m_branchesList->SetItem( idx, 1, _( "remote" ) );
181
182 m_branchesList->SetItem( idx, 2, branch.tipHash );
183 m_branchesList->SetItem( idx, 3, KIGIT::RelativeDate( branch.when ) );
184 m_branchIsRemote.push_back( branch.isRemote );
185
186 // Keep the selection where it was, or start on the current branch.
187 if( branch.name == selected || ( selected.IsEmpty() && branch.isCurrent ) )
188 selectRow = idx;
189 }
190
191 // Relative dates vary in length with the language and font, so the column follows its text
192 if( m_branchesList->GetItemCount() > 0 )
193 {
194 m_branchesList->SetColumnWidth( 3, wxLIST_AUTOSIZE );
195 m_branchesList->SetColumnWidth( 3, std::max( m_branchesList->GetColumnWidth( 3 ), FromDIP( 90 ) ) );
196 }
197
198 int shown = m_branchesList->GetItemCount();
199 m_branchCount->SetLabel( wxString::Format( wxPLURAL( "%d branch", "%d branches", shown ), shown ) );
200
201 if( selectRow != wxNOT_FOUND )
202 {
203 m_branchesList->SetItemState( selectRow, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
204 showBranchDetail( m_branchesList->GetItemText( selectRow, 0 ) );
205 }
206 else
207 {
209 }
210
211 m_fillingBranches = false;
212 } );
213}
214
215
220
221
222void PANEL_GIT_BRANCHES::showBranchDetail( const wxString& aBranch )
223{
225
226 if( aBranch.IsEmpty() || !m_dialog->SessionStillCurrent() )
227 return;
228
229 auto detail = std::make_shared<KIGIT_BRANCH_DETAIL>();
230
231 m_detailQuery.Run(
232 m_frame->Prj().GetGitCommon(),
233 [detail, aBranch]( KIGIT_COMMON& aCommon )
234 {
235 *detail = aCommon.GetBranchDetail( aBranch );
236 },
237 [this, detail, aBranch]()
238 {
239 if( m_dialog->SessionStillCurrent() && KIGIT::SelectedText( m_branchesList, 0 ) == aBranch )
240 {
241 fillBranchDetail( *detail );
242 }
243 } );
244}
245
246
248{
249 if( !aDetail.found )
250 {
252 return;
253 }
254
255 m_branchTitle->SetLabel( wxString::Format( _( "Branch: %s" ), aDetail.name ) );
256 m_branchCommit->SetLabel(
257 wxString::Format( _( "Commit: %s, %s" ), aDetail.tipHash, KIGIT::RelativeDate( aDetail.when ) ) );
258 m_branchAuthor->SetLabel( wxString::Format( _( "Author: %s <%s>" ), aDetail.author, aDetail.email ) );
259 m_branchMessage->ChangeValue( aDetail.message );
260
261 wxString sync;
262
263 if( aDetail.upstream.IsEmpty() )
264 sync = _( "Not tracking another branch." );
265 else if( !aDetail.divergence )
266 sync = wxString::Format( _( "Could not compare with %s." ), aDetail.upstream );
267 else
268 {
269 const KIGIT_AHEAD_BEHIND& counts = *aDetail.divergence;
270
271 if( counts.ahead == 0 && counts.behind == 0 )
272 sync = wxString::Format( _( "Up to date with %s." ), aDetail.upstream );
273 else if( counts.behind == 0 )
274 sync = wxString::Format( wxPLURAL( "%zu commit ahead of %s.", "%zu commits ahead of %s.", counts.ahead ),
275 counts.ahead, aDetail.upstream );
276 else if( counts.ahead == 0 )
277 sync = wxString::Format( wxPLURAL( "%zu commit behind %s.", "%zu commits behind %s.", counts.behind ),
278 counts.behind, aDetail.upstream );
279 else
280 sync = wxString::Format( wxPLURAL( "%zu commit ahead and %zu behind %s.",
281 "%zu commits ahead and %zu behind %s.", counts.ahead ),
282 counts.ahead, counts.behind, aDetail.upstream );
283 }
284
285 m_branchSync->SetLabel( sync );
286
287 if( !m_branchesSplitter->IsSplit() )
289
290 m_branchDetail->Layout();
291}
292
293
299
300
302{
303 if( !m_dialog->SessionStillCurrent() )
304 return;
305
306 // The new branch starts where the selected one is, so a branch can be made off any other.
307 wxString from = KIGIT::SelectedText( m_branchesList, 0 );
308 wxString prompt =
309 from.IsEmpty() ? _( "New branch name:" ) : wxString::Format( _( "New branch from '%s', name:" ), from );
310 wxString name;
311 wxString nameError;
312
313 do
314 {
315 if( !nameError.IsEmpty() )
316 DisplayErrorMessage( this, nameError );
317
318 name = wxGetTextFromUser( prompt, _( "New Branch" ), name, this );
319
320 if( name.IsEmpty() || !m_dialog->SessionStillCurrent() )
321 return;
322
323 nameError = KIGIT::BranchNameError( name );
324 } while( !nameError.IsEmpty() );
325
326 m_dialog->RunGitAction(
327 [name, from]( KIGIT_COMMON& aCommon )
328 {
329 return aCommon.CreateBranch( name, from );
330 },
331 wxString::Format( _( "Could not create branch '%s'." ), name ) );
332}
333
334
336{
337 if( !m_dialog->SessionStillCurrent() )
338 return;
339
340 wxString name = KIGIT::SelectedText( m_branchesList, 0 );
341
342 if( name.IsEmpty() )
343 return;
344
345 // Deleting a remote-tracking branch would mean deleting it on the server, and the lookup
346 // below could otherwise hit a local branch of the same name.
347 if( KIGIT::SelectedText( m_branchesList, 1 ) == _( "remote" ) )
348 {
349 DisplayInfoMessage( this, _( "This branch lives on the remote, so it cannot be deleted from here." ) );
350 return;
351 }
352
353 struct OUTCOME
354 {
355 wxString current;
356 std::optional<size_t> unmerged;
357 bool checked = false;
358 };
359
360 auto outcome = std::make_shared<OUTCOME>();
361
362 m_actionQuery.Run(
363 m_frame->Prj().GetGitCommon(),
364 [outcome, name]( KIGIT_COMMON& aCommon )
365 {
366 outcome->current = aCommon.GetCurrentBranchName();
367 outcome->unmerged = aCommon.GetUnmergedCommitCount( name );
368 outcome->checked = true;
369 },
370 [this, outcome, name]()
371 {
372 if( !m_dialog->SessionStillCurrent() || !outcome->checked )
373 return;
374
375 if( name == outcome->current )
376 {
377 DisplayErrorMessage( this, _( "You cannot delete the branch you are on." ) );
378 return;
379 }
380
381 if( !outcome->unmerged )
382 {
383 DisplayErrorMessage( this, _( "Could not compare this branch with the current version." ) );
384 return;
385 }
386
387 wxString question;
388
389 if( *outcome->unmerged == 1 )
390 {
391 question = wxString::Format( _( "Branch '%s' has one commit that is not in the current version."
392 "\n\nDelete it anyway?" ),
393 name );
394 }
395 else if( *outcome->unmerged > 1 )
396 {
397 question = wxString::Format( _( "Branch '%s' has %zu commits that are not in the current version."
398 "\n\nDelete it anyway?" ),
399 name, *outcome->unmerged );
400 }
401 else
402 {
403 question = wxString::Format( _( "Delete branch '%s'?" ), name );
404 }
405
406 wxRichMessageDialog confirm( this, question, _( "Delete Branch" ),
407 wxYES_NO | wxNO_DEFAULT | wxICON_WARNING | wxCENTER );
408 confirm.SetYesNoLabels( _( "&Delete" ), _( "Cancel" ) );
409
410 if( confirm.ShowModal() != wxID_YES || !m_dialog->SessionStillCurrent() )
411 return;
412
413 m_dialog->RunGitAction(
414 [name]( KIGIT_COMMON& aCommon )
415 {
416 return aCommon.DeleteBranch( name );
417 },
418 wxString::Format( _( "Could not delete branch '%s'." ), name ) );
419 } );
420}
421
422
423void PANEL_GIT_BRANCHES::onForcePush( bool aRetriedAfterTrust )
424{
425 if( m_push.IsBusy() )
426 {
428 return;
429 }
430
431 if( !m_dialog->SessionStillCurrent() )
432 return;
433
434 struct OUTCOME
435 {
436 wxString branch;
437 wxString headOid;
438 wxString upstream;
439 wxString remoteName;
440 wxString pushUrl;
441 bool hasRemote = false;
442 bool detached = false;
443 bool checked = false;
444 };
445
446 std::shared_ptr<KIGIT_COMMON> common = m_frame->Prj().GetGitCommon();
447 auto outcome = std::make_shared<OUTCOME>();
448
449 // Read the keyring before the confirmation, so no unlock prompt comes between it and the push
450 if( KIGIT_COMMON::DeferForSecret( common, m_push.Alive(),
451 [this, aRetriedAfterTrust]()
452 {
453 // Checks again that nothing started and the session is still this one
454 onForcePush( aRetriedAfterTrust );
455 } ) )
456 {
457 return;
458 }
459
460 m_actionQuery.Run(
461 common,
462 [outcome]( KIGIT_COMMON& aCommon )
463 {
464 outcome->hasRemote = aCommon.HasPushAndPullRemote();
465 outcome->detached = aCommon.IsHeadDetached();
466 outcome->branch = aCommon.GetCurrentBranchName();
467 outcome->headOid = aCommon.GetHeadCommitId();
468
469 // Push targets the same-named remote ref, even with a differently named upstream.
470 outcome->remoteName = aCommon.GetRemoteNameOrDefault();
471 outcome->pushUrl = aCommon.GetPushUrl( outcome->remoteName );
472 outcome->upstream = outcome->remoteName + wxS( "/" ) + outcome->branch;
473 outcome->checked = true;
474 },
475 [this, common, outcome, aRetriedAfterTrust]()
476 {
477 if( !m_dialog->SessionStillCurrent() || !outcome->checked || m_push.IsBusy() )
478 return;
479
480 if( outcome->detached )
481 {
482 DisplayInfoMessage( this,
483 _( "This project is showing an old snapshot rather than a branch, so there "
484 "is no branch to push. Double click a branch to go back to it first." ) );
485 return;
486 }
487
488 if( !outcome->hasRemote )
489 {
490 DisplayInfoMessage( this, _( "No remote is configured to push to." ) );
491 return;
492 }
493
494 wxRichMessageDialog confirm(
495 this,
496 wxString::Format( _( "Force push replaces '%s' at %s with your local '%s'.\n\n"
497 "Commits that exist only on the remote will be lost." ),
498 outcome->upstream, KIGIT::StripEmbeddedUserinfo( outcome->pushUrl ),
499 outcome->branch ),
500 _( "Force Push" ), wxYES_NO | wxNO_DEFAULT | wxICON_WARNING | wxCENTER );
501 confirm.SetYesNoLabels( _( "Force &Push" ), _( "Cancel" ) );
502
503 if( confirm.ShowModal() != wxID_YES || !m_dialog->SessionStillCurrent() )
504 return;
505
506 // Two clicks during a keyring read each reach a confirmation, and the second must not replace the first
507 if( m_push.IsBusy() )
508 {
510 return;
511 }
512
513 startForcePush( common, outcome->branch, outcome->headOid, outcome->remoteName, outcome->pushUrl,
514 aRetriedAfterTrust );
515 } );
516}
517
518
519void PANEL_GIT_BRANCHES::startForcePush( std::shared_ptr<KIGIT_COMMON> aCommon, const wxString& aExpectedBranch,
520 const wxString& aExpectedHeadOid, const wxString& aRemoteName,
521 const wxString& aPushUrl, bool aRetriedAfterTrust )
522{
523 // Carried rather than captured by reference, because Start returns before the work runs.
524 struct OUTCOME
525 {
527 wxString error;
528 wxString details;
529 bool authFailure = false;
530 bool cancelled = false;
531
532 std::optional<KIGIT::HOST_KEY_FAILURE> hostKey;
533 };
534
535 auto outcome = std::make_shared<OUTCOME>();
536
537 m_pushBusy.Begin( aCommon, _( "Pushing..." ),
538 [this]()
539 {
540 m_push.Cancel();
541 } );
542
543 bool started = m_push.Start(
544 "git force push",
545 [aCommon, outcome, aExpectedBranch, aExpectedHeadOid, aRemoteName, aPushUrl, alive = m_push.Alive(),
546 dialog = m_dialog]( const KIGIT_COMMON::CANCEL_TOKEN& aToken )
547 {
548 GIT_PUSH_HANDLER handler( aCommon.get() );
549 handler.SetProgressReporter( std::make_unique<KIGIT_STATUS_REPORTER>(
550 alive,
551 [dialog]( const wxString& aText )
552 {
553 dialog->ShowTransferProgress( aText );
554 } ) );
555 handler.SetCancelToken( aToken );
556 handler.SetWaitForActionLock( true );
557 handler.SetExpectedTarget( aExpectedBranch, aExpectedHeadOid );
558 handler.SetExpectedDestination( aRemoteName, aPushUrl );
559 outcome->result = handler.PerformPush( true );
560 KIGIT_ERROR_MESSAGE error = handler.PopError();
561 outcome->error = error.summary;
562 outcome->details = error.details;
563 outcome->authFailure = handler.WasAuthFailure();
564 outcome->hostKey = handler.GetHostKeyFailure();
565
566 // This operation's own token, so a force push that never became active cannot
567 // consume a cancel belonging to the transfer that is running.
568 outcome->cancelled = handler.IsThisOperationCancelled();
569
570 // The other surfaces need this even when the page that started it has gone.
571 if( outcome->result == PushResult::Success && !outcome->cancelled )
572 {
574 [aCommon]()
575 {
576 aCommon->NotifyRefreshListeners();
577 } );
578 }
579 },
580 [this, aCommon, outcome, aRetriedAfterTrust]()
581 {
582 if( !m_dialog->SessionStillCurrent() )
583 return;
584
585 m_pushBusy.Release();
586
587 if( !outcome->cancelled && outcome->result == PushResult::Success )
588 KIGIT::ClearSyncWarnings( aCommon.get() );
589
590 if( outcome->cancelled || outcome->result == PushResult::Success )
591 {
592 m_credentialPrompts = 0;
593 return;
594 }
595
596 if( outcome->result == PushResult::Busy )
597 {
598 m_credentialPrompts = 0;
600 return;
601 }
602
604 failure.authFailure = outcome->authFailure;
605 failure.hostKey = outcome->hostKey;
606 failure.error = outcome->error;
607
608 switch( KIGIT::AnswerTransferFailure( this, m_push.Alive(), aCommon.get(), &m_frame->Prj(), failure,
609 aRetriedAfterTrust, m_credentialPrompts ) )
610 {
611 case KIGIT::TRANSFER_RETRY::RETRY: onForcePush( aRetriedAfterTrust ); return;
612
613 case KIGIT::TRANSFER_RETRY::RETRY_TRUSTED: onForcePush( true ); return;
614
615 // Declining a prompt is the user's answer, not an error
616 case KIGIT::TRANSFER_RETRY::CANCELLED: m_dialog->ShowTransferProgress( _( "Cancelled." ) ); return;
617
619 case KIGIT::TRANSFER_RETRY::GONE: return;
620
622 }
623
624 wxString error = outcome->error;
625
626 if( error.IsEmpty() )
627 error = KIGIT::UnexplainedFailure( KIGIT_OPERATION::PUSH, aCommon->GetRemote() );
628
629 DisplayErrorMessage( this, error, outcome->details );
630 } );
631
632 if( !started )
633 {
634 m_pushBusy.Release();
635 DisplayInfoMessage( this, _( "Could not start the force push." ) );
636 }
637}
const char * name
The base frame for deriving all KiCad main window classes.
The advanced Git window: a non-modal dialog with a top bar naming the repository and branch and a sid...
The project's git session.
static bool DeferForSecret(const std::shared_ptr< KIGIT_COMMON > &aCommon, const std::weak_ptr< bool > &aOwner, std::function< void()> aRetry)
Read the remote's secret from the keyring on the UI thread without blocking it, so an unlock prompt c...
std::shared_ptr< std::atomic< bool > > CANCEL_TOKEN
One token per operation.
wxString GetCurrentBranchName() const
wxString GetRemoteNameOrDefault() const
Returns GetRemotename() when non-empty, otherwise "origin".
wxString GetPushUrl(const wxString &aRemoteName) const
The address a push to aRemoteName connects to, its push URL or else its URL. Empty without one.
bool CreateBranch(const wxString &aName, const wxString &aFrom=wxEmptyString)
wxString GetHeadCommitId() const
Full commit ID at HEAD, or empty for an unborn or missing HEAD.
bool HasPushAndPullRemote() const
bool IsHeadDetached() const
True when HEAD points at a commit rather than a branch, as after checking out a tag.
WX_SPLITTER_WINDOW * m_branchesSplitter
PANEL_GIT_BRANCHES_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
void StopTransfer()
Ask a force push still running to stop. It finishes on its own.
PANEL_GIT_BRANCHES(wxWindow *aParent, GIT_ADVANCED_DIALOG *aDialog, EDA_BASE_FRAME *aFrame)
void fillBranchDetail(const KIGIT_BRANCH_DETAIL &aDetail)
int m_branchSashPos
Where the user left the sash between the list and its detail pane.
KIGIT_QUERY m_listQuery
List and detail reads share the session lock without waiting on the UI thread.
void onForcePush(bool aRetriedAfterTrust=false)
Force push the current branch, after an explicit confirmation.
void showBranchDetail(const wxString &aBranch)
Fill the detail pane with aBranch, or hide it when the name is empty or gone.
int m_credentialPrompts
Keyring reads and credential prompts the current force push has shown, reset when it ends.
GIT_ADVANCED_DIALOG * m_dialog
void reloadBranches()
Refill the list after the search text changed.
void Populate()
Fill the list from the repository's branches. The repository is read on a worker.
EDA_BASE_FRAME * m_frame
GIT_TRANSFER_BUSY::HOLD m_pushBusy
The force push's hold on its repository while it runs.
std::vector< bool > m_branchIsRemote
Whether each listed row is a remote-tracking branch.
void startForcePush(std::shared_ptr< KIGIT_COMMON > aCommon, const wxString &aExpectedBranch, const wxString &aExpectedHeadOid, const wxString &aRemoteName, const wxString &aPushUrl, bool aRetriedAfterTrust)
KIGIT_TRANSFER m_push
The force push this page started.
KIGIT_QUERY m_actionQuery
Reads needed before an action's confirmation, separate from list refreshes.
bool m_fillingBranches
True while the list is being refilled, when its selection events are its own.
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition confirm.cpp:245
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition confirm.cpp:217
This file is part of the common library.
#define _(s)
Base window classes and related definitions.
PushResult
@ Busy
Another git operation held the action lock, so nothing was pushed.
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...
void ClearSyncWarnings(wxWindow *aWindow)
Clear the background fetch's warnings from the frame holding aWindow.
wxString BranchNameError(const wxString &aName)
Empty when aName is a branch name git would accept, otherwise why it would not, in the words to show ...
void UnsplitKeepingSash(wxSplitterWindow *aSplitter, wxWindow *aPane, int &aSashPos)
Close a splitter's second pane, keeping the sash where the user left it for next time.
void ShowBusyMessage(wxWindow *aParent)
Show a busy message for a user action. UI thread only.
TRANSFER_RETRY AnswerTransferFailure(wxWindow *aParent, const std::weak_ptr< bool > &aAlive, KIGIT_COMMON *aCommon, PROJECT *aProject, const TRANSFER_FAILURE &aFailure, bool aRetriedAfterTrust, int &aPrompts)
Answer a failed transfer the way every window does.
wxString SelectedText(wxListCtrl *aList, int aColumn)
The text of the selected row in a report list, or empty when nothing is selected.
@ RETRY_TRUSTED
Run it again, now that the server's key is trusted.
@ GONE
The window closed during a prompt, so the caller must not touch it.
@ CANCELLED
Stop and say so, the user cancelled the transfer or a prompt.
@ RETRY
Run the transfer again.
@ HOST_DECLINED
Stop without a message, the user chose not to trust the server.
wxString RelativeDate(const wxDateTime &aWhen)
"just now", "3 hours ago", or the ISO date once it is more than a month old.
void KeepDetailWidth(WX_SPLITTER_WINDOW *aSplitter)
Keep a split detail pane at the width its controls need, against both a narrow window and a dragged s...
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.
void CallOnUi(std::function< void()> aFn)
Run aFn on the UI thread.
void MarkDestructive(wxButton *aButton)
Paint a button's text the diff's red, for one that throws something away.
Why a transfer to a remote failed.
std::optional< HOST_KEY_FAILURE > hostKey
The server's key is unknown or has changed.
bool authFailure
The remote refused every credential offered.
wxString error
Shown above the credential fields.
size_t behind
Commits only in the second reference.
size_t ahead
Commits only in the first reference.
std::optional< KIGIT_AHEAD_BEHIND > divergence
Comparison with upstream, if it could be read.
wxString upstream
The branch this one tracks, or empty.
A summary the user can act on, with the raw text that explains it kept apart for the details.
wxString result
Test unit parsing edge cases and error handling.