28#include <wx/richmsgdlg.h>
29#include <wx/stdpaths.h>
32#include <wx/textdlg.h>
34#include <wx/wupdlock.h>
36#include <wx/dcclient.h>
37#include <wx/progdlg.h>
38#include <wx/settings.h>
39#include <wx/weakref.h>
109 return aTask.valid() && aTask.wait_for( std::chrono::seconds( 0 ) ) != std::future_status::ready;
117struct IGNORE_SELECTION
119 std::vector<GIT_IGNORE_TARGET> targets;
122 wxString extensionRule;
125 bool canIgnore =
false;
128 bool ignored =
false;
131 bool canKeepPath =
false;
132 bool canKeepExtension =
false;
137IGNORE_SELECTION gitIgnoreSelection(
KIGIT_COMMON& aCommon,
const wxString& aProjectPath,
138 const std::vector<PROJECT_TREE_ITEM*>& aSelection )
142 IGNORE_SELECTION selection;
143 bool allIgnored =
true;
144 bool allNamed =
true;
145 bool allFiles =
true;
146 bool anyTracked =
false;
151 return IGNORE_SELECTION();
153 wxString
path = item->GetFileName();
155 if( !
path.StartsWith( aProjectPath ) )
156 return IGNORE_SELECTION();
158 path =
path.Mid( aProjectPath.length() );
161 path.Replace( wxS(
"\\" ), wxS(
"/" ) );
166 return IGNORE_SELECTION();
174 allFiles &= !isDirectory;
178 if( selection.targets.empty() )
179 selection.extensionRule = extensionRule;
180 else if( selection.extensionRule != extensionRule )
181 selection.extensionRule.Clear();
183 selection.targets.push_back( {
path, isDirectory } );
186 if( selection.targets.empty() )
190 selection.extensionRule.Clear();
192 selection.canIgnore = !anyTracked && !allIgnored;
193 selection.ignored = allIgnored;
194 selection.canKeepPath = allIgnored && allNamed;
195 selection.canKeepExtension =
196 allIgnored && !selection.extensionRule.IsEmpty() &&
alg::contains( rules, selection.extensionRule );
209 wxT(
"^.*\\.kicad_pro$" ),
212 wxT(
"^.*\\.kicad_sch$" ),
213 wxT(
"^[^$].*\\.brd$" ),
214 wxT(
"^[^$].*\\.kicad_pcb$" ),
215 wxT(
"^[^$].*\\.kicad_dru$" ),
216 wxT(
"^[^$].*\\.kicad_wks$" ),
217 wxT(
"^[^$].*\\.kicad_mod$" ),
221 wxT(
"^.*\\.kicad_sym$" ),
226 wxT(
"^.*\\.gbrjob$" ),
227 wxT(
"^.*\\.gb[alops]$" ),
228 wxT(
"^.*\\.gt[alops]$" ),
229 wxT(
"^.*\\.g[0-9]{1,2}$" ),
230 wxT(
"^.*\\.gm[0-9]{1,2}$" ),
234 wxT(
"^.*\\.html$" ),
245 wxT(
"^.*\\.kicad_jobset" ),
316 wxSashLayoutWindow( parent,
ID_LEFT_FRAME, wxDefaultPosition, wxDefaultSize, wxNO_BORDER | wxTAB_TRAVERSAL ),
327 Bind( wxEVT_FSWATCHER,
330 Bind( wxEVT_SYS_COLOUR_CHANGED,
344 m_filters.emplace_back( wxT(
"^no KiCad files found" ) );
354 Unbind( wxEVT_FSWATCHER,
356 Unbind( wxEVT_SYS_COLOUR_CHANGED,
366 common->RemoveRefreshListener(
this );
392 if( tree_data.size() != 1 )
395 wxString prj_filename = tree_data[0]->GetFileName();
397 m_Parent->LoadProject( prj_filename );
409 wxString curr_dir = item_data->GetDir();
411 if( curr_dir.IsEmpty() )
414 curr_dir = wxPathOnly(
m_Parent->GetProjectFileName() );
417 if( curr_dir.IsEmpty() || !wxFileName::DirExists( curr_dir ) )
420 if( !curr_dir.IsEmpty() )
421 curr_dir += wxFileName::GetPathSeparator();
436 wxString prj_dir = wxPathOnly(
m_Parent->GetProjectFileName() );
439 wxString curr_dir = item_data->GetDir();
441 if( curr_dir.IsEmpty() )
444 wxString new_dir = wxGetTextFromUser(
_(
"Directory name:" ),
_(
"Create New Directory" ) );
446 if( new_dir.IsEmpty() )
449 wxString full_dirname = curr_dir + wxFileName::GetPathSeparator() + new_dir;
451 if( !wxMkdir( full_dirname ) )
499 return wxEmptyString;
505 std::vector<wxString> projects;
506 wxString dir_filename;
507 bool haveFile = dir.GetFirst( &dir_filename );
511 wxFileName file( dir_filename );
515 projects.push_back( file.GetName() );
517 haveFile = dir.GetNext( &dir_filename );
528 const wxTreeItemId& aParent,
529 std::vector<wxString>* aProjectNames,
533 wxFileName fn( aName );
536 return wxTreeItemId();
539 if( fn.GetFullName().IsSameAs( wxS(
".git" ),
false ) )
540 return wxTreeItemId();
542 if( wxDirExists( aName ) )
550 bool addFile =
false;
552 for(
const wxString& m_filter :
m_filters )
554 wxCHECK2_MSG( reg.Compile( m_filter, wxRE_ICASE ),
continue,
555 wxString::Format(
"Regex %s failed to compile.", m_filter ) );
557 if( reg.Matches( aName ) )
565 return wxTreeItemId();
572 if( ext == wxT(
"" ) )
575 if( reg.Compile( wxString::FromAscii(
"^.*\\." ) + ext + wxString::FromAscii(
"$" ), wxRE_ICASE )
576 && reg.Matches( aName ) )
584 wxString file = wxFileNameFromPath( aName );
585 wxFileName currfile( file );
587 bool showAllSchematics =
gitRepo() !=
nullptr;
591 && ( currfile.GetName().CmpNoCase(
project.GetName() ) == 0 ) )
593 return wxTreeItemId();
602 return wxTreeItemId();
608 if( !parentTreeItem )
609 return wxTreeItemId();
611 wxDir parentDir( parentTreeItem->
GetDir() );
612 std::vector<wxString> projects =
getProjects( parentDir );
615 return wxTreeItemId();
620 wxTreeItemIdValue cookie;
621 wxTreeItemId kid =
m_TreeProject->GetFirstChild( aParent, cookie );
628 return itemData->GetId();
649 if( fname.GetName().CmpNoCase( currfile.GetName() ) == 0 )
655 return wxTreeItemId();
661 return wxTreeItemId();
688 wxTreeItemId newItemId =
m_TreeProject->AppendItem( aParent, file );
695 wxString fileName = currfile.GetName().Lower();
696 wxString projName =
project.GetName().Lower();
698 if( fileName == projName || fileName.StartsWith( projName +
"-" ) )
702 bool subdir_populated =
false;
713 std::vector<wxString> projects =
getProjects( dir );
714 wxString dir_filename;
715 bool haveFile = dir.GetFirst( &dir_filename );
720 subdir_populated = aRecurse;
726 wxString
path = aName + wxFileName::GetPathSeparator() + dir_filename;
729 haveFile = dir.GetNext( &dir_filename );
738 if( subdir_populated )
758 wxString pro_dir =
m_Parent->GetProjectFileName();
772 if( !
Pgm().GetCommonSettings()->m_Git.enableGit )
778 wxFileName fn = pro_dir;
779 bool prjReset =
false;
790 bool prjOpened = fn.FileExists();
792 if(
Pgm().GetCommonSettings()->m_Git.enableGit )
800 if( !prjOpened && !prjReset )
803 prjOpened = fn.FileExists();
823 pro_dir = wxPathOnly(
m_Parent->GetProjectFileName() );
824 wxDir dir( pro_dir );
828 std::vector<wxString> projects =
getProjects( dir );
830 bool haveFile = dir.GetFirst( &filename );
834 if( filename != fn.GetFullName() )
836 wxString
name = dir.GetName() + wxFileName::GetPathSeparator() + filename;
843 haveFile = dir.GetNext( &filename );
860 wxLogTrace(
traceGit,
"PROJECT_TREE_PANE::ReCreateTreePrj: starting timers" );
869 wxTreeItemId curr_item = Event.GetItem();
888 bool can_switch_to_project =
true;
889 bool can_create_new_directory =
true;
890 bool can_open_this_directory =
true;
891 bool can_edit =
true;
892 bool can_rename =
true;
893 bool can_delete =
true;
894 bool run_jobs =
false;
897 bool vcs_enabled = !gitIntegrationDisabled;
898 bool vcs_has_repo =
gitRepo() !=
nullptr;
899 bool vcs_can_init = vcs_enabled && !vcs_has_repo;
900 bool vcs_can_set_remote = vcs_enabled && vcs_has_repo;
903 bool vcs_can_remove = vcs_has_repo || gitIntegrationDisabled;
904 bool vcs_can_switch = vcs_enabled && vcs_has_repo;
905 bool vcs_can_show_history = vcs_enabled && vcs_has_repo;
911 vcs_menu &= libgit_init;
913 if( selection.size() == 0 )
917 if( selection.size() != 1 )
919 can_switch_to_project =
false;
920 can_create_new_directory =
false;
929 can_switch_to_project =
false;
935 can_delete = item->CanDelete();
936 can_rename = item->CanRename();
938 switch( item->GetType() )
946 can_switch_to_project =
false;
950 can_create_new_directory =
false;
951 can_open_this_directory =
false;
956 can_switch_to_project =
false;
963 can_switch_to_project =
false;
964 can_create_new_directory =
false;
965 can_open_this_directory =
false;
978 can_switch_to_project =
false;
979 can_create_new_directory =
false;
980 can_open_this_directory =
false;
990 if( can_switch_to_project )
993 _(
"Close all editors, and switch to the selected project" ),
995 popup_menu.AppendSeparator();
998 if( can_create_new_directory )
1004 if( can_open_this_directory )
1006 if( selection.size() == 1 )
1009 text =
_(
"Reveal in Finder" );
1010 help_text =
_(
"Reveals the directory in a Finder window" );
1012 text =
_(
"Open Directory in File Explorer" );
1013 help_text =
_(
"Opens the directory in the default system file manager" );
1019 text =
_(
"Reveal in Finder" );
1020 help_text =
_(
"Reveals the directories in a Finder window" );
1022 text =
_(
"Open Directories in File Explorer" );
1023 help_text =
_(
"Opens the directories in the default system file manager" );
1033 if( selection.size() == 1 )
1034 help_text =
_(
"Open the file in a Text Editor" );
1036 help_text =
_(
"Open files in a Text Editor" );
1042 if( run_jobs && selection.size() == 1 )
1050 if( selection.size() == 1 )
1052 text =
_(
"Rename File..." );
1053 help_text =
_(
"Rename file" );
1057 text =
_(
"Rename Files..." );
1058 help_text =
_(
"Rename files" );
1067 if( selection.size() == 1 )
1068 help_text =
_(
"Delete the file and its content" );
1070 help_text =
_(
"Delete the files and their contents" );
1072 if( can_switch_to_project
1073 || can_create_new_directory
1074 || can_open_this_directory
1078 popup_menu.AppendSeparator();
1095 const bool repoWide =
1096 selection.size() == 1 && selection[0] && selection[0]->GetId() ==
m_TreeProject->GetRootItem();
1097 wxMenu* vcs_submenu =
new wxMenu();
1098 wxMenuItem* vcs_menuitem =
nullptr;
1105 _(
"Initialize a new repository" ) );
1106 vcs_menuitem->Enable( vcs_can_init );
1109 _(
"Set or change the default remote URL and credentials" ) );
1110 vcs_menuitem->Enable( vcs_can_set_remote );
1114 vcs_submenu->AppendSeparator();
1116 vcs_menuitem = vcs_submenu->Append(
ID_GIT_HISTORY,
_(
"Version History..." ),
1117 _(
"Show the commits made to this project" ) );
1118 vcs_menuitem->Enable( vcs_can_show_history );
1122 std::shared_ptr<KIGIT_COMMON> common =
gitCommon();
1123 std::vector<KIGIT_BRANCH_INFO> branches;
1128 std::unique_lock<std::mutex> branchLock = common->TryLockAction();
1130 if( branchLock.owns_lock() )
1131 branches = common->GetBranches();
1138 if( branch.isRemote || branch.isCurrent )
1147 wxMenu* branch_submenu =
new wxMenu();
1153 vcs_menuitem->Enable( vcs_can_switch );
1157 _(
"Switch to a different branch" ) );
1158 vcs_menuitem->Enable( vcs_can_switch );
1160 vcs_menuitem = vcs_submenu->Append(
ID_GIT_SWITCH_BRANCH,
_(
"Switch to Branch" ), branch_submenu );
1161 vcs_menuitem->Enable( vcs_can_switch );
1164 bool ignore_usable =
false;
1167 vcs_menuitem = vcs_submenu->AppendSubMenu( ignore_submenu,
_(
"Ignore" ) );
1168 vcs_menuitem->Enable( ignore_usable );
1172 vcs_submenu->AppendSeparator();
1174 if( gitIntegrationDisabled )
1176 vcs_menuitem = vcs_submenu->Append(
ID_GIT_REMOVE_VCS,
_(
"Enable Git Integration" ),
1177 _(
"Re-enable Git integration for this project" ) );
1181 vcs_menuitem = vcs_submenu->Append(
ID_GIT_REMOVE_VCS,
_(
"Disable Git Integration" ),
1182 _(
"Disable Git integration for this project" ) );
1185 vcs_menuitem->Enable( vcs_can_remove );
1188 popup_menu.AppendSeparator();
1189 popup_menu.AppendSubMenu( vcs_submenu,
_(
"Version Control" ) );
1192 if( popup_menu.GetMenuItemCount() > 0 )
1193 PopupMenu( &popup_menu );
1201 if( editorname.IsEmpty() )
1203 wxMessageBox(
_(
"No text editor selected in KiCad. Please choose one." ) );
1207 for(
const wxString& fullFileName : aFileNames )
1209 if( !fullFileName.IsEmpty() )
1210 ExecuteFile( editorname, fullFileName.wc_str(),
nullptr,
false );
1217 std::vector<wxString> fileNames;
1220 fileNames.push_back( item_data->GetFileName() );
1231 item_data->Delete();
1241 if( tree_data.size() != 1 )
1245 wxString msg = wxString::Format(
_(
"Change filename: '%s'" ),
1246 tree_data[0]->GetFileName() );
1247 wxTextEntryDialog dlg( wxGetTopLevelParent(
this ), msg,
_(
"Change filename" ), buffer );
1249 if( dlg.ShowModal() != wxID_OK )
1252 buffer = dlg.GetValue();
1253 buffer.Trim(
true );
1254 buffer.Trim(
false );
1256 if( buffer.IsEmpty() )
1259 tree_data[0]->Rename( buffer,
true );
1268 if( tree_data.size() != 1 )
1291 std::vector<wxTreeItemId> validItemIds;
1294 for( wxTreeItemId
id : validItemIds )
1313 wxTreeItemId itemId = Event.GetItem();
1323 wxTreeItemIdValue cookie;
1324 wxTreeItemId kid =
m_TreeProject->GetFirstChild( itemId, cookie );
1327 bool subdir_populated =
false;
1330 for( ; kid.IsOk(); kid =
m_TreeProject->GetNextChild( itemId, cookie ) )
1341 wxDir dir( fileName );
1343 if( dir.IsOpened() )
1345 std::vector<wxString> projects =
getProjects( dir );
1346 wxString dir_filename;
1347 bool haveFile = dir.GetFirst( &dir_filename );
1352 wxString
name = fileName + wxFileName::GetPathSeparator() + dir_filename;
1355 haveFile = dir.GetNext( &dir_filename );
1361 subdir_populated =
true;
1370 if( subdir_populated )
1378 wxArrayTreeItemIds selection;
1379 std::vector<PROJECT_TREE_ITEM*> data;
1383 for(
const wxTreeItemId itemId : selection )
1389 wxLogTrace(
traceGit, wxS(
"Null tree item returned for selection, dynamic_cast failed?" ) );
1393 data.push_back( item );
1408 wxString prj_dir = wxPathOnly(
m_Parent->GetProjectFileName() );
1412 if( prj_dir == aSubDir )
1416 wxTreeItemIdValue cookie;
1417 wxTreeItemId root_id =
m_root;
1418 std::stack<wxTreeItemId> subdirs_id;
1420 wxTreeItemId child =
m_TreeProject->GetFirstChild( root_id, cookie );
1424 if( ! child.IsOk() )
1426 if( subdirs_id.empty() )
1433 root_id = subdirs_id.top();
1454 subdirs_id.push( child );
1472 if( !( event.GetChangeType() & ( wxFSW_EVENT_CREATE |
1473 wxFSW_EVENT_DELETE |
1474 wxFSW_EVENT_RENAME |
1475 wxFSW_EVENT_MODIFY ) ) )
1480 const wxFileName& pathModified =
event.GetPath();
1483 if( pathModified.GetFullPath().Contains( wxS(
".history" ) ) )
1486 wxString subdir = pathModified.GetPath();
1487 wxString fn = pathModified.GetFullPath();
1490 if( pathModified.GetFullName().IsEmpty() )
1492 subdir = subdir.BeforeLast(
'/' );
1493 fn = fn.BeforeLast(
'/' );
1498 if( !root_id.IsOk() )
1501 CallAfter( [
this] ()
1503 wxLogTrace(
traceGit, wxS(
"File system event detected, updating tree cache" ) );
1507 wxTreeItemIdValue cookie;
1508 wxTreeItemId kid =
m_TreeProject->GetFirstChild( root_id, cookie );
1510 switch( event.GetChangeType() )
1512 case wxFSW_EVENT_CREATE:
1527 case wxFSW_EVENT_DELETE:
1541 case wxFSW_EVENT_RENAME :
1543 const wxFileName& newpath =
event.GetNewPath();
1544 wxString newdir = newpath.GetPath();
1545 wxString newfn = newpath.GetFullPath();
1569 if( rootData && newpath.Exists() && ( newfn != rootData->
GetFileName() ) )
1575 if( newitem.IsOk() )
1596 wxString prj_dir = wxPathOnly(
m_Parent->GetProjectFileName() );
1598#if defined( _WIN32 )
1605 m_Parent->m_FileWatcherInfo =
_(
"Network path: not monitoring folder changes" );
1611 m_Parent->m_FileWatcherInfo =
_(
"Local path: monitoring folder changes" );
1629 class WatcherLogHandler :
public wxLog
1632 explicit WatcherLogHandler(
bool* err ) :
1640 void DoLogTextAtLevel( wxLogLevel level,
const wxString&
text )
override
1642 if( m_err && ( level == wxLOG_Error || level == wxLOG_FatalError ) )
1650 bool watcherHasError =
false;
1651 WatcherLogHandler tmpLog( &watcherHasError );
1660 if( watcherHasError )
1668 fn.AssignDir( prj_dir );
1669 fn.DontFollowLink();
1683 TO_UTF8( fn.GetFullPath() ) );
1691 TO_UTF8( fn.GetFullPath() ) );
1696 if( m_TreeProject->IsEmpty() )
1700 wxTreeItemIdValue cookie;
1701 wxTreeItemId root_id = m_root;
1703 std::stack < wxTreeItemId > subdirs_id;
1705 wxTreeItemId kid = m_TreeProject->GetFirstChild( root_id, cookie );
1706 int total_watch_count = 0;
1712 if( subdirs_id.empty() )
1718 root_id = subdirs_id.top();
1720 kid = m_TreeProject->GetFirstChild( root_id, cookie );
1735 if(
path.Contains( wxS(
".history" ) ) )
1737 kid = m_TreeProject->GetNextChild( root_id, cookie );
1743 if( wxFileName::IsDirReadable(
path ) )
1748 fn.AssignDir(
path );
1749 m_watcher->Add( fn );
1750 total_watch_count++;
1754 if( itemData->
IsPopulated() && m_TreeProject->GetChildrenCount( kid ) )
1755 subdirs_id.push( kid );
1759 kid = m_TreeProject->GetNextChild( root_id, cookie );
1766#if defined(DEBUG) && 1
1767 wxArrayString paths;
1768 m_watcher->GetWatchedPaths( &paths );
1771 for(
unsigned ii = 0; ii < paths.GetCount(); ii++ )
1798 std::shared_ptr<KIGIT_COMMON> common =
gitCommon();
1799 common->SetShuttingDown(
true );
1801 std::unique_lock<std::mutex> lock = common->TryLockAction();
1803 constexpr auto kGraceMs = std::chrono::seconds( 2 );
1804 auto graceEnd = std::chrono::steady_clock::now() + kGraceMs;
1806 while( !lock.owns_lock() && std::chrono::steady_clock::now() < graceEnd )
1808 if( lock.try_lock() )
1810 std::this_thread::sleep_for( std::chrono::milliseconds( 50 ) );
1813 constexpr auto kCheckInterval = std::chrono::seconds( 30 );
1814 bool userAbandoned =
false;
1816 while( !lock.owns_lock() && !userAbandoned )
1818 auto intervalEnd = std::chrono::steady_clock::now() + kCheckInterval;
1821 wxProgressDialog progress(
_(
"Please wait" ),
1822 _(
"Closing project..." ),
1824 wxPD_APP_MODAL | wxPD_SMOOTH );
1826 while( !lock.try_lock()
1827 && std::chrono::steady_clock::now() < intervalEnd )
1830 std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) );
1835 if( lock.owns_lock() )
1838 wxMessageDialog ask(
this,
1839 _(
"A Git operation is still running.\n"
1840 "Keep waiting, or abandon?" ),
1841 _(
"Git Operation Delayed" ),
1842 wxYES_NO | wxICON_QUESTION );
1843 ask.SetYesNoLabels(
_(
"Keep Waiting" ),
_(
"Abandon" ) );
1845 if( ask.ShowModal() == wxID_NO )
1846 userAbandoned =
true;
1860 common->SetRepo(
nullptr );
1884 std::shared_ptr<KIGIT_COMMON> common =
gitCommon();
1896 previous->RemoveRefreshListener(
this );
1900 common->AddRefreshListener(
this,
1928 wxRect
rect( wxPoint( 0, 0 ), GetClientSize() );
1929 wxPaintDC
dc(
this );
1931 dc.SetBrush( wxSystemSettings::GetColour( wxSYS_COLOUR_FRAMEBK ) );
1932 dc.SetPen( wxPen( wxSystemSettings::GetColour( wxSYS_COLOUR_ACTIVEBORDER ), 1 ) );
1976 wxString dir = tree_data->
GetDir();
1980 wxLogError(
"Failed to initialize git project: project directory is empty." );
1985 wxWindow* topLevelParent = wxGetTopLevelParent(
this );
1990 _(
"The selected directory is already a Git project." ) );
2006 const char* canonicalWorkDir = git_repository_workdir( initHandler.
GetRepo() );
2008 if( canonicalWorkDir )
2011 dir, wxString::FromUTF8( canonicalWorkDir ) );
2016 dlg.SetTitle(
_(
"Set default remote" ) );
2043 bool retriedAfterTrust =
false;
2049 std::make_unique<WX_PROGRESS_REPORTER>(
this,
_(
"Fetch Remote" ), 1,
PR_NO_ABORT ) );
2057 if( std::optional<KIGIT::HOST_KEY_FAILURE> hostKey = handler.
GetHostKeyFailure() )
2062 retriedAfterTrust =
true;
2100 wxString existingURL;
2106 if( !lock.owns_lock() )
2109 git_remote* remote =
nullptr;
2111 if( git_remote_lookup( &remote, repo,
"origin" ) == GIT_OK )
2115 if(
const char* url = git_remote_url( remote ) )
2116 existingURL = wxString::FromUTF8( url );
2131 wxWeakRef<PROJECT_TREE_PANE> self(
this );
2132 std::shared_ptr<KIGIT_COMMON> session =
gitCommon();
2138 [self, session, existingURL, username](
bool aFound,
const wxString& aSecret )
2140 if( !self || self->gitCommon() != session || session->IsShuttingDown() || !session->GetRepo() )
2143 self->showGitRemoteSettings( existingURL, username, aFound ? aSecret : wxString() );
2149 const wxString& aPassword )
2157 wxWindow* topLevelParent = wxGetTopLevelParent(
this );
2159 dlg.SetTitle(
_(
"Configure Default Remote" ) );
2176 bool setupOk =
false;
2177 wxString setupError;
2178 wxString setupDetails;
2184 if( !lock.owns_lock() )
2187 setupOk = initHandler.
SetupRemote( remoteConfig );
2210 std::shared_ptr<KIGIT_COMMON> common =
gitCommon();
2212 if( !common->GetRepo() || common->IsShuttingDown() )
2219 std::vector<KIGIT_BRANCH_INFO> entries;
2220 bool loaded =
false;
2223 auto branches = std::make_shared<BRANCHES>();
2224 wxWeakRef<PROJECT_TREE_PANE> self(
this );
2231 branches->loaded =
true;
2233 [self, common, branches]()
2235 if( !branches->loaded || !self || self->IsBeingDeleted() || self->m_Parent->IsBeingDeleted()
2236 || common->IsShuttingDown() || self->gitCommon() != common
2237 || !
Pgm().GetCommonSettings()->m_Git.enableGit
2238 ||
Prj().GetLocalSettings().m_GitIntegrationDisabled )
2243 DIALOG_GIT_SWITCH dlg( wxGetTopLevelParent( self->m_Parent ), std::move( branches->entries ) );
2246 if( !self || self->IsBeingDeleted() || common->IsShuttingDown() || self->gitCommon() != common )
2249 if( retval == wxID_OK || retval == wxID_ADD )
2250 self->switchGitBranch( common, dlg.
GetBranchName(), retval == wxID_ADD );
2271 if( IsBeingDeleted() ||
m_Parent->IsBeingDeleted() ||
gitCommon() != aCommon || aCommon->IsShuttingDown()
2272 || !
Pgm().GetCommonSettings()->m_Git.enableGit ||
Prj().GetLocalSettings().m_GitIntegrationDisabled )
2293 if( IsBeingDeleted() ||
m_Parent->IsBeingDeleted() ||
gitCommon() != aCommon || aCommon->IsShuttingDown()
2294 || !
Pgm().GetCommonSettings()->m_Git.enableGit ||
Prj().GetLocalSettings().m_GitIntegrationDisabled )
2305 if( !lock.owns_lock() )
2319 aCommon->NotifyRefreshListeners();
2328 wxMenu* submenu =
new wxMenu();
2329 std::shared_ptr<KIGIT_COMMON> common =
gitCommon();
2330 IGNORE_SELECTION ignore;
2334 if( !
Prj().GetLocalSettings().m_GitIntegrationDisabled && common->GetRepo() )
2337 std::unique_lock<std::mutex> lock = common->TryLockAction();
2339 if( lock.owns_lock() )
2340 ignore = gitIgnoreSelection( *common,
Prj().GetProjectPath(), aSelection );
2345 const bool single = ignore.targets.size() == 1;
2346 const bool folder = single && ignore.targets.front().isDirectory;
2348 auto append = [submenu](
int aId,
const wxString& aLabel,
const wxString& aHelp,
bool aEnabled )
2350 submenu->Append( aId, aLabel, aHelp )->Enable( aEnabled );
2353 if( ignore.ignored )
2357 folder ?
_(
"Stop Ignoring This Folder" )
2358 : single ?
_(
"Stop Ignoring This File" )
2359 :
_(
"Stop Ignoring Selected Items" ),
2360 _(
"Take the rule naming these out of the project's ignored files" ), ignore.canKeepPath );
2362 if( ignore.canKeepExtension )
2365 wxString::Format(
_(
"Stop Ignoring All '%s' Files" ), ignore.extensionRule ),
2366 _(
"Take that rule out of the project's ignored files" ),
true );
2372 folder ?
_(
"Ignore This Folder" )
2373 : single ?
_(
"Ignore This File" )
2374 :
_(
"Ignore Selected Items" ),
2375 _(
"Leave these out of version control" ), ignore.canIgnore );
2377 if( !ignore.extensionRule.IsEmpty() )
2380 _(
"Leave every file with this extension out of version control" ), ignore.canIgnore );
2387 submenu->AppendSeparator();
2389 _(
"Open the project's ignored files in a text editor" ), haveIgnoreFile );
2391 aUsable = ignore.canIgnore || ignore.canKeepPath || ignore.canKeepExtension || haveIgnoreFile;
2401 switch( aEvent.GetId() )
2427 wxLogTrace(
traceGit, wxS(
"onGitRemoveVCS: Git integration %s" ),
2437 std::stack<wxTreeItemId> items;
2440 while( !items.empty() )
2442 wxTreeItemId current = items.top();
2445 m_TreeProject->SetItemState( current, wxTREE_ITEMSTATE_NONE );
2447 wxTreeItemIdValue cookie;
2448 wxTreeItemId child =
m_TreeProject->GetFirstChild( current, cookie );
2450 while( child.IsOk() )
2452 items.push( child );
2470 wxLogTrace(
traceGit, wxS(
"updateGitStatusIcons: Updating git status icons" ) );
2473 if( !lock.owns_lock() )
2475 wxLogTrace(
traceGit, wxS(
"updateGitStatusIcons: Failed to acquire lock for git status icon update" ) );
2482 wxLogTrace(
traceGit, wxS(
"updateGitStatusIcons: Git is disabled or tree control is null" ) );
2486 const wxColour
normal = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT );
2487 const wxColour dimmed = wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT );
2490 std::stack<std::pair<wxTreeItemId, bool>> items;
2493 while( !items.empty() )
2495 auto [current, parentIgnored] = items.top();
2498 if( current.IsOk() &&
m_TreeProject->ItemHasChildren( current ) )
2500 wxTreeItemIdValue cookie;
2501 wxTreeItemId child =
m_TreeProject->GetFirstChild( current, cookie );
2503 while( child.IsOk() )
2507 const bool ignored =
2510 items.push( { child, ignored } );
2512 const int state = known && !ignored ?
static_cast<int>( it->second ) : wxTREE_ITEMSTATE_NONE;
2513 const wxColour colour = ignored ? dimmed :
normal;
2534 wxString filename = wxFileNameFromPath( rootItem->
GetFileName() );
2543 wxLogTrace(
traceGit, wxS(
"updateGitStatusIcons: Git status icons updated" ) );
2549 wxLogTrace(
traceGit, wxS(
"updateTreeCache: Updating tree cache" ) );
2553 if( !lock.owns_lock() )
2555 wxLogTrace(
traceGit, wxS(
"updateTreeCache: Failed to acquire lock for tree cache update" ) );
2561 wxLogTrace(
traceGit, wxS(
"updateTreeCache: Tree control is null" ) );
2572 std::stack<wxTreeItemId> items;
2575 while( !items.empty() )
2587 gitAbsPath.Replace( wxS(
"\\" ), wxS(
"/" ) );
2591 wxTreeItemIdValue cookie;
2592 wxTreeItemId child =
m_TreeProject->GetFirstChild( kid, cookie );
2594 while( child.IsOk() )
2596 items.push( child );
2604 const wxString& aProjectFullName )
2606 wxLogTrace(
traceGit, wxS(
"updateGitStatusIconMap: Updating git status icons" ) );
2607#if defined( _WIN32 )
2629 if( !lock1.owns_lock() || !lock2.owns_lock() )
2631 wxLogTrace(
traceGit, wxS(
"updateGitStatusIconMap: Failed to acquire locks for git status icon update" ) );
2637 if( !aGitCommon || !aGitCommon->GetRepo() )
2639 wxLogTrace(
traceGit, wxS(
"updateGitStatusIconMap: No git repository found" ) );
2645 std::unique_lock<std::mutex> gitLock = aGitCommon->TryLockAction();
2647 if( !gitLock.owns_lock() )
2649 wxLogTrace(
traceGit, wxS(
"updateGitStatusIconMap: Failed to acquire git action mutex" ) );
2654 if( aGitCommon->IsShuttingDown() )
2656 wxLogTrace(
traceGit, wxS(
"updateGitStatusIconMap: Cancelled" ) );
2664 wxFileName rootFilename( aProjectFullName );
2667 wxFileName relative = rootFilename;
2668 relative.MakeRelativeTo( repoWorkDir );
2669 wxString pathspecStr = relative.GetPath( wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR );
2672 pathspecStr.Replace( wxS(
"\\" ), wxS(
"/" ) );
2676 auto fileStatusMap = statusHandler.
GetFileStatus( pathspecStr );
2677 auto [localChanges, remoteChanges] = aGitCommon->GetDifferentFiles();
2680 std::map<wxString, unsigned int> currentStatus;
2682 for(
const auto& [absPath, fileStatus] : fileStatusMap )
2683 currentStatus.emplace( absPath, fileStatus.gitStatus );
2690 std::map<wxTreeItemId, KIGIT_COMMON::GIT_STATUS> icons;
2692 for(
const auto& [absPath, fileStatus] : fileStatusMap )
2698 wxLogTrace(
traceGit, wxS(
"File '%s' not found in tree cache" ), absPath );
2702 icons[iter->second] = fileStatus.status;
2718 wxLogTrace(
traceGit, wxS(
"updateGitStatusIconMap: Updated git status icons" ) );
2724 [
this, aGitCommon]()
2731 aGitCommon->NotifyRefreshListeners();
2744 wxLogTrace(
traceGit,
"onGitSyncTimer" );
2754 wxLogTrace(
traceGit,
"onGitSyncTimer: previous fetch still running, skipping" );
2761 std::shared_ptr<KIGIT_COMMON> common =
gitCommon();
2768 if( !common->GetRepo() )
2770 wxLogTrace(
traceGit,
"onGitSyncTimer: No git repository found" );
2775 if( common->IsShuttingDown() )
2777 wxLogTrace(
traceGit,
"onGitSyncTimer: Cancelled" );
2787 if( !common->IsShuttingDown() )
2789 [
this, common, fetched, kind, summary]()
2792 if( common->IsShuttingDown() || common !=
gitCommon() )
2800 common->NotifyRefreshListeners();
2804 wxLogTrace(
traceGit,
"onGitSyncTimer: Restarting git sync timer" );
2811 const wxString& aSummary )
2831 if( existing.GetTitle() == aSummary )
2849 std::shared_ptr<KIGIT_COMMON> common =
gitCommon();
2851 if( common->IsShuttingDown() )
2865 [
this, common, projectFullName]()
2873 wxLogTrace(
traceGit,
"onGitStatusTimer" );
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
void SetRepoSSHPath(const wxString &aPath)
KIGIT_COMMON::GIT_CONN_TYPE GetRepoType() const
void SetPassword(const wxString &aPassword)
wxString GetRepoSSHPath() const
The private key, also when its .pub was picked.
wxString GetRepoURL() const
wxString GetUsername() const
void SetUsername(const wxString &aUsername)
wxString GetPassword() const
void SetSkipButtonLabel(const wxString &aLabel)
wxString GetBranchName() const
virtual bool IsLibraryAvailable()=0
bool IsRepository(const wxString &aPath)
Check if a directory is already a git repository.
InitResult InitializeRepository(const wxString &aPath)
Initialize a new git repository in the specified directory.
bool SetupRemote(const RemoteConfig &aConfig)
Set up a remote for the repository.
void SetProgressReporter(std::unique_ptr< PROGRESS_REPORTER > aProgressReporter)
bool PerformFetch(bool aSkipLock=false)
std::map< wxString, FileStatus > GetFileStatus(const wxString &aPathspec=wxEmptyString, bool aChangedOnly=false)
Get detailed file status for all files in the specified path.
wxString GetCurrentBranchName()
Get the current branch name.
void UpdateRemoteStatus(const std::set< wxString > &aLocalChanges, const std::set< wxString > &aRemoteChanges, std::map< wxString, FileStatus > &aFileStatus)
Get status for modified files based on local/remote changes.
wxString GetWorkingDirectory()
Get the repository working directory path.
The main KiCad project manager frame.
void OnChangeWatchedPaths(wxCommandEvent &aEvent)
Called by sending a event with id = ID_INIT_WATCHED_PATHS rebuild the list of watched paths.
PROJECT_TREE_PANE * m_projectTreePane
static wxString ComputeSymlinkPreservingWorkDir(const wxString &aUserProjectPath, const wxString &aCanonicalWorkDir)
Compute a working directory path that preserves symlinks from the user's project path.
static bool RemoveVCS(git_repository *&aRepo, const wxString &aProjectPath=wxEmptyString, bool aRemoveGitDir=false, wxString *aErrors=nullptr)
Remove version control from a directory by freeing the repository and optionally removing the ....
static int CreateBranch(git_repository *aRepo, const wxString &aBranchName)
Create a new branch based on HEAD.
The project's git session.
wxString GetRemote() const
void SetUsername(const wxString &aUsername)
git_repository * GetRepo() const
void SetProjectDir(const wxString &aProjectDir)
Keep symlinks in the repository path so Git status paths match the project tree.
static constexpr std::chrono::milliseconds ACTION_LOCK_WAIT
Long enough for a status read to finish, short enough that a window does not look hung.
wxString GetUsername() const
void SetShuttingDown(bool aCancel)
Stop the operation running now and keep later ones from starting.
static wxString GetLastGitError()
libgit2's last message, without credentials from any URL it quotes, so it is safe to show or trace.
void UpdateCurrentBranchInfo()
static REMOTE_URL ParseRemoteURL(const wxString &aURL)
wxString GetPassword()
The secret for the remote, read without ever prompting, so it is safe on a transfer worker.
std::vector< KIGIT_BRANCH_INFO > GetBranches() const
Local and remote branches with their tip commits.
void SetRemote(const wxString &aRemote)
bool SecretRead() const
False while the keyring has not been read for the current remote.
KIGIT_ERROR_MESSAGE PopError()
Take the newest error with its details. Both are empty when none is queued.
Read repository state without blocking the UI.
std::optional< KIGIT::HOST_KEY_FAILURE > GetHostKeyFailure() const
The host key this operation's transfer refused, for the UI to offer to trust or to report.
git_repository * GetRepo() const
Get a pointer to the git repository.
void SetActionLockWait(std::chrono::milliseconds aWait)
A UI caller retrying confirmed input waits this long for a background read instead of failing at once...
std::optional< KIGIT_FAILURE > GetFailureKind() const
The kind of the last failure ReportTransferFailure classified, or none.
bool WasAuthFailure() const
Set when the server refused every credential offered, so the caller can prompt and retry.
KISTATUSBAR is a wxStatusBar suitable for Kicad manager.
void AddWarningMessages(const wxString &aSource, const wxString &aMessages)
Add warning/error messages (not thread-safe, use the std::vector<KI_ERROR> variant from other threads...
std::map< wxString, std::vector< KI_ERROR > > GetWarningMessages() const
Get a copy of all stored warning/error messages, grouped by source and sorted by source name for stab...
Holds a structured error message.
KI_ERROR & SetSeverity(SEVERITY aSeverity)
KI_ERROR & SetTitle(const wxString &aTitle)
static wxString GetDefaultUserProjectsPath()
Gets the default path we point users to create projects.
virtual COMMON_SETTINGS * GetCommonSettings() const
virtual const wxString & GetTextEditor(bool aCanShowFileChooser=true)
Return the path to the preferred text editor application.
The project local settings are things that are attached to a particular project, but also might be pa...
bool m_GitIntegrationDisabled
If true, KiCad will not use Git integration for this project even if a .git directory exists.
bool SaveToFile(const wxString &aDirectory="", bool aForce=false) override
Calls Store() and then writes the contents of the JSON document to a file.
wxString m_GitRepoUsername
Handle one item (a file or a directory name) for the tree file.
void SetRootFile(bool aValue)
const wxString & GetFileName() const
void SetPopulated(bool aValue)
TREE_FILE_TYPE GetType() const
const wxString GetDir() const
void Activate(PROJECT_TREE_PANE *aTreePrjFrame)
Window to display the tree files.
PROJECT_TREE_ITEM * m_selectedItem
void switchGitBranch(std::shared_ptr< KIGIT_COMMON > aCommon, const wxString &aBranchName, bool aCreate)
void syncGitListener()
Follow the project's git session with a refresh listener, so operations started from the version cont...
std::unordered_map< wxString, wxTreeItemId > m_gitTreeCache
void onGitIgnore(wxCommandEvent &event)
Add the selected files to, or take them out of, the project's ignored files.
std::map< wxTreeItemId, KIGIT_COMMON::GIT_STATUS > m_gitStatusIcons
void onGitInitializeProject(wxCommandEvent &event)
Initialize a new git repository in the current project directory.
void showGitRemoteSettings(const wxString &aExistingURL, const wxString &aUsername, const wxString &aPassword)
void openInTextEditor(const std::vector< wxString > &aFileNames)
Open files in the user's text editor, or explain that none is chosen.
git_repository * gitRepo() const
void onDeleteFile(wxCommandEvent &event)
Delete the selected file or directory in the tree project.
void onGitRemoveVCS(wxCommandEvent &event)
Remove the git repository from the current project directory.
void EmptyTreePrj()
Delete all m_TreeProject entries.
void FileWatcherReset()
Reinit the watched paths Should be called after opening a new project to rebuild the list of watched ...
wxString m_gitCurrentBranchName
std::vector< PROJECT_TREE_ITEM * > GetSelectedData()
Return the item data from item currently selected (highlighted)
void onOpenDirectory(wxCommandEvent &event)
Handles the right-click menu for opening a directory in the current system file browser.
void onFileSystemEvent(wxFileSystemWatcherEvent &event)
called when a file or directory is modified/created/deleted The tree project is modified when a file ...
std::vector< GIT_IGNORE_TARGET > m_gitMenuIgnoreTargets
wxFileSystemWatcher * m_watcher
void WaitForGitOperations()
Give a running background git operation a chance to finish, asking the user to keep waiting or abando...
void onRight(wxTreeEvent &Event)
Called on a right click on an item.
void onSelect(wxTreeEvent &Event)
Called on a double click on an item.
PROJECT_TREE * m_TreeProject
PROJECT_TREE_PANE(KICAD_MANAGER_FRAME *parent)
std::weak_ptr< KIGIT_COMMON > m_gitMenuSession
KICAD_MANAGER_FRAME * m_Parent
std::future< void > m_gitSyncTask
void onExpand(wxTreeEvent &Event)
Called on a click on the + or - button of an item with children.
std::weak_ptr< KIGIT_COMMON > m_gitListenerSession
std::map< wxString, unsigned int > m_gitLastStatus
Raw status of every file in the last pass, so a change with no tree item still reaches the panels.
std::vector< wxString > m_gitMenuBranches
Preserve the shortcut targets while the context menu runs its event loop.
void onGitSyncTimer(wxTimerEvent &event)
void onGitHistory(wxCommandEvent &event)
Open the advanced Git window on its History page.
void onIdle(wxIdleEvent &aEvent)
Idle event handler, used process the selected items at a point in time when all other events have bee...
void updateTreeCache()
Updates the map of the wxtreeitemid to the name of each file for use in the thread.
void gitStatusTimerHandler()
std::mutex m_gitStatusMutex
static wxString GetFileExt(TREE_FILE_TYPE type)
friend class PROJECT_TREE_ITEM
wxTreeItemId findSubdirTreeItem(const wxString &aSubDir)
Search for the item in tree project which is the node of the subdirectory aSubDir.
void onGitEditIgnoreFile(wxCommandEvent &event)
Open the project's ignore file, for rules the menu items cannot reach.
void ReCreateTreePrj()
Create or modify the tree showing project file names.
void onThemeChanged(wxSysColourChangedEvent &aEvent)
void onRunSelectedJobsFile(wxCommandEvent &event)
Run a selected jobs file.
void onGitStatusTimer(wxTimerEvent &event)
void shutdownFileWatcher()
Shutdown the file watcher.
std::mutex m_gitTreeCacheMutex
std::shared_ptr< KIGIT_COMMON > gitCommon() const
The current project's git session, created empty on first use.
void updateGitStatusIconMap(std::shared_ptr< KIGIT_COMMON > aGitCommon, const wxString &aProjectFullName)
This is a threaded call that will change the map of git status icons for use in the main thread.
wxTreeItemId addItemToProjectTree(const wxString &aName, const wxTreeItemId &aParent, std::vector< wxString > *aProjectNames, bool aRecurse)
Add the file or directory aName to the project tree.
void onGitRemoteSettings(wxCommandEvent &event)
Configure (or change) the default remote on an already-initialized repository.
void onOpenSelectedFileWithTextEditor(wxCommandEvent &event)
Call the text editor to open the selected file in the tree project.
void updateGitStatusIcons()
Updates the icons shown in the tree project to reflect the current git status.
bool m_gitIconsInitialized
std::future< void > m_gitStatusIconTask
PROJECT_TREE_ITEM * GetItemIdData(wxTreeItemId aId)
Return the item data corresponding to a wxTreeItemId identifier.
std::unique_ptr< KIGIT_QUERY > m_branchQuery
Owns the branch-switch preflight and suppresses callbacks when the project closes.
void reportGitSyncResult(bool aFetched, std::optional< KIGIT_FAILURE > aKind, const wxString &aSummary)
Background fetches have no window to answer, so each failure goes to the status bar's warnings once,...
void onGitSwitchBranch(wxCommandEvent &event)
Switch to a different branch in the git repository.
void onCreateNewDirectory(wxCommandEvent &event)
Creates a new subdirectory inside the current kicad project directory the user is prompted to enter a...
void onSwitchToSelectedProject(wxCommandEvent &event)
Switch to a other project selected from the tree project (by selecting an other .pro file inside the ...
void onPaint(wxPaintEvent &aEvent)
We don't have uniform borders so we have to draw them ourselves.
void onRenameFile(wxCommandEvent &event)
Rename the selected file or directory in the tree project.
void releaseGitRepo()
Releases the git repository handle, deferring the free to the orphan registry while a background git ...
wxMenu * buildIgnoreSubmenu(const std::vector< PROJECT_TREE_ITEM * > &aSelection, bool &aUsable)
Build the Ignore submenu for a selection, and remember what its items apply to.
std::vector< wxString > m_filters
PROJECT_TREE This is the class to show (as a tree) the files in the project directory.
Container for project specific data.
virtual std::shared_ptr< KIGIT_COMMON > GetGitCommon() const
This project's Git session, created empty on first use.
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
virtual bool AttachGitRepository()
Find the Git repository containing the project directory and bind it to the session.
virtual PROJECT_LOCAL_SETTINGS & GetLocalSettings() const
virtual void ReleaseGitCommon()
Safely release the session's repository handle and drop the session.
A scoped application of a wxLog target.
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
wxDECLARE_EVENT(wxEVT_REFRESH_CUSTOM_COMMAND, wxCommandEvent)
EVT_MENU_RANGE(ID_GERBVIEW_DRILL_FILE1, ID_GERBVIEW_DRILL_FILEMAX, GERBVIEW_FRAME::OnDrlFileHistory) EVT_MENU_RANGE(ID_GERBVIEW_ZIP_FILE1
int ExecuteFile(const wxString &aEditorName, const wxString &aFileName, wxProcess *aCallback, bool aFileForKicad)
Call the executable file aEditorName with the parameter aFileName.
GIT_BACKEND * GetGitBackend()
void ChangeGitIgnore(EDA_BASE_FRAME *aFrame, wxWindow *aParent, GIT_IGNORE_CHANGE aChange, const std::vector< GIT_IGNORE_TARGET > &aTargets)
Write a change to the project's ignored files and refresh every Git surface.
void ProjectClearOfUncommittedWork(EDA_BASE_FRAME *aFrame, wxWindow *aParent, KIGIT_QUERY &aQuery, std::function< void(const GIT_WORKTREE_STATUS &)> aReady)
Check the working tree and Git LFS on a worker, then run aReady on the UI thread when the operation c...
void SwitchProjectToBranch(EDA_BASE_FRAME *aFrame, wxWindow *aParent, const wxString &aBranch, KIGIT_QUERY &aQuery, std::function< void()> aFinished)
Check the working tree on a worker, then confirm switching to aBranch and recheck unsaved editors.
GIT_IGNORE_CHANGE
Which change to the project's ignored files a menu item asks for.
@ IGNORE_PATH
Ignore the paths themselves.
@ KEEP_EXTENSION
Stop ignoring every file sharing the paths' extension.
@ KEEP_PATH
Stop ignoring the paths themselves.
@ IGNORE_EXTENSION
Ignore every file sharing the paths' extension.
int m_GitIconRefreshInterval
The interval in milliseconds to refresh the git icons in the project tree.
static const std::string LegacySchematicFileExtension
static const std::string HtmlFileExtension
static const wxString GerberFileExtensionsRegex
static const std::string NetlistFileExtension
static const std::string GerberJobFileExtension
static const std::string ReportFileExtension
static const std::string ProjectFileExtension
static const std::string FootprintPlaceFileExtension
static const std::string LegacyPcbFileExtension
static const std::string LegacyProjectFileExtension
static const std::string KiCadSchematicFileExtension
static const std::string LegacySymbolLibFileExtension
static const std::string CsvFileExtension
static const std::string KiCadSymbolLibFileExtension
static const std::string SpiceFileExtension
static const std::string PdfFileExtension
static const std::string TextFileExtension
static const std::string DrawingSheetFileExtension
static const std::string KiCadJobSetFileExtension
static const std::string FootprintAssignmentFileExtension
static const std::string SVGFileExtension
static const std::string DrillFileExtension
static const std::string DesignRulesFileExtension
static const std::string MarkdownFileExtension
static const std::string KiCadFootprintFileExtension
static const std::string ArchiveFileExtension
static const std::string KiCadPcbFileExtension
const wxChar *const tracePathsAndFiles
Flag to enable path and file name debug output.
const wxChar *const traceGit
Flag to enable Git debugging output.
EVT_MENU(ID_COMPARE_PROJECT_BRANCHES, KICAD_MANAGER_FRAME::OnCompareProjectBranches) KICAD_MANAGER_FRAME
bool LaunchExternal(const wxString &aPath)
Launches the given file or folder in the host OS.
This file contains miscellaneous commonly used macros and functions.
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
void ClearSyncWarnings(wxWindow *aWindow)
Clear the background fetch's warnings from the frame holding aWindow.
void SortBranchesForDisplay(std::vector< KIGIT_BRANCH_INFO > &aBranches)
Put the current branch first, then local and remote branches with the newest tips first.
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 ...
constexpr const wxChar * SYNC_WARNING_SOURCE
The status bar source under which background fetch failures are listed.
APIEXPORT wxFileName ProjectIgnoreFile(const wxString &aProjectPath)
The ignore file that covers a project.
std::unique_lock< std::mutex > WaitForActionLock(KIGIT_COMMON &aCommon, wxWindow *aParent)
TryLockAction that first waits a moment for a status read or fetch to let go.
APIEXPORT wxString ExtensionIgnoreRule(const wxString &aProjectRelPath)
The rule that ignores every file sharing a path's extension, or nothing when it has none.
PROMPT_ANSWER PromptForCredentials(wxWindow *aParent, KIGIT_COMMON *aCommon, PROJECT *aProject=nullptr, const wxString &aExplanation=wxEmptyString)
Ask the user for the credentials of the session's remote and apply them to the session.
std::unique_lock< std::mutex > TryLockAction(KIGIT_COMMON &aCommon, wxWindow *aParent)
Try the action lock and show a busy message if it is unavailable.
APIEXPORT IGNORE_STATE IgnoreState(KIGIT_COMMON &aCommon, const wxString &aProjectRelPath, bool aIsDirectory)
What git's rules and its index say about a project path, so the user is offered only what would take ...
PROMPT_ANSWER PromptToTrustHost(wxWindow *aParent, const HOST_KEY_FAILURE &aFailure, bool aRetriedAfterTrust)
Ask whether to trust a server seen for the first time, and remember its key when the user agrees.
APIEXPORT wxString PathIgnoreRule(const wxString &aProjectRelPath, bool aIsDirectory)
The rule that ignores one path and nothing else.
APIEXPORT std::vector< wxString > ReadIgnoreRules(const wxFileName &aIgnoreFile)
The rules an ignore file holds, in order, without its comments and blank lines.
std::unique_ptr< git_remote, decltype([](git_remote *aRemote) { git_remote_free(aRemote); })> GitRemotePtr
A unique pointer for git_remote objects with automatic cleanup.
KICOMMON_API wxMenuItem * AddMenuItem(wxMenu *aMenu, int aId, const wxString &aText, const wxBitmapBundle &aImage, wxItemKind aType=wxITEM_NORMAL)
Create and insert a menu item with an icon into aMenu.
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
PGM_BASE & Pgm()
The global program "get" accessor.
#define NAMELESS_PROJECT
default name for nameless projects
static bool gitTaskStillRunning(const std::future< void > &aTask)
project_tree_ids
The frame that shows the tree list of files and subdirectories inside the working directory.
@ ID_PROJECT_SWITCH_TO_OTHER
@ ID_GIT_EDIT_IGNORE_FILE
@ ID_GIT_IGNORE_EXTENSION
@ ID_GIT_INITIALIZE_PROJECT
static bool promptForGitCredentials(wxWindow *aParent, KIGIT_COMMON *aCommon, const wxString &aExplanation)
static void saveAcceptedRemoteSettings(PROJECT &aProject, const RemoteConfig &aConfig)
std::vector< wxString > getProjects(const wxDir &dir)
static const wxChar * s_allowedExtensionsToList[]
#define wxFileSystemWatcher
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Repository state used before an operation that requires a clean working tree.
What an ignore rule for one path would achieve.
bool tracked
The path, or a file inside it, is in the index, so a new rule would do nothing.
bool ignored
Git's rules already cover the path.
A summary the user can act on, with the raw text that explains it kept apart for the details.
KIGIT_COMMON::GIT_CONN_TYPE connType
DATABASE_CONNECTION dc(odbcBackend(cs))
wxString result
Test unit parsing edge cases and error handling.
thread_pool & GetKiCadThreadPool()
Get a reference to the current thread pool.
BS::priority_thread_pool thread_pool
wxLogTrace helper definitions.
static PIECE rect(double aLeft, double aTop, double aRight, double aBottom, bool aMixed=false)
Definition of file extensions used in Kicad.